Skip to content

Commit

Permalink
update-index --again: take optional pathspecs
Browse files Browse the repository at this point in the history
When pathspecs are given, update-index --again further limits
the set of paths to be updated to those that match them.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed May 6, 2006
1 parent 83e77a2 commit 22293b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion t/t2101-update-index-reupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,14 @@ test_expect_success 'update-index --update from subdir' \
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF'

test_done
test_expect_success 'update-index --update with pathspec' \
'echo very happy >file2 &&
cat file2 >dir1/file3 &&
git-update-index --again dir1/ &&
git-ls-files -s >current &&
cmp current - <<\EOF
100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3
100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
EOF'

test_done
4 changes: 3 additions & 1 deletion update-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ static int do_reupdate(int ac, const char **av,
*/
int pos;
int has_head = 1;
char **pathspec = get_pathspec(prefix, av + 1);

if (read_ref(git_path("HEAD"), head_sha1))
/* If there is no HEAD, that means it is an initial
Expand All @@ -621,7 +622,8 @@ static int do_reupdate(int ac, const char **av,
struct cache_entry *ce = active_cache[pos];
struct cache_entry *old = NULL;
int save_nr;
if (ce_stage(ce))

if (ce_stage(ce) || !ce_path_match(ce, pathspec))
continue;
if (has_head)
old = read_one_ent(NULL, head_sha1,
Expand Down

0 comments on commit 22293b9

Please sign in to comment.