From: Jeff King <peff@peff.net>
To: Miklos Vajna <vmiklos@frugalware.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 2/2] ls-files: fix broken --no-empty-directory
Date: Tue, 10 Mar 2009 15:11:11 -0400 [thread overview]
Message-ID: <20090310191111.GA27662@sigill.intra.peff.net> (raw)
In-Reply-To: <20090308211312.GE4371@genesis.frugalware.org>
On Sun, Mar 08, 2009 at 10:13:12PM +0100, Miklos Vajna wrote:
> > + OPT_BIT(0, "no-empty-directory", &dir.flags,
> > + "don't show empty directories",
> > DIR_HIDE_EMPTY_DIRECTORIES),
> > OPT_BOOLEAN('u', "unmerged", &show_unmerged,
> > "show unmerged files in the output"),
>
> Thanks for catching this. But then why not using PARSE_OPT_NONEG?
>
> That would avoid --no-no-empty-directory.
I think either we don't care about negation, in which case it is not
hurting anybody to support --no-no-empty-directory, or we do, in which
case you actually want to do the negation properly. Which would be
something like:
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 437c366..2c5f7a5 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -427,6 +427,7 @@ static int option_parse_exclude_standard(const struct option *opt,
int cmd_ls_files(int argc, const char **argv, const char *prefix)
{
int require_work_tree = 0, show_tag = 0;
+ int show_empty_directories = 1;
struct dir_struct dir;
struct option builtin_ls_files_options[] = {
{ OPTION_CALLBACK, 'z', NULL, NULL, NULL,
@@ -454,9 +455,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
OPT_BIT(0, "directory", &dir.flags,
"show 'other' directories' name only",
DIR_SHOW_OTHER_DIRECTORIES),
- OPT_BIT(0, "no-empty-directory", &dir.flags,
- "don't show empty directories",
- DIR_HIDE_EMPTY_DIRECTORIES),
+ OPT_BOOLEAN(0, "empty-directory", &show_empty_directories,
+ "show empty directories (on by default)"),
OPT_BOOLEAN('u', "unmerged", &show_unmerged,
"show unmerged files in the output"),
{ OPTION_CALLBACK, 'x', "exclude", &dir.exclude_list[EXC_CMDL], "pattern",
@@ -506,6 +506,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
show_stage = 1;
if (dir.exclude_per_dir)
exc_given = 1;
+ if (!show_empty_directories)
+ dir.flags |= DIR_HIDE_EMPTY_DIRECTORIES;
if (require_work_tree && !is_inside_work_tree())
setup_work_tree();
which is even still a little confusing, as you get "--empty-directory"
in the usage message. But you would almost never want to use that, as it
is already the default.
-Peff
next prev parent reply other threads:[~2009-03-10 19:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-08 1:20 [PATCH 0/2] fix ls-files parseopt regression Jeff King
2009-03-08 1:22 ` [PATCH 1/2] t3000: use test_cmp instead of diff Jeff King
2009-03-08 1:27 ` [PATCH 2/2] ls-files: fix broken --no-empty-directory Jeff King
2009-03-08 21:13 ` Miklos Vajna
2009-03-10 19:11 ` Jeff King [this message]
2009-03-10 22:16 ` Miklos Vajna
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=20090310191111.GA27662@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=vmiklos@frugalware.org \
/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).