Skip to content

Commit e55682e

Browse files
derrickstoleegitster
authored andcommitted
sparse-checkout: use C-style quotes in 'list' subcommand
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bd64de4 commit e55682e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

builtin/sparse-checkout.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ static int sparse_checkout_list(int argc, const char **argv)
7878

7979
string_list_sort(&sl);
8080

81-
for (i = 0; i < sl.nr; i++)
82-
printf("%s\n", sl.items[i].string);
81+
for (i = 0; i < sl.nr; i++) {
82+
quote_c_style(sl.items[i].string, NULL, stdout, 0);
83+
printf("\n");
84+
}
8385

8486
return 0;
8587
}

t/t1091-sparse-checkout-builtin.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ test_expect_success BSLASHPSPEC 'pattern-checks: escaped "*"' '
406406
EOF
407407
test_cmp expect escaped/.git/info/sparse-checkout &&
408408
check_read_tree_errors escaped "a zbad\\dir zdoes*exist" &&
409-
git -C escaped ls-tree -d --name-only HEAD | git -C escaped sparse-checkout set --stdin &&
409+
git -C escaped ls-tree -d --name-only HEAD >list-expect &&
410+
git -C escaped sparse-checkout set --stdin <list-expect &&
410411
cat >expect <<-\EOF &&
411412
/*
412413
!/*/
@@ -417,7 +418,9 @@ test_expect_success BSLASHPSPEC 'pattern-checks: escaped "*"' '
417418
/zdoes\*exist/
418419
EOF
419420
test_cmp expect escaped/.git/info/sparse-checkout &&
420-
check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist"
421+
check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" &&
422+
git -C escaped sparse-checkout list >list-actual &&
423+
test_cmp list-expect list-actual
421424
'
422425

423426
test_done

0 commit comments

Comments
 (0)