mirror of
https://github.com/git/git.git
synced 2024-05-12 03:36:10 +02:00
Merge branch 'jc/apply-parse-diff-git-header-names-fix' into next
"git apply" failed to extract the filename the patch applied to, when the change was about an empty file created in or deleted from a directory whose name ends with a SP, which has been corrected. * jc/apply-parse-diff-git-header-names-fix: apply: parse names out of "diff --git" more carefully
This commit is contained in:
commit
d586367985
9
apply.c
9
apply.c
|
@ -1292,8 +1292,15 @@ static char *git_header_name(int p_value,
|
||||||
return NULL; /* no postimage name */
|
return NULL; /* no postimage name */
|
||||||
second = skip_tree_prefix(p_value, name + len + 1,
|
second = skip_tree_prefix(p_value, name + len + 1,
|
||||||
line_len - (len + 1));
|
line_len - (len + 1));
|
||||||
|
/*
|
||||||
|
* If we are at the SP at the end of a directory,
|
||||||
|
* skip_tree_prefix() may return NULL as that makes
|
||||||
|
* it appears as if we have an absolute path.
|
||||||
|
* Keep going to find another SP.
|
||||||
|
*/
|
||||||
if (!second)
|
if (!second)
|
||||||
return NULL;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Does len bytes starting at "name" and "second"
|
* Does len bytes starting at "name" and "second"
|
||||||
* (that are separated by one HT or SP we just
|
* (that are separated by one HT or SP we just
|
||||||
|
|
|
@ -66,4 +66,26 @@ test_expect_success 'apply --index create' '
|
||||||
git diff --exit-code
|
git diff --exit-code
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'apply with no-contents and a funny pathname' '
|
||||||
|
mkdir "funny " &&
|
||||||
|
>"funny /empty" &&
|
||||||
|
git add "funny /empty" &&
|
||||||
|
git diff HEAD "funny /" >sample.patch &&
|
||||||
|
git diff -R HEAD "funny /" >elpmas.patch &&
|
||||||
|
git reset --hard &&
|
||||||
|
rm -fr "funny " &&
|
||||||
|
|
||||||
|
git apply --stat --check --apply sample.patch &&
|
||||||
|
test_must_be_empty "funny /empty" &&
|
||||||
|
|
||||||
|
git apply --stat --check --apply elpmas.patch &&
|
||||||
|
test_path_is_missing "funny /empty" &&
|
||||||
|
|
||||||
|
git apply -R --stat --check --apply elpmas.patch &&
|
||||||
|
test_must_be_empty "funny /empty" &&
|
||||||
|
|
||||||
|
git apply -R --stat --check --apply sample.patch &&
|
||||||
|
test_path_is_missing "funny /empty"
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in New Issue