diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-02-24 22:09:54 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-02-24 22:09:54 -0800 |
commit | faf723a631aff822b4808c496c0970edb0ca2a99 (patch) | |
tree | 6ac7646bf0e31bc5ee177b358a8cdda5ea7d3fc6 /builtin/apply.c | |
parent | 9874fca7122563e28d699a911404fc49d2a24f1c (diff) | |
parent | a46442f1675722eb68238b329a4a285f03f41dda (diff) | |
download | git-faf723a631aff822b4808c496c0970edb0ca2a99.tar.gz |
Merge branch 'jk/blame-commit-label' into maint
"git blame HEAD -- missing" failed to correctly say "HEAD" when it
tried to say "No such path 'missing' in HEAD".
* jk/blame-commit-label:
blame.c: fix garbled error message
use xstrdup_or_null to replace ternary conditionals
builtin/commit.c: use xstrdup_or_null instead of envdup
builtin/apply.c: use xstrdup_or_null instead of null_strdup
git-compat-util: add xstrdup_or_null helper
Diffstat (limited to 'builtin/apply.c')
-rw-r--r-- | builtin/apply.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/builtin/apply.c b/builtin/apply.c index 0aad912839..dfd7a34117 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -657,11 +657,6 @@ static size_t diff_timestamp_len(const char *line, size_t len) 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, int p_value, const char *end, int terminate) { @@ -684,10 +679,10 @@ static char *find_name_common(const char *line, const char *def, start = line; } if (!start) - return squash_slash(null_strdup(def)); + return squash_slash(xstrdup_or_null(def)); len = line - start; if (!len) - return squash_slash(null_strdup(def)); + return squash_slash(xstrdup_or_null(def)); /* * Generally we prefer the shorter name, especially @@ -909,7 +904,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 = null_strdup(name); + patch->new_name = xstrdup_or_null(name); } } if (!name) @@ -998,7 +993,7 @@ static int gitdiff_delete(const char *line, struct patch *patch) { patch->is_delete = 1; 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); } @@ -1006,7 +1001,7 @@ static int gitdiff_newfile(const char *line, struct patch *patch) { patch->is_new = 1; 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); } |