From: Junio C Hamano Date: Thu, 27 Feb 2014 22:01:15 +0000 (-0800) Subject: Merge branch 'nd/submodule-pathspec-ending-with-slash' X-Git-Tag: v2.0.0-rc0~163 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cbaeafc3251d08b479c5eb735444bb6ad6210c93;p=thirdparty%2Fgit.git Merge branch 'nd/submodule-pathspec-ending-with-slash' Allow "git cmd path/", when the 'path' is where a submodule is bound to the top-level working tree, to match 'path', despite the extra and unnecessary trailing slash. * nd/submodule-pathspec-ending-with-slash: clean: use cache_name_is_other() clean: replace match_pathspec() with dir_path_match() pathspec: pass directory indicator to match_pathspec_item() match_pathspec: match pathspec "foo/" against directory "foo" dir.c: prepare match_pathspec_item for taking more flags pathspec: rename match_pathspec_depth() to match_pathspec() pathspec: convert some match_pathspec_depth() to dir_path_match() pathspec: convert some match_pathspec_depth() to ce_path_match() --- cbaeafc3251d08b479c5eb735444bb6ad6210c93 diff --cc builtin/rm.c index 171f37c1cc,05642184c5..960634dd0c --- a/builtin/rm.c +++ b/builtin/rm.c @@@ -308,10 -308,10 +308,10 @@@ int cmd_rm(int argc, const char **argv for (i = 0; i < active_nr; i++) { const struct cache_entry *ce = active_cache[i]; - if (!match_pathspec_depth(&pathspec, ce->name, ce_namelen(ce), 0, seen)) + if (!ce_path_match(ce, &pathspec, seen)) continue; ALLOC_GROW(list.entry, list.nr + 1, list.alloc); - list.entry[list.nr].name = ce->name; + list.entry[list.nr].name = xstrdup(ce->name); list.entry[list.nr].is_submodule = S_ISGITLINK(ce->ce_mode); if (list.entry[list.nr++].is_submodule && !is_staging_gitmodules_ok()) diff --cc builtin/update-index.c index 00313f373a,aaa6f78f16..d12ad95f3e --- a/builtin/update-index.c +++ b/builtin/update-index.c @@@ -559,9 -564,8 +560,9 @@@ static int do_reupdate(int ac, const ch const struct cache_entry *ce = active_cache[pos]; struct cache_entry *old = NULL; int save_nr; + char *path; - if (ce_stage(ce) || !ce_path_match(ce, &pathspec)) + if (ce_stage(ce) || !ce_path_match(ce, &pathspec, NULL)) continue; if (has_head) old = read_one_ent(NULL, head_sha1, diff --cc t/t4010-diff-pathspec.sh index 9f5659f7fe,d30ff34be7..2bb973655b --- a/t/t4010-diff-pathspec.sh +++ b/t/t4010-diff-pathspec.sh @@@ -127,17 -127,10 +127,23 @@@ test_expect_success 'diff-tree ignores test_cmp expect actual ' +test_expect_success 'diff multiple wildcard pathspecs' ' + mkdir path2 && + echo rezrov >path2/file1 && + git update-index --add path2/file1 && + tree3=`git write-tree` && + git diff --name-only $tree $tree3 -- "path2*1" "path1*1" >actual && + cat <<-\EOF >expect && + path1/file1 + path2/file1 + EOF + test_cmp expect actual +' + + test_expect_success 'diff-cache ignores trailing slash on submodule path' ' + git diff --name-only HEAD^ submod >expect && + git diff --name-only HEAD^ submod/ >actual && + test_cmp expect actual + ' + test_done