mirror of
https://github.com/git/git
synced 2024-10-30 14:03:28 +00:00
sparse-checkout: work with Windows paths
When using Windows, a user may run 'git sparse-checkout set A\B\C' to add the Unix-style path A/B/C to their sparse-checkout patterns. Normalizing the input path converts the backslashes to slashes before we add the string 'A/B/C' to the recursive hashset. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2631dc879d
commit
ef07659926
2 changed files with 17 additions and 0 deletions
|
@ -394,6 +394,9 @@ static void strbuf_to_cone_pattern(struct strbuf *line, struct pattern_list *pl)
|
||||||
|
|
||||||
strbuf_trim_trailing_dir_sep(line);
|
strbuf_trim_trailing_dir_sep(line);
|
||||||
|
|
||||||
|
if (strbuf_normalize_path(line))
|
||||||
|
die(_("could not normalize path %s"), line->buf);
|
||||||
|
|
||||||
if (!line->len)
|
if (!line->len)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -497,4 +497,18 @@ test_expect_success BSLASHPSPEC 'pattern-checks: escaped characters' '
|
||||||
test_cmp list-expect list-actual
|
test_cmp list-expect list-actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success MINGW 'cone mode replaces backslashes with slashes' '
|
||||||
|
git -C repo sparse-checkout set deep\\deeper1 &&
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
/*
|
||||||
|
!/*/
|
||||||
|
/deep/
|
||||||
|
!/deep/*/
|
||||||
|
/deep/deeper1/
|
||||||
|
EOF
|
||||||
|
test_cmp expect repo/.git/info/sparse-checkout &&
|
||||||
|
check_files repo a deep &&
|
||||||
|
check_files repo/deep a deeper1
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue