提交 5bceab41 编写于 作者: J Junio C Hamano

Merge branch 'bw/submodule-with-bs-path'

"git submodule" script does not work well with strange pathnames.
Protect it from a path with slashes in them, at least.

* bw/submodule-with-bs-path:
  submodule: prevent backslash expantion in submodule names
...@@ -332,7 +332,7 @@ cmd_foreach() ...@@ -332,7 +332,7 @@ cmd_foreach()
git submodule--helper list --prefix "$wt_prefix" || git submodule--helper list --prefix "$wt_prefix" ||
echo "#unmatched" $? echo "#unmatched" $?
} | } |
while read mode sha1 stage sm_path while read -r mode sha1 stage sm_path
do do
die_if_unmatched "$mode" "$sha1" die_if_unmatched "$mode" "$sha1"
if test -e "$sm_path"/.git if test -e "$sm_path"/.git
...@@ -441,7 +441,7 @@ cmd_deinit() ...@@ -441,7 +441,7 @@ cmd_deinit()
git submodule--helper list --prefix "$wt_prefix" "$@" || git submodule--helper list --prefix "$wt_prefix" "$@" ||
echo "#unmatched" $? echo "#unmatched" $?
} | } |
while read mode sha1 stage sm_path while read -r mode sha1 stage sm_path
do do
die_if_unmatched "$mode" "$sha1" die_if_unmatched "$mode" "$sha1"
name=$(git submodule--helper name "$sm_path") || exit name=$(git submodule--helper name "$sm_path") || exit
...@@ -605,7 +605,7 @@ cmd_update() ...@@ -605,7 +605,7 @@ cmd_update()
"$@" || echo "#unmatched" $? "$@" || echo "#unmatched" $?
} | { } | {
err= err=
while read mode sha1 stage just_cloned sm_path while read -r mode sha1 stage just_cloned sm_path
do do
die_if_unmatched "$mode" "$sha1" die_if_unmatched "$mode" "$sha1"
...@@ -847,7 +847,7 @@ cmd_summary() { ...@@ -847,7 +847,7 @@ cmd_summary() {
# Get modified modules cared by user # Get modified modules cared by user
modules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- "$@" | modules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- "$@" |
sane_egrep '^:([0-7]* )?160000' | sane_egrep '^:([0-7]* )?160000' |
while read mod_src mod_dst sha1_src sha1_dst status sm_path while read -r mod_src mod_dst sha1_src sha1_dst status sm_path
do do
# Always show modules deleted or type-changed (blob<->module) # Always show modules deleted or type-changed (blob<->module)
if test "$status" = D || test "$status" = T if test "$status" = D || test "$status" = T
...@@ -873,7 +873,7 @@ cmd_summary() { ...@@ -873,7 +873,7 @@ cmd_summary() {
git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- $modules | git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- $modules |
sane_egrep '^:([0-7]* )?160000' | sane_egrep '^:([0-7]* )?160000' |
cut -c2- | cut -c2- |
while read mod_src mod_dst sha1_src sha1_dst status name while read -r mod_src mod_dst sha1_src sha1_dst status name
do do
if test -z "$cached" && if test -z "$cached" &&
test $sha1_dst = 0000000000000000000000000000000000000000 test $sha1_dst = 0000000000000000000000000000000000000000
...@@ -1020,7 +1020,7 @@ cmd_status() ...@@ -1020,7 +1020,7 @@ cmd_status()
git submodule--helper list --prefix "$wt_prefix" "$@" || git submodule--helper list --prefix "$wt_prefix" "$@" ||
echo "#unmatched" $? echo "#unmatched" $?
} | } |
while read mode sha1 stage sm_path while read -r mode sha1 stage sm_path
do do
die_if_unmatched "$mode" "$sha1" die_if_unmatched "$mode" "$sha1"
name=$(git submodule--helper name "$sm_path") || exit name=$(git submodule--helper name "$sm_path") || exit
...@@ -1100,7 +1100,7 @@ cmd_sync() ...@@ -1100,7 +1100,7 @@ cmd_sync()
git submodule--helper list --prefix "$wt_prefix" "$@" || git submodule--helper list --prefix "$wt_prefix" "$@" ||
echo "#unmatched" $? echo "#unmatched" $?
} | } |
while read mode sha1 stage sm_path while read -r mode sha1 stage sm_path
do do
die_if_unmatched "$mode" "$sha1" die_if_unmatched "$mode" "$sha1"
......
...@@ -273,6 +273,20 @@ test_expect_success 'submodule add with ./, /.. and // in path' ' ...@@ -273,6 +273,20 @@ test_expect_success 'submodule add with ./, /.. and // in path' '
test_cmp empty untracked test_cmp empty untracked
' '
test_expect_success 'submodule add with \\ in path' '
test_when_finished "rm -rf parent sub\\with\\backslash" &&
# Initialize a repo with a backslash in its name
git init sub\\with\\backslash &&
touch sub\\with\\backslash/empty.file &&
git -C sub\\with\\backslash add empty.file &&
git -C sub\\with\\backslash commit -m "Added empty.file" &&
# Add that repository as a submodule
git init parent &&
git -C parent submodule add ../sub\\with\\backslash
'
test_expect_success 'submodule add in subdirectory' ' test_expect_success 'submodule add in subdirectory' '
echo "refs/heads/master" >expect && echo "refs/heads/master" >expect &&
>empty && >empty &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册