diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2020-01-31 23:16:12 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-02-01 00:05:29 +0300 |
commit | e55682ea2640dd3aa002a2657c32bdd1d85b44e9 (patch) | |
tree | c9fa0d126b1261bf9c78390a1018945819a84862 | |
parent | bd64de42de28e5cdda7765d5de1c3ed34d4898cb (diff) |
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 <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/sparse-checkout.c | 6 | ||||
-rwxr-xr-x | t/t1091-sparse-checkout-builtin.sh | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 6083aa10f2..facdb6bda7 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -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; } diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh index a46a310740..545e8d5ebe 100755 --- a/t/t1091-sparse-checkout-builtin.sh +++ b/t/t1091-sparse-checkout-builtin.sh @@ -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 |