Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2016-08-09 00:03:12 +0300
committerJunio C Hamano <gitster@pobox.com>2016-08-11 22:41:47 +0300
commit9724e6ff48506323ab897e2d9f8d27febd4d9bb0 (patch)
treebb5f9a7ba23b6599a499d7f2ea6127e2ecdf4fde /builtin/apply.c
parentfef7ba5353095e87b3bcd712fa15eb71e1f53b30 (diff)
builtin/apply: make parse_traditional_patch() return -1 on error
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in "builtin/apply.c", parse_traditional_patch() should return -1 instead of calling die(). Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/apply.c')
-rw-r--r--builtin/apply.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 5530ba13ec..f99498b5cb 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -755,10 +755,10 @@ static int has_epoch_timestamp(const char *nameline)
* files, we can happily check the index for a match, but for creating a
* new file we should try to match whatever "patch" does. I have no idea.
*/
-static void parse_traditional_patch(struct apply_state *state,
- const char *first,
- const char *second,
- struct patch *patch)
+static int parse_traditional_patch(struct apply_state *state,
+ const char *first,
+ const char *second,
+ struct patch *patch)
{
char *name;
@@ -803,7 +803,9 @@ static void parse_traditional_patch(struct apply_state *state,
}
}
if (!name)
- die(_("unable to find filename in patch at line %d"), state->linenr);
+ return error(_("unable to find filename in patch at line %d"), state->linenr);
+
+ return 0;
}
static int gitdiff_hdrend(struct apply_state *state,
@@ -1467,7 +1469,8 @@ static int find_header(struct apply_state *state,
continue;
/* Ok, we'll consider it a patch */
- parse_traditional_patch(state, line, line+len, patch);
+ if (parse_traditional_patch(state, line, line+len, patch))
+ return -128;
*hdrsize = len + nextlen;
state->linenr += 2;
return offset;