mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
builtin/apply.c: use xstrdup_or_null instead of null_strdup
This file had its own identical helper that predates xstrdup_or_null. Let's use the global one to avoid repetition. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d64ea0f83b
commit
4440690786
1 changed files with 5 additions and 10 deletions
|
@ -656,11 +656,6 @@ static size_t diff_timestamp_len(const char *line, size_t len)
|
||||||
return line + len - end;
|
return line + len - end;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *null_strdup(const char *s)
|
|
||||||
{
|
|
||||||
return s ? xstrdup(s) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *find_name_common(const char *line, const char *def,
|
static char *find_name_common(const char *line, const char *def,
|
||||||
int p_value, const char *end, int terminate)
|
int p_value, const char *end, int terminate)
|
||||||
{
|
{
|
||||||
|
@ -683,10 +678,10 @@ static char *find_name_common(const char *line, const char *def,
|
||||||
start = line;
|
start = line;
|
||||||
}
|
}
|
||||||
if (!start)
|
if (!start)
|
||||||
return squash_slash(null_strdup(def));
|
return squash_slash(xstrdup_or_null(def));
|
||||||
len = line - start;
|
len = line - start;
|
||||||
if (!len)
|
if (!len)
|
||||||
return squash_slash(null_strdup(def));
|
return squash_slash(xstrdup_or_null(def));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generally we prefer the shorter name, especially
|
* Generally we prefer the shorter name, especially
|
||||||
|
@ -908,7 +903,7 @@ static void parse_traditional_patch(const char *first, const char *second, struc
|
||||||
patch->old_name = name;
|
patch->old_name = name;
|
||||||
} else {
|
} else {
|
||||||
patch->old_name = name;
|
patch->old_name = name;
|
||||||
patch->new_name = null_strdup(name);
|
patch->new_name = xstrdup_or_null(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!name)
|
if (!name)
|
||||||
|
@ -997,7 +992,7 @@ static int gitdiff_delete(const char *line, struct patch *patch)
|
||||||
{
|
{
|
||||||
patch->is_delete = 1;
|
patch->is_delete = 1;
|
||||||
free(patch->old_name);
|
free(patch->old_name);
|
||||||
patch->old_name = null_strdup(patch->def_name);
|
patch->old_name = xstrdup_or_null(patch->def_name);
|
||||||
return gitdiff_oldmode(line, patch);
|
return gitdiff_oldmode(line, patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,7 +1000,7 @@ static int gitdiff_newfile(const char *line, struct patch *patch)
|
||||||
{
|
{
|
||||||
patch->is_new = 1;
|
patch->is_new = 1;
|
||||||
free(patch->new_name);
|
free(patch->new_name);
|
||||||
patch->new_name = null_strdup(patch->def_name);
|
patch->new_name = xstrdup_or_null(patch->def_name);
|
||||||
return gitdiff_newmode(line, patch);
|
return gitdiff_newmode(line, patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue