@matheusbsbs / matheus-bagliano / commits / 22293b9c41
Fork 0

update-index --again: take optional pathspecs

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>

Junio C Hamano committed May 5, 2006 at 23:09 UTC 22293b9c41778bb60f3b07355e1b8e421a503702
2 files changed +13 -2
t/t2101-update-index-reupdate.sh
+10 -1
@@ -69,5 +69,14 @@ test_expect_success 'update-index --update from subdir' \
69 100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
70 EOF'
71
72 -test_done
72 +test_expect_success 'update-index --update with pathspec' \
73 + 'echo very happy >file2 &&
74 + cat file2 >dir1/file3 &&
75 + git-update-index --again dir1/ &&
76 + git-ls-files -s >current &&
77 + cmp current - <<\EOF
78 +100644 594fb5bb1759d90998e2bf2a38261ae8e243c760 0 dir1/file3
79 +100644 0f1ae1422c2bf43f117d3dbd715c988a9ed2103f 0 file2
80 +EOF'
81
82 +test_done
update-index.c
+3 -1
@@ -610,6 +610,7 @@ static int do_reupdate(int ac, const char **av,
610 */
611 int pos;
612 int has_head = 1;
613 + char **pathspec = get_pathspec(prefix, av + 1);
614
615 if (read_ref(git_path("HEAD"), head_sha1))
616 /* If there is no HEAD, that means it is an initial
@@ -621,7 +622,8 @@ static int do_reupdate(int ac, const char **av,
622 struct cache_entry *ce = active_cache[pos];
623 struct cache_entry *old = NULL;
624 int save_nr;
624 - if (ce_stage(ce))
625 +
626 + if (ce_stage(ce) || !ce_path_match(ce, pathspec))
627 continue;
628 if (has_head)
629 old = read_one_ent(NULL, head_sha1,