git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Test case for a problem with git add -u from subdirectory

From
PKPekka Kaitaniemi <kaitanie@cc.helsinki.fi>
Date
Feb 20, 2008, 14:32 UTC
Message-ID
<20080220143215.GA23053@localdomain>

Manual page for "git-add -u" says: Update only files that git already knows about. This is similar to what "git commit -a" does in preparation for making a commit, except that the update is limited to paths specified on the command line. If no paths are specified, all tracked files are updated.

The key sentence being: "If no paths are specified, all tracked files are updated." If one modifies a file in subdir1, then goes to subdir2 and performs "git add -u" the modified file in subdir1 is not added to the index. This test case demonstrates the problem.

Signed-off-by: Pekka Kaitaniemi <kaitanie@cc.helsinki.fi>
---

I found a possible problem in "git add -u" command without any paths. Modified files located in a different subdirectory are not added to the index even though the documentation says that in this case all tracked files should be. Maybe this is caused by a bug in "git add"? Or is the problem in the documentation?

In any case, this patch contains a test case that demonstrates the problem.

 t/t2200-add-update.sh |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 24f892f..5815ec5 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -80,6 +80,22 @@ test_expect_success 'change gets noticed' '
 
 '
 
+test_expect_success 'update from a different subdirectory' '
+	(
+		cd dir1 &&
+		echo addmore >sub2 &&
+                cd ../dir2 &&
+                git add -u
+	)
+
+'
+
+test_expect_success 'change gets noticed' '
+
+	test "$(git diff-files --name-status dir1)" = ""
+
+'
+
 test_expect_success 'replace a file with a symlink' '
 
 	rm foo &&
-- 
1.5.4.2
Next: Junio C Hamano
Message 1 of 3 in “Test case for a problem with git add -u from subdirectory”
  1. Test case for a problem with git add -u from subdirectoryPekka Kaitaniemi, Feb 20, 2008
  2. Junio C HamanoFeb 20, 2008
  3. Pekka KaitaniemiFeb 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.