]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branch 'dr/maint-ls-tree-prefix-recursion-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 15 Sep 2010 19:41:13 +0000 (12:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Sep 2010 19:41:13 +0000 (12:41 -0700)
* dr/maint-ls-tree-prefix-recursion-fix:
  ls-tree $di $dir: do not mistakenly recurse into directories

builtin/ls-tree.c
t/t3100-ls-tree-restrict.sh

index dc86b0d9a997f98ad43ca2897055a92b8a3eb7d0..a8187568bf99872e717c389b031331838544fe04 100644 (file)
@@ -52,6 +52,8 @@ static int show_recursive(const char *base, int baselen, const char *pathname)
                speclen = strlen(spec);
                if (speclen <= len)
                        continue;
+               if (spec[len] && spec[len] != '/')
+                       continue;
                if (memcmp(pathname, spec, len))
                        continue;
                return 1;
index eee0d344d24623ad9928366729c8efaea699fcd7..81d90b66c50e75323a44aaf5e2e067d5a3569e6a 100755 (executable)
@@ -165,4 +165,13 @@ test_expect_success \
 EOF
      test_output'
 
+test_expect_success \
+    'ls-tree with one path a prefix of the other' \
+    'git ls-tree $tree path2/baz path2/bazbo >current &&
+     make_expected <<\EOF &&
+040000 tree X  path2/baz
+120000 blob X  path2/bazbo
+EOF
+     test_output'
+
 test_done