开发者

Bug or feature? Paths replaced by symlinks are "forgotten" by git

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, t开发者_如何学运维he 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


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 (git@vger.kernel.org),


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜