summaryrefslogtreecommitdiff
path: root/builtin/for-each-ref.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2015-01-12 20:57:37 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-01-13 10:03:30 -0800
commitd64ea0f83bd7e676778f833c57f969a94518a28d (patch)
treea823ee7016046bdd3f6d2d9454b6a07260f28182 /builtin/for-each-ref.c
parentclean up name allocation in prepare_revision_walk (diff)
downloadtgif-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/for-each-ref.c')
0 files changed, 0 insertions, 0 deletions