tags:

views:

39

answers:

2

I've seen a few git-with-symlinks questions answered on here, but I'm still puzzled by this one.

Suppose I've added directories to a git repository, then later replaced the directory with a symbolic link having the same name. The files are "still there" in the sense that they still have the same path through the symbolic link. However, since git doesn't follow the links, the files are ostensibly forgotten/deleted. However, no mention of this is made when I run "git status."

I was happily working away thinking nothing was wrong until I realized the files were considered deleted by running "git diff."

Thus, I have two questions: is there a reason the files wouldn't show up in "git status" as deleted or moved? Also, how can I get the files re-added?

For those who aren't sure what I'm talking about, consider this example:


$ git init
$ mkdir path
$ touch path/file
$ git add path
$ git commit -a -m "added file"

Then...


$ git status
# On branch master
nothing to commit (working directory clean)

Then...


$ mv path path2
$ ln -s path2 path
$ git status
# On branch master
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#   path
#   path2/
nothing added to commit but untracked files present (use "git add" to track)

Yet...


$ git diff
diff --git a/path/file b/path/file
deleted file mode 100644
index e69de29..0000000


Thanks! Tom

+1  A: 

I'd say this is pretty clearly a bug. Presumably status is using different machinery than diff, so it carelessly sees that there are no changes to path/file and doesn't realize it's behind a link. It handles directory->regular file changes fine, and also works fine if the symlink doesn't point to a directory containing the appropriate file, so it's just this specific case. Good catch! You might want to report it to the git mailing list ([email protected]),

Jefromi
Thanks Jefromi, I may just do that. :)
Tom
A: 

What version of git are you using, i am using 1.7.0.4 and I can't replicate your error, by my test it shows that the original file is a typechange and that the new file is new.

http://pastie.org/1149236

Jed Schneider
A regression, then - I'm using v1.7.3-rc0-27-g154adcf.
Jefromi
Nope, you didn't do the same test. You turned a *file* into a link to the same file, not a directory containing a file into a link to a directory containing the same file. This bug does indeed exist in v1.7.0.4 too.
Jefromi
I'm using 1.7.1, from macports.
Tom