diff options
author | Jeff King <peff@peff.net> | 2015-01-12 20:57:37 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-01-13 10:03:30 -0800 |
commit | d64ea0f83bd7e676778f833c57f969a94518a28d (patch) | |
tree | a823ee7016046bdd3f6d2d9454b6a07260f28182 /builtin/clone.c | |
parent | clean up name allocation in prepare_revision_walk (diff) | |
download | tgif-d64ea0f83bd7e676778f833c57f969a94518a28d.tar.xz |
git-compat-util: add xstrdup_or_null helper
It's a common idiom to duplicate a string if it is non-NULL,
or pass a literal NULL through. This is already a one-liner
in C, but you do have to repeat the name of the string
twice. So if there's a function call, you must write:
const char *x = some_fun(...);
return x ? xstrdup(x) : NULL;
instead of (with this patch) just:
return xstrdup_or_null(some_fun(...));
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/clone.c')
0 files changed, 0 insertions, 0 deletions