Thread (33 messages) flat view 33 messages, 5 authors, 2018-01-02

[BUG] File move with `add -N` shows as rename to same name

From: Alex Vandiver <hidden>
Date: 2017-12-23 02:51:05
Subsystem: the rest · Maintainer: Linus Torvalds

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<--------------------
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help