Code

Merge branch 'jn/maint-fast-import-empty-ls' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 26 Mar 2012 19:10:25 +0000 (12:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Mar 2012 19:10:25 +0000 (12:10 -0700)
* jn/maint-fast-import-empty-ls:
  fast-import: don't allow 'ls' of path with empty components
  fast-import: leakfix for 'ls' of dirty trees

fast-import.c
t/t9300-fast-import.sh

index c1486cabbaa5f736f92994587fafd1f3afdf43af..a85275dc682d2bb8068f003b8281c3933488f010 100644 (file)
@@ -1641,6 +1641,8 @@ static int tree_content_get(
                n = slash1 - p;
        else
                n = strlen(p);
+       if (!n)
+               die("Empty path component found in input");
 
        if (!root->tree)
                load_tree(root);
@@ -3028,6 +3030,8 @@ static void parse_ls(struct branch *b)
                store_tree(&leaf);
 
        print_ls(leaf.versions[1].mode, leaf.versions[1].sha1, p);
+       if (leaf.tree)
+               release_tree_content_recursive(leaf.tree);
        if (!b || root != &b->branch_tree)
                release_tree_entry(root);
 }
index 438aaf6b14b8ae0cb35739d6006eaf646876107c..0f5b5e5964a60f31cdfd6bc456848c2f4b820d0a 100755 (executable)
@@ -1306,6 +1306,45 @@ test_expect_success \
        M 040000 $subdir file3/
        INPUT_END'
 
+test_expect_success \
+       'N: reject foo/ syntax in copy source' \
+       'test_must_fail git fast-import <<-INPUT_END
+       commit refs/heads/N5C
+       committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+       data <<COMMIT
+       copy with invalid syntax
+       COMMIT
+
+       from refs/heads/branch^0
+       C file2/ file3
+       INPUT_END'
+
+test_expect_success \
+       'N: reject foo/ syntax in rename source' \
+       'test_must_fail git fast-import <<-INPUT_END
+       commit refs/heads/N5D
+       committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+       data <<COMMIT
+       rename with invalid syntax
+       COMMIT
+
+       from refs/heads/branch^0
+       R file2/ file3
+       INPUT_END'
+
+test_expect_success \
+       'N: reject foo/ syntax in ls argument' \
+       'test_must_fail git fast-import <<-INPUT_END
+       commit refs/heads/N5E
+       committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+       data <<COMMIT
+       copy with invalid syntax
+       COMMIT
+
+       from refs/heads/branch^0
+       ls "file2/"
+       INPUT_END'
+
 test_expect_success \
        'N: copy to root by id and modify' \
        'echo "hello, world" >expect.foo &&