From: Salikh Zakirov Date: Wed, 15 Aug 2007 17:01:43 +0000 (+0900) Subject: git-add -u paths... now works from subdirectory X-Git-Tag: v1.5.2.5~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2ed2c222dfe372385dc562fb5dc246d5595c1eae;p=git.git git-add -u paths... now works from subdirectory git-add -u also takes the path limiters, but unlike the command without the -u option, the code forgot that it could be invoked from a subdirectory, and did not correctly handle the prefix. Signed-off-by: Salikh Zakirov Signed-off-by: Junio C Hamano --- diff --git a/builtin-add.c b/builtin-add.c index a5fae7ca1..07e3ddfd0 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -123,12 +123,12 @@ static void update_callback(struct diff_queue_struct *q, } } -static void update(int verbose, const char **files) +static void update(int verbose, const char *prefix, const char **files) { struct rev_info rev; - init_revisions(&rev, ""); + init_revisions(&rev, prefix); setup_revisions(0, NULL, &rev, NULL); - rev.prune_data = get_pathspec(rev.prefix, files); + rev.prune_data = get_pathspec(prefix, files); rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = update_callback; rev.diffopt.format_callback_data = &verbose; @@ -209,7 +209,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) } if (take_worktree_changes) { - update(verbose, argv + i); + update(verbose, prefix, argv + i); goto finish; } diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 4c7c6af43..58cd7f31b 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -62,4 +62,18 @@ test_expect_success 'cache tree has not been corrupted' ' ' +test_expect_success 'update from a subdirectory' ' + ( + cd dir1 && + echo more >sub2 && + git add -u sub2 + ) +' + +test_expect_success 'change gets noticed' ' + + test "$(git diff-files --name-status dir1)" = "" + +' + test_done