]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse-checkout: use C-style quotes in 'list' subcommand
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 31 Jan 2020 20:16:12 +0000 (20:16 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 31 Jan 2020 21:05:29 +0000 (13:05 -0800)
When in cone mode, the 'git sparse-checkout list' subcommand lists
the directories included in the sparse cone. When these directories
contain odd characters, such as a backslash, then we need to use
C-style quotes similar to 'git ls-tree'.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/sparse-checkout.c
t/t1091-sparse-checkout-builtin.sh

index 6083aa10f27cac3221255dda6931c9dd89c296a6..facdb6bda707de92808a5a1c961eaed3eb125cbf 100644 (file)
@@ -78,8 +78,10 @@ static int sparse_checkout_list(int argc, const char **argv)
 
                string_list_sort(&sl);
 
-               for (i = 0; i < sl.nr; i++)
-                       printf("%s\n", sl.items[i].string);
+               for (i = 0; i < sl.nr; i++) {
+                       quote_c_style(sl.items[i].string, NULL, stdout, 0);
+                       printf("\n");
+               }
 
                return 0;
        }
index a46a310740a7f26006a37ecba4703a0c42abc493..545e8d5ebe1de98ef56dcb07accb87797464ee11 100755 (executable)
@@ -406,7 +406,8 @@ test_expect_success BSLASHPSPEC 'pattern-checks: escaped "*"' '
        EOF
        test_cmp expect escaped/.git/info/sparse-checkout &&
        check_read_tree_errors escaped "a zbad\\dir zdoes*exist" &&
-       git -C escaped ls-tree -d --name-only HEAD | git -C escaped sparse-checkout set --stdin &&
+       git -C escaped ls-tree -d --name-only HEAD >list-expect &&
+       git -C escaped sparse-checkout set --stdin <list-expect &&
        cat >expect <<-\EOF &&
        /*
        !/*/
@@ -417,7 +418,9 @@ test_expect_success BSLASHPSPEC 'pattern-checks: escaped "*"' '
        /zdoes\*exist/
        EOF
        test_cmp expect escaped/.git/info/sparse-checkout &&
-       check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist"
+       check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" &&
+       git -C escaped sparse-checkout list >list-actual &&
+       test_cmp list-expect list-actual
 '
 
 test_done