From: Ben Walton <bwalton@artsci.utoronto.ca>
To: bebarino@gmail.com, gitster@pobox.com
Cc: git@vger.kernel.org, Ben Walton <bwalton@artsci.utoronto.ca>
Subject: [PATCH] ls-files: die instead of fprintf/exit in -i error
Date: Thu, 8 Oct 2009 21:53:35 -0400 [thread overview]
Message-ID: <1255053215-14059-1-git-send-email-bwalton@artsci.utoronto.ca> (raw)
In-Reply-To: <4ACE4C72.4050400@gmail.com>
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 <bwalton@artsci.utoronto.ca>
---
This is the alternate solution to this bug as proposed earlier today.
I don't have a preference either way for which solution is better or
more inline with the 'git way,' so please choose the most appropriate.
I've run the test suite with both patches on Linux and Solaris
and everything passes.
builtin-ls-files.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index f473220..2c95ca6 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 |
--
1.6.4.4
next prev parent reply other threads:[~2009-10-09 1:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-08 14:20 [PATCH] ls-files: make option parser keep argv[0] Ben Walton
2009-10-08 20:32 ` Stephen Boyd
2009-10-09 1:53 ` Ben Walton [this message]
2009-10-09 6:53 ` [PATCH] ls-files: die instead of fprintf/exit in -i error Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1255053215-14059-1-git-send-email-bwalton@artsci.utoronto.ca \
--to=bwalton@artsci.utoronto.ca \
--cc=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).