Skip to content

Commit

Permalink
git-add -u paths... now works from subdirectory
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Salikh Zakirov authored and Junio C Hamano committed Aug 15, 2007
1 parent a4882c2 commit 2ed2c22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builtin-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
14 changes: 14 additions & 0 deletions t/t2200-add-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2ed2c22

Please sign in to comment.