Merge branch 'nd/submodule-pathspec-ending-with-slash'
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 22:01:15 +0000 (14:01 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 22:01:15 +0000 (14:01 -0800)
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()

1  2 
builtin/commit.c
builtin/rm.c
builtin/update-index.c
cache.h
read-cache.c
resolve-undo.c
t/t4010-diff-pathspec.sh
Simple merge
diff --cc builtin/rm.c
index 171f37c1cc5371c307ef16ce67fefc1c40fbc2c2,05642184c5d89addae1900660ad99e5f29c324f2..960634dd0c52f1da689e8a54980e5e81cf2d2f36
@@@ -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())
index 00313f373aadd989e0627b0b3068676c66c17a9b,aaa6f78f1629311257291ba1075ddd7c7dd1a3ed..d12ad95f3e210f780d95334d59a58e6b9d3b69ad
@@@ -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 cache.h
Simple merge
diff --cc read-cache.c
Simple merge
diff --cc resolve-undo.c
Simple merge
index 9f5659f7fe4df23d805e6c38264a1ebf38fc2538,d30ff34be7ebaf01ef22ce63cc2d1beeccf6a057..2bb973655bf043cc43292764ffd68becda25aa2e
@@@ -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