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 <salikh@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Salikh Zakirov committed
Aug 16, 2007 at 02:01 UTC
2ed2c222dfe372385dc562fb5dc246d5595c1eae
2 files changed
+18
-4
builtin-add.c
+4
-4
@@ -123,12 +123,12 @@ static void update_callback(struct diff_queue_struct *q,
123
}
124
}
125
126
-static void update(int verbose, const char **files)
126
+static void update(int verbose, const char *prefix, const char **files)
127
{
128
struct rev_info rev;
129
- init_revisions(&rev, "");
129
+ init_revisions(&rev, prefix);
130
setup_revisions(0, NULL, &rev, NULL);
131
- rev.prune_data = get_pathspec(rev.prefix, files);
131
+ rev.prune_data = get_pathspec(prefix, files);
132
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
133
rev.diffopt.format_callback = update_callback;
134
rev.diffopt.format_callback_data = &verbose;
@@ -209,7 +209,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
209
}
210
211
if (take_worktree_changes) {
212
- update(verbose, argv + i);
212
+ update(verbose, prefix, argv + i);
213
goto finish;
214
}
215
t/t2200-add-update.sh
+14
@@ -62,4 +62,18 @@ test_expect_success 'cache tree has not been corrupted' '
62
63
'
64
65
+test_expect_success 'update from a subdirectory' '
66
+ (
67
+ cd dir1 &&
68
+ echo more >sub2 &&
69
+ git add -u sub2
70
+ )
71
+'
72
+
73
+test_expect_success 'change gets noticed' '
74
+
75
+ test "$(git diff-files --name-status dir1)" = ""
76
+
77
+'
78
+
79
test_done