Commit 5eade074 authored by Jeff King's avatar Jeff King Committed by Junio C Hamano

xdiff-interface: drop parse_hunk_header()

This function was used only for parsing the hunk headers generated by
xdiff. Now that we can use hunk callbacks to get that information
directly, it has outlived its usefulness.

Note to anyone who wants to resurrect it: the "len" parameter was
totally unused, meaning that the function could read past the end of the
"line" array. In practice this never happened, because we only used it
to parse xdiff's generated header lines. But it would be dangerous to
use it for other cases without fixing this defect.
Signed-off-by: 's avatarJeff King <>
Signed-off-by: 's avatarJunio C Hamano <>
parent d2eb8093
......@@ -15,51 +15,6 @@ struct xdiff_emit_state {
struct strbuf remainder;
static int parse_num(char **cp_p, int *num_p)
char *cp = *cp_p;
int num = 0;
while ('0' <= *cp && *cp <= '9')
num = num * 10 + *cp++ - '0';
if (!(cp - *cp_p))
return -1;
*cp_p = cp;
*num_p = num;
return 0;
int parse_hunk_header(char *line, int len,
int *ob, int *on,
int *nb, int *nn)
char *cp;
cp = line + 4;
if (parse_num(&cp, ob)) {
return error("malformed diff output: %s", line);
if (*cp == ',') {
if (parse_num(&cp, on))
goto bad_line;
*on = 1;
if (*cp++ != ' ' || *cp++ != '+')
goto bad_line;
if (parse_num(&cp, nb))
goto bad_line;
if (*cp == ',') {
if (parse_num(&cp, nn))
goto bad_line;
*nn = 1;
return -!!memcmp(cp, " @@", 3);
static int xdiff_out_hunk(void *priv_,
long old_begin, long old_nr,
long new_begin, long new_nr,
......@@ -23,9 +23,6 @@ int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
xdiff_emit_line_fn line_fn,
void *consume_callback_data,
xpparam_t const *xpp, xdemitconf_t const *xecfg);
int parse_hunk_header(char *line, int len,
int *ob, int *on,
int *nb, int *nn);
int read_mmfile(mmfile_t *ptr, const char *filename);
void read_mmblob(mmfile_t *ptr, const struct object_id *oid);
int buffer_is_binary(const char *ptr, unsigned long size);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment