Skip to content

Calling repo.index.add('DIR_SYMLINK') adds contents of symlinked directory, not symlink #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ben-en opened this issue Jun 25, 2015 · 6 comments

Comments

@ben-en
Copy link

ben-en commented Jun 25, 2015

I have a git repo that i'm using in a pretty roundabout way. Basically i have a repo/master directory which stores a bunch of folders that have content in them. Then i have some repo/SECTION folders. To identify where each piece of content goes, i symlink the directory to the section it belongs in. Calling git add on the symlink directly adds the symlink, and not the content of the linked directory. After initializing the repo with GitPython calling repo.index.add('SECTION/DIR_SYMLINK') results in all of the items from the folder being added as if DIR_SYMLINK were a folder, but does not add its folder. See git output below.

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   gal19/117a76a47d475c3e9866701d24302a45/image0000.jpg
        new file:   gal19/117a76a47d475c3e9866701d24302a45/image0001.png
        ...
        new file:   gal19/117a76a47d475c3e9866701d24302a45/image0035.jpg
        new file:   gal19/117a76a47d475c3e9866701d24302a45/image0036.jpg
        new file:   gal19/117a76a47d475c3e9866701d24302a45/index.html
        new file:   gal19/117a76a47d475c3e9866701d24302a45/info.json

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        gal19/117a76a47d475c3e9866701d24302a45

After a git reset HEAD and git add gal19/117a76a47d475c3e9866701d24302a45 this is the git status:

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   gal19/117a76a47d475c3e9866701d24302a45
@Byron Byron added this to the v1.0.2 - Fixes milestone Jun 26, 2015
@Byron
Copy link
Member

Byron commented Jun 26, 2015

I am able to reproduce the issue, and am working on a fix.

@Byron Byron closed this as completed in cfc70fe Jun 26, 2015
@Byron
Copy link
Member

Byron commented Jun 26, 2015

Please feel free to try the latest master, which contains a fix for the issue at hand.

Thanks for letting me know, the issue description was very helpful indeed.

@Byron
Copy link
Member

Byron commented Jun 26, 2015

You can watch the development stream on youtube.

GitPython #11 [issue 302 - fix adding symlinks to directories]

thumb

@ben-en
Copy link
Author

ben-en commented Jun 30, 2015

Hi Byron! Thanks for taking on this issue so quickly. Unfortunately this does not seem to resolve my issue. As you assumed, i am on the latest GitPython (now 0.3.6) and am on Python 3. As you also (correctly) assumed, the gal19 folder is a 'SECTION' and the random hash is the symlink to the directory. Now, with a fully committed git repo, i've manually added a symlink to a directory again. This time i've just used GitPython in the interactive python shell. Here are the commands and their responses:

>>> from git import Repo
>>> repo = Repo('/srv/pool')
>>> repo.untracked_files
['gal19/5ee8fb6ae399027aefcaf690032f2398']
>>> repo.index.add(['gal19/5ee8fb6ae399027aefcaf690032f2398'])
[(100644, 87bbbe2d447426f6d71cf93755599344f4c792ae, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/image0007.jpg), (100644, 3c706b33dbd2f7ff446f1c4676c0c320af8d858b, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/image0002.png), (100644, c569673e8c8d590bcdf74774e6febbc56a170d71, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/info.json), (100644, 093e52366d95889636eacdeabe11ae91c68364ec, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/image0005.jpg), (100644, da584fc55428848803b06d1dc952232f2646b16f, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/image0004.jpg), (100644, bc303c4acb9d61a0a98f9674cceb4d5e989d50e2, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/image0006.jpg), (100644, 288b55b618b554b3a8ca0b9c66e256ebfcbef254, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/image0000.jpg), (100644, 21c3c150c3d21eb102d88d1f05d8696b745f92d1, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/index.html), (100644, 44217e0b63d2899f89fd6d190feac41dc5a52ef7, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/image0001.png), (100644, 2fb50b1b83ac263ed52a5fdf374c72589d8cab98, 0, gal19/5ee8fb6ae399027aefcaf690032f2398/image0003.jpg)]

As you can see in the last line, the same result has occurred as the original bug description. Below is the git status which illustrates this better.

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/image0000.jpg
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/image0001.png
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/image0002.png
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/image0003.jpg
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/image0004.jpg
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/image0005.jpg
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/image0006.jpg
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/image0007.jpg
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/index.html
        new file:   gal19/5ee8fb6ae399027aefcaf690032f2398/info.json

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        gal19/5ee8fb6ae399027aefcaf690032f2398

I'm not sure what other information i could provide, but feel free to request anything you'd think would help!
Thanks again for taking the time to handle this issue.

@Byron
Copy link
Member

Byron commented Jul 1, 2015

If you are using GitPython v0.3.6, you are not using the version that contains the fix. The latter is only to be found on github - if you grab the latest master, you should be fine indeed.

Would you try again and let me know ? Thank you

@ben-en
Copy link
Author

ben-en commented Jul 1, 2015

Oh thank you, i had thought i had managed to acquire the latest version from github. I am now on 1.0.1 and it works! Thank you very much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants