diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-02-26 17:06:23 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-02-26 17:06:23 -0800 |
commit | 660e20f5c72ba363c08f0d3fca60c9680f296c40 (patch) | |
tree | b1f64c45ac088b1930e3127c86e6246f04a03805 | |
parent | 8f2c0995b611ef2f53fc29dc5ea3721a803ec1c2 (diff) | |
parent | 3d1f148c3381de410a9b02a05bde05cd0fb17a0c (diff) | |
download | git-660e20f5c72ba363c08f0d3fca60c9680f296c40.tar.gz git-660e20f5c72ba363c08f0d3fca60c9680f296c40.tar.xz |
Merge branch 'jc/add-refresh-unmerged' into maint
* jc/add-refresh-unmerged:
refresh_index: do not show unmerged path that is outside pathspec
-rw-r--r-- | read-cache.c | 11 | ||||
-rwxr-xr-x | t/t3700-add.sh | 15 |
2 files changed, 24 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); diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 575d9508a..874b3a644 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -179,6 +179,21 @@ test_expect_success 'git add --refresh' ' test -z "`git diff-index HEAD -- foo`" ' +test_expect_success 'git add --refresh with pathspec' ' + git reset --hard && + echo >foo && echo >bar && echo >baz && + git add foo bar baz && H=$(git rev-parse :foo) && git rm -f foo && + echo "100644 $H 3 foo" | git update-index --index-info && + test-chmtime -60 bar baz && + >expect && + git add --refresh bar >actual && + test_cmp expect actual && + + git diff-files --name-only >actual && + ! grep bar actual&& + grep baz actual +' + test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' ' git reset --hard && date >foo1 && |