All of lore.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Junio C Hamano <gitster@pobox.com>
Cc: Thomas Rast <trast@inf.ethz.ch>,
	git@vger.kernel.org, Bert Wesarg <bert.wesarg@googlemail.com>,
	Geoffrey Irving <irving@naml.us>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Pierre Habouzit <madcoder@debian.org>, Jeff King <peff@peff.net>
Subject: [PATCH 4/3] parse-options: disallow --no-no-sth
Date: Tue, 28 Feb 2012 21:12:53 +0100	[thread overview]
Message-ID: <4F4D3545.6060704@lsrfire.ath.cx> (raw)
In-Reply-To: <7vzkc457g3.fsf@alter.siamese.dyndns.org>

Now that options whose definition starts with "no-" can be negated
by removing said "no-", there is no need anymore to allow them to
be negated by adding a second "no-", which just looks silly.

The following thirteen options are affected:

	apply          --no-add
	bisect--helper --no-checkout
	checkout-index --no-create
	clone          --no-checkout --no-hardlinks
	commit         --no-verify   --no-post-rewrite
	format-patch   --no-binary
	hash-object    --no-filters
	read-tree      --no-sparse-checkout
	revert         --no-commit
	show-branch    --no-name
	update-ref     --no-deref

E.g., with this patch --no-add and --add (its reverse) are still
accepted by git apply, but --no-no-add isn't anymore.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 parse-options.c          |    3 +++
 t/t0040-parse-options.sh |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 1908996..dc59bba 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -248,6 +248,9 @@ is_abbreviated:
 				}
 				continue;
 			}
+			/* double negation? */
+			if (!prefixcmp(long_name, "no-"))
+				continue;
 			flags |= OPT_UNSET;
 			rest = skip_prefix(arg + 3, long_name);
 			/* abbreviated and negated? */
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index a44bcb9..b124f3c 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -101,11 +101,11 @@ test_expect_success 'OPT_BOOL() #5' 'check boolean: 1 -B'
 test_expect_success 'OPT_BOOL() is idempotent #1' 'check boolean: 1 --yes --yes'
 test_expect_success 'OPT_BOOL() is idempotent #2' 'check boolean: 1 -DB'
 
-test_expect_success 'OPT_BOOL() negation #1' 'check boolean: 0 -D --no-yes'
-test_expect_success 'OPT_BOOL() negation #2' 'check boolean: 0 -D --no-no-doubt'
+test_expect_success 'OPT_BOOL() negation' 'check boolean: 0 -D --no-yes'
 
 test_expect_success 'OPT_BOOL() no negation #1' 'check_unknown --fear'
 test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown --no-no-fear'
+test_expect_success 'OPT_BOOL() no negation #3' 'check_unknown --no-no-doubt'
 
 test_expect_success 'OPT_BOOL() positivation' 'check boolean: 0 -D --doubt'
 
-- 
1.7.9.2

  reply	other threads:[~2012-02-28 20:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-25 19:07 [PATCH 0/3] parse-options: no- symmetry René Scharfe
2012-02-25 19:11 ` [PATCH 1/3] test-parse-options: convert to OPT_BOOL() René Scharfe
2012-02-25 19:14 ` [PATCH 2/3] parse-options: allow positivation of options starting, with no- René Scharfe
2012-02-26 23:32   ` Junio C Hamano
2012-02-27  8:30     ` Thomas Rast
2012-02-27 17:18       ` Junio C Hamano
2012-02-27 17:56         ` René Scharfe
2012-02-27 20:48           ` Junio C Hamano
2012-02-28 20:12             ` René Scharfe [this message]
2012-02-28 21:15               ` [PATCH 4/3] parse-options: disallow --no-no-sth Junio C Hamano
2012-02-29 18:06                 ` René Scharfe
2012-02-29 19:02                   ` Junio C Hamano
2012-02-25 19:15 ` [PATCH 3/3] parse-options: remove PARSE_OPT_NEGHELP René Scharfe
2012-02-27 18:25   ` Jeff King
2012-02-27 18:58     ` Junio C Hamano
2012-02-27 22:26     ` René Scharfe
2012-02-28  0:34       ` Jeff King
2012-02-28 19:06   ` [PATCH 3/3 v2] " René Scharfe
2012-02-28 19:09     ` Jeff King

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=4F4D3545.6060704@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=irving@naml.us \
    --cc=madcoder@debian.org \
    --cc=peff@peff.net \
    --cc=trast@inf.ethz.ch \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.