From ac78b009398f8cab1f57d1ef62db21ac95e11ed1 Mon Sep 17 00:00:00 2001 From: Ben Walton Date: Thu, 8 Oct 2009 21:53:35 -0400 Subject: [PATCH] ls-files: die instead of fprintf/exit in -i error When ls-files was called with -i but no exclude pattern, it was calling fprintf(stderr, "...", NULL) and then exiting. On Solaris, passing NULL into fprintf was causing a segfault. On glibc systems, it was simply producing incorrect output (eg: "(null)": ...). The NULL pointer was a result of argv[0] not being preserved by the option parser. Instead of requesting that the option parser preserve argv[0], use die() with a constant string. A trigger for this bug was: `git ls-files -i` Signed-off-by: Ben Walton Signed-off-by: Junio C Hamano --- builtin-ls-files.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/builtin-ls-files.c b/builtin-ls-files.c index f473220502..2c95ca6105 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -524,11 +524,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix) ps_matched = xcalloc(1, num); } - if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given) { - fprintf(stderr, "%s: --ignored needs some exclude pattern\n", - argv[0]); - exit(1); - } + if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given) + die("ls-files --ignored needs some exclude pattern"); /* With no flags, we default to showing the cached files */ if (!(show_stage | show_deleted | show_others | show_unmerged |