{"thread":{"id":"12214","subject":"[PATCH] Test case for a problem with git add -u from subdirectory","startedAt":"2008-02-20T14:32:15Z","lastAt":"2008-02-20T19:31:26Z","messageCount":3,"participants":["Pekka Kaitaniemi","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"69372","messageId":"20080220143215.GA23053@localdomain","threadId":"12214","inReplyTo":null,"subject":"[PATCH] Test case for a problem with git add -u from subdirectory","fromName":"Pekka Kaitaniemi","fromEmail":"kaitanie@cc.helsinki.fi","sentAt":"2008-02-20T14:32:15Z","receivedAt":"2008-02-20T14:32:15Z","isPatch":true,"sender":{"key":"kaitanie@cc.helsinki.fi","avatar":null},"body":"Manual page for \"git-add -u\" says:\nUpdate only files that git already knows about. This is similar to\nwhat \"git commit -a\" does in preparation for making a commit, except\nthat the update is limited to paths specified on the command line. If\nno paths are specified, all tracked files are updated.\n\nThe key sentence being: \"If no paths are specified, all tracked files\nare updated.\" If one modifies a file in subdir1, then goes to subdir2\nand performs \"git add -u\" the modified file in subdir1 is not added to\nthe index. This test case demonstrates the problem.\n\nSigned-off-by: Pekka Kaitaniemi <kaitanie@cc.helsinki.fi>\n---\n\nI found a possible problem in \"git add -u\" command without any\npaths. Modified files located in a different subdirectory are not\nadded to the index even though the documentation says that in this\ncase all tracked files should be. Maybe this is caused by a bug in\n\"git add\"? Or is the problem in the documentation?\n\nIn any case, this patch contains a test case that demonstrates the\nproblem.\n\n t/t2200-add-update.sh |   16 ++++++++++++++++\n 1 files changed, 16 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh\nindex 24f892f..5815ec5 100755\n--- a/t/t2200-add-update.sh\n+++ b/t/t2200-add-update.sh\n@@ -80,6 +80,22 @@ test_expect_success 'change gets noticed' '\n \n '\n \n+test_expect_success 'update from a different subdirectory' '\n+\t(\n+\t\tcd dir1 &&\n+\t\techo addmore >sub2 &&\n+                cd ../dir2 &&\n+                git add -u\n+\t)\n+\n+'\n+\n+test_expect_success 'change gets noticed' '\n+\n+\ttest \"$(git diff-files --name-status dir1)\" = \"\"\n+\n+'\n+\n test_expect_success 'replace a file with a symlink' '\n \n \trm foo &&\n-- \n1.5.4.2\n"},{"id":"69391","messageId":"7vhcg35v9r.fsf@gitster.siamese.dyndns.org","threadId":"12214","inReplyTo":"20080220143215.GA23053@localdomain","subject":"Re: [PATCH] Test case for a problem with git add -u from subdirectory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-20T18:37:36Z","receivedAt":"2008-02-20T18:37:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pekka Kaitaniemi <kaitanie@cc.helsinki.fi> writes:\n\n> The key sentence being: \"If no paths are specified, all tracked files\n> are updated.\"\n\nMy recollection is that the current behaviour was requested\nspecifically by the users.  Although I do not remember offhand,\nthe first implementation might have even been doing the whole\ntree unconditionally, and surprised users by stepping outside of\nthe current subdirectory.\n\nSometimes I am annoyed that it does not do the whole tree\n(i.e. you have to go to the top), but some other times (which\nhappens to be majority for me but it would depend on the\nproject) I find the current behaviour a lot more convenient, and\npersonally I do not think it is a good idea to change the\ncurrent behaviour.\n\nPlease send in documentation clarifications.\n"},{"id":"69395","messageId":"20080220193126.GA26686@localdomain","threadId":"12214","inReplyTo":"7vhcg35v9r.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Test case for a problem with git add -u from subdirectory","fromName":"Pekka Kaitaniemi","fromEmail":"kaitanie@cc.helsinki.fi","sentAt":"2008-02-20T19:31:26Z","receivedAt":"2008-02-20T19:31:26Z","isPatch":true,"sender":{"key":"kaitanie@cc.helsinki.fi","avatar":null},"body":"On Wed, Feb 20, 2008 at 10:37:36AM -0800, Junio C Hamano wrote:\n> Pekka Kaitaniemi <kaitanie@cc.helsinki.fi> writes:\n> \n> > The key sentence being: \"If no paths are specified, all tracked files\n> > are updated.\"\n> \n> My recollection is that the current behaviour was requested\n> specifically by the users.  Although I do not remember offhand,\n> the first implementation might have even been doing the whole\n> tree unconditionally, and surprised users by stepping outside of\n> the current subdirectory.\n\nI was a bit confused whether it was a feature or a bug and since the\ndocumentation seemed to indicate that \"git add -u\" should add\neverything I suspected that it was a bug. Anyways, thanks for the\nclarification.\n\n> Sometimes I am annoyed that it does not do the whole tree\n> (i.e. you have to go to the top), but some other times (which\n> happens to be majority for me but it would depend on the\n> project) I find the current behaviour a lot more convenient, and\n> personally I do not think it is a good idea to change the\n> current behaviour.\n\nI agree. Changing the behaviour is not good since it was requested by\nusers and implemented intentionally.\n\nIf adding all tracked files in the whole tree to the index is needed,\nthen maybe it would be useful to add a new flag to git-add? Something\nlike -a (as in all), or -U (really update the whole tree) might be\nuseful option. But then again, the difference between them should also\nbe documented clearly.\n\n> Please send in documentation clarifications.\n\nOK, I'll prepare a patch.\n\nPekka\n"}]}