Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit ad76feb

Browse files
committed
Merge branch 'tr/maint-apply-non-git-patch-parsefix'
Fix for the codepath to parse patches that add new files, generated by programs other than Git. THis is an old breakage in v1.7.11 and will need to be merged down to the maintanance tracks. * tr/maint-apply-non-git-patch-parsefix: apply: carefully strdup a possibly-NULL name
2 parents 12dd2f6 + 212eb96 commit ad76feb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

builtin/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ static void parse_traditional_patch(const char *first, const char *second, struc
906906
patch->old_name = name;
907907
} else {
908908
patch->old_name = name;
909-
patch->new_name = xstrdup(name);
909+
patch->new_name = null_strdup(name);
910910
}
911911
}
912912
if (!name)

t/t4111-apply-subdir.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ test_expect_success 'apply --index from subdir of toplevel' '
8686
test_cmp expected sub/dir/file
8787
'
8888

89+
test_expect_success 'apply half-broken patch from subdir of toplevel' '
90+
(
91+
cd sub/dir &&
92+
test_must_fail git apply <<-EOF
93+
--- sub/dir/file
94+
+++ sub/dir/file
95+
@@ -1,0 +1,0 @@
96+
--- file_in_root
97+
+++ file_in_root
98+
@@ -1,0 +1,0 @@
99+
EOF
100+
)
101+
'
102+
89103
test_expect_success 'apply from .git dir' '
90104
cp postimage expected &&
91105
cp preimage .git/file &&

0 commit comments

Comments
 (0)