[BUG] File move with `add -N` shows as rename to same name
- From
- Alex Vandiver <alexmv@dropbox.com>
- Date
- Dec 23, 2017, 02:42 UTC
- Message-ID
- <alpine.DEB.2.10.1712221829430.29746@alexmv-linux>
I just stumbled across the following oddity:
mv tracked-file new-path
git add -N new-path
git status..shows:
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)renamed: tracked-file -> tracked-file
no changes added to commit (use "git add" and/or "git commit -a")
Bisect points at 425a28e0a ("diff-lib: allow ita entries treated as "not yet exist in index"", 2016-10-24), but I don't have enough context to suggest the right fix.
Failing test is included below. - Alex
--------------------8<--------------------
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh index 1bdf38e80..97b6c0f05 100755 --- a/t/t2203-add-intent.sh +++ b/t/t2203-add-intent.sh @@ -150,5 +150,19 @@ test_expect_success 'commit: ita entries ignored in empty commit check' ' ) ' +test_expect_success 'rename detection finds the right names' ' + git init rename-detection && + ( + cd rename-detection && + echo contents > original-file + git add original-file + git commit -m first-commit + mv original-file new-file + git add -N new-file + git status --porcelain > actual + grep new-file actual + ) +' + test_done --------------------8<--------------------