Re: [PATCH 1/5] parseopt: add OPT_NEGBIT
From: Jeff King <hidden>
Date: 2016-06-15 22:46:43
Subsystem:
the rest · Maintainer:
Linus Torvalds
On Thu, May 07, 2009 at 09:44:17PM +0200, René Scharfe wrote:
Add OPTION_NEGBIT and OPT_NEGBIT, mirroring OPTION_BIT and OPT_BIT. OPT_NEGBIT can be used together with OPT_BIT to define two options that cancel each other out.
Nice, this neatly fixes the problem with --no-no-empty-directory in "ls-files" discussed here: http://article.gmane.org/gmane.comp.version-control.git/112607 We just need this patch on top of René's 1/5: -- >8 -- Subject: [PATCH] ls-files: make --no-empty-directory properly negatable This option was specified to parseopt as an OPT_BIT; however, we actually want to _set_ the bit on --no-empty-directory. Thus the existing implementation used --no-empty-directory, and required --no-no-empty-directory to negate it. Now that OPT_NEGBIT exists, we can properly support it as --empty-directory and --no-empty-directory (but of course still defaulting to showing empty directories). Signed-off-by: Jeff King <redacted> --- builtin-ls-files.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index da2daf4..3d59b0e 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c@@ -454,7 +454,7 @@ 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, + OPT_NEGBIT(0, "empty-directory", &dir.flags, "don't show empty directories", DIR_HIDE_EMPTY_DIRECTORIES), OPT_BOOLEAN('u', "unmerged", &show_unmerged,
--
1.6.3.201.g5d2a4.dirty