提交 90360c71 编写于 作者: J Junio C Hamano

Merge branch 'tr/maint-apply-non-git-patch-parsefix' into maint

"git apply" parsed patches that add new files, generated by programs
other than Git, incorrectly.  This is an old breakage in v1.7.11.

* tr/maint-apply-non-git-patch-parsefix:
  apply: carefully strdup a possibly-NULL name
......@@ -906,7 +906,7 @@ static void parse_traditional_patch(const char *first, const char *second, struc
patch->old_name = name;
} else {
patch->old_name = name;
patch->new_name = xstrdup(name);
patch->new_name = null_strdup(name);
}
}
if (!name)
......
......@@ -86,6 +86,20 @@ test_expect_success 'apply --index from subdir of toplevel' '
test_cmp expected sub/dir/file
'
test_expect_success 'apply half-broken patch from subdir of toplevel' '
(
cd sub/dir &&
test_must_fail git apply <<-EOF
--- sub/dir/file
+++ sub/dir/file
@@ -1,0 +1,0 @@
--- file_in_root
+++ file_in_root
@@ -1,0 +1,0 @@
EOF
)
'
test_expect_success 'apply from .git dir' '
cp postimage expected &&
cp preimage .git/file &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册