提交 1fe32cb9 编写于 作者: J Junio C Hamano

filter-branch: handle filenames that need quoting

The command used a very old fashioned construct to extract
filenames out of diff-index and ended up corrupting the output.
We can simply use --name-only and pipe into --stdin mode of
update-index.  It's been like that for the past 2 years or so
since a94d9948 (update-index: work with c-quoted name).
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 0ef617f4
...@@ -276,10 +276,11 @@ while read commit parents; do ...@@ -276,10 +276,11 @@ while read commit parents; do
eval "$filter_tree" < /dev/null || eval "$filter_tree" < /dev/null ||
die "tree filter failed: $filter_tree" die "tree filter failed: $filter_tree"
git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \ (
xargs -0 git update-index --add --replace --remove git diff-index -r --name-only $commit
git ls-files -z --others | \ git ls-files --others
xargs -0 git update-index --add --replace --remove ) |
git update-index --add --replace --remove --stdin
fi fi
eval "$filter_index" < /dev/null || eval "$filter_index" < /dev/null ||
......
...@@ -165,4 +165,18 @@ test_expect_success '"map" works in commit filter' ' ...@@ -165,4 +165,18 @@ test_expect_success '"map" works in commit filter' '
git rev-parse --verify master git rev-parse --verify master
' '
test_expect_success 'Name needing quotes' '
git checkout -b rerere A &&
mkdir foo &&
name="れれれ" &&
>foo/$name &&
git add foo &&
git commit -m "Adding a file" &&
git filter-branch --tree-filter "rm -fr foo" &&
! git ls-files --error-unmatch "foo/$name" &&
test $(git rev-parse --verify rerere) != $(git rev-parse --verify A)
'
test_done test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册