From a4882c27f8b3793d94b03fd503a0c67ad9772cf6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 15 Aug 2007 14:12:14 -0700 Subject: Fix "git add -u" data corruption. This applies to 'maint' to fix a rather serious data corruption issue. When "git add -u" affects a subdirectory in such a way that the only changes to its contents are path removals, the next tree object written out of that index was bogus, as the remove codepath forgot to invalidate the cache-tree entry. Reported by Salikh Zakirov. Signed-off-by: Junio C Hamano --- builtin-add.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin-add.c') diff --git a/builtin-add.c b/builtin-add.c index 159117106a..a5fae7ca17 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -115,6 +115,7 @@ static void update_callback(struct diff_queue_struct *q, break; case DIFF_STATUS_DELETED: remove_file_from_cache(path); + cache_tree_invalidate_path(active_cache_tree, path); if (verbose) printf("remove '%s'\n", path); break; -- cgit v1.2.3 From 2ed2c222dfe372385dc562fb5dc246d5595c1eae Mon Sep 17 00:00:00 2001 From: Salikh Zakirov Date: Thu, 16 Aug 2007 02:01:43 +0900 Subject: 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 --- builtin-add.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'builtin-add.c') diff --git a/builtin-add.c b/builtin-add.c index a5fae7ca17..07e3ddfd0a 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; } -- cgit v1.2.3