Skip to content

Commit

Permalink
Merge branch 'tr/maint-apply-non-git-patch-parsefix'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Jun 26, 2013
2 parents 12dd2f6 + 212eb96 commit ad76feb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions t/t4111-apply-subdir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit ad76feb

Please sign in to comment.