aboutsummaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-02-17 10:11:05 -0800
committerJunio C Hamano <gitster@pobox.com>2012-02-17 10:11:05 -0800
commit3d1f148c3381de410a9b02a05bde05cd0fb17a0c (patch)
treec853d1e06f704cdc1343322f1684095f9b073312 /read-cache.c
parentd1ba7a4cb77b64993a56b06c1497d1ab78094cc4 (diff)
downloadgit-3d1f148c3381de410a9b02a05bde05cd0fb17a0c.tar.gz
git-3d1f148c3381de410a9b02a05bde05cd0fb17a0c.tar.xz
refresh_index: do not show unmerged path that is outside pathspec
When running "git add --refresh <pathspec>", we incorrectly showed the path that is unmerged even if it is outside the specified pathspec, even though we did honor pathspec and refreshed only the paths that matched. Note that this cange does not affect "git update-index --refresh"; for hysterical raisins, it does not take a pathspec (it takes real paths) and more importantly itss command line options are parsed and executed one by one as they are encountered, so "git update-index --refresh foo" means "first refresh the index, and then update the entry 'foo' by hashing the contents in file 'foo'", not "refresh only entry 'foo'". Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/read-cache.c b/read-cache.c
index a51bba1b9..274e54b4f 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1120,11 +1120,16 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
struct cache_entry *ce, *new;
int cache_errno = 0;
int changed = 0;
+ int filtered = 0;
ce = istate->cache[i];
if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
continue;
+ if (pathspec &&
+ !match_pathspec(pathspec, ce->name, strlen(ce->name), 0, seen))
+ filtered = 1;
+
if (ce_stage(ce)) {
while ((i < istate->cache_nr) &&
! strcmp(istate->cache[i]->name, ce->name))
@@ -1132,12 +1137,14 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
i--;
if (allow_unmerged)
continue;
- show_file(unmerged_fmt, ce->name, in_porcelain, &first, header_msg);
+ if (!filtered)
+ show_file(unmerged_fmt, ce->name, in_porcelain,
+ &first, header_msg);
has_errors = 1;
continue;
}
- if (pathspec && !match_pathspec(pathspec, ce->name, strlen(ce->name), 0, seen))
+ if (filtered)
continue;
new = refresh_cache_ent(istate, ce, options, &cache_errno, &changed);