author | Junio C Hamano <gitster@pobox.com> | |
Thu, 21 Jan 2010 04:28:50 +0000 (20:28 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 21 Jan 2010 04:28:50 +0000 (20:28 -0800) |
* ag/maint-apply-too-large-p:
builtin-apply.c: Skip filenames without enough components
builtin-apply.c: Skip filenames without enough components
builtin-apply.c | patch | blob | history | |
t/t4120-apply-popt.sh | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index 541493e1ba81462f4b01bb99c2840938bae02e4f..b99db0b80027685190eb14bf036b8eec8e4f76b2 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
{
int i = 0, j = 0;
+ if (!name)
+ return NULL;
+
while (name[i]) {
if ((name[j++] = name[i++]) == '/')
while (name[i] == '/')
static char *find_name(const char *line, char *def, int p_value, int terminate)
{
int len;
- const char *start = line;
+ const char *start = NULL;
+
+ if (p_value == 0)
+ start = line;
if (*line == '"') {
struct strbuf name = STRBUF_INIT;
@@ -1199,7 +1205,8 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
continue;
if (!patch->old_name && !patch->new_name) {
if (!patch->def_name)
- die("git diff header lacks filename information (line %d)", linenr);
+ die("git diff header lacks filename information when removing "
+ "%d leading pathname components (line %d)" , p_value, linenr);
patch->old_name = patch->new_name = patch->def_name;
}
patch->is_toplevel_relative = 1;
diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh
index 83d4ba679850c2ae2548bcfcce3f22227fcde8c7..b463b4f05ce43ee345a0594528d684befe7c2ef3 100755 (executable)
--- a/t/t4120-apply-popt.sh
+++ b/t/t4120-apply-popt.sh
git apply -p2 patch.file
'
+test_expect_success 'apply with too large -p' '
+ test_must_fail git apply --stat -p3 patch.file 2>err &&
+ grep "removing 3 leading" err
+'
+
test_done