git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-push: Accept -n as a synonym for --dry-run.
@ 2009-09-13  0:05 Nelson Elhage
  2009-09-13  2:44 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Nelson Elhage @ 2009-09-13  0:05 UTC (permalink / raw)
  To: git; +Cc: Nelson Elhage

'-n' is the standard way to specify a dry run for other git commands,
so make 'git-push' accept it as well.
---
 Documentation/git-push.txt |    3 ++-
 builtin-push.c             |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 58d2bd5..ba6a8a2 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -9,7 +9,7 @@ git-push - Update remote refs along with associated objects
 SYNOPSIS
 --------
 [verse]
-'git push' [--all | --mirror | --tags] [--dry-run] [--receive-pack=<git-receive-pack>]
+'git push' [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
 	   [--repo=<repository>] [-f | --force] [-v | --verbose]
 	   [<repository> <refspec>...]
 
@@ -82,6 +82,7 @@ nor in any Push line of the corresponding remotes file---see below).
 	if the configuration option `remote.<remote>.mirror` is
 	set.
 
+-n::
 --dry-run::
 	Do everything except actually send the updates.
 
diff --git a/builtin-push.c b/builtin-push.c
index 787011f..5e5f3ad 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,7 +10,7 @@
 #include "parse-options.h"
 
 static const char * const push_usage[] = {
-	"git push [--all | --mirror] [--dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
+	"git push [--all | --mirror] [-n | --dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
 	NULL,
 };
 
@@ -182,7 +182,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
 			    (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
 		OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
-		OPT_BIT( 0 , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
+		OPT_BIT('n' , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
 		OPT_BIT( 0,  "porcelain", &flags, "machine-readable output", TRANSPORT_PUSH_PORCELAIN),
 		OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE),
 		OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
-- 
1.6.3.1.499.ge7b8da

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
  2009-09-13  0:05 [PATCH] git-push: Accept -n as a synonym for --dry-run Nelson Elhage
@ 2009-09-13  2:44 ` Junio C Hamano
  2009-09-13  3:40   ` Nelson Elhage
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2009-09-13  2:44 UTC (permalink / raw)
  To: Nelson Elhage; +Cc: git

Nelson Elhage <nelhage@MIT.EDU> writes:

> '-n' is the standard way to specify a dry run for other git commands,
> so make 'git-push' accept it as well.
> ---

Sign-off?

Indeed -n is used in many places for --dry-run, but it is not _the_
standard way.

commit, push (as you identified), reflog, and send-email have --dry-run
but -n is not a synonym for it.  Some of them even use -n as a shorthand
for a more often used option than --dry-run.

So the justification should be more like "push does not any other option
that deserves a short-and-sweet -n better, it will not have any such
option in the future, and --dry-run is very often used that it deserves to
use -n as its short-hand."

I tend to agree with the first two points, but I am not sure about the
third point.  Do people dry-push that often?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
  2009-09-13  2:44 ` Junio C Hamano
@ 2009-09-13  3:40   ` Nelson Elhage
  2009-09-13  3:54     ` Nelson Elhage
  2009-09-13  5:18     ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Nelson Elhage @ 2009-09-13  3:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Sat, Sep 12, 2009 at 07:44:29PM -0700, Junio C Hamano wrote:
> Sign-off?

Signed-off-by: Nelson Elhage <nelhage@mit.edu>

(I can resend the entire patch, but I'll resend with a new commit
message if appropriate after any discussion plays itself out).

> 
> Indeed -n is used in many places for --dry-run, but it is not _the_
> standard way.
> 
> commit, push (as you identified), reflog, and send-email have --dry-run
> but -n is not a synonym for it.  Some of them even use -n as a shorthand
> for a more often used option than --dry-run.

Can you point to an example of a git command supporting --dry-run, and
using -n for something else? I personally would find that confusing,
since -n is a common alias for dry-run both inside and outside of git
(c.f. make, rsync, libtool). I guess patch(1) has that property, but
none of your examples from git use -n to mean something else.

In fact, reflog already supports '-n' to mean dry-run, it's just not
documented. I'll send along a documentation patch to fix that.

I got the claim that -n was "standard" from parse-options.h, which
defines OPT__DRY_RUN, which defines both -n and --dry-run switches at
the same time. Given the number of commands that treat them as
synonymous, I think it would be a win for UI consistency to make them
synonymous everywhere.

> 
> So the justification should be more like "push does not any other option
> that deserves a short-and-sweet -n better, it will not have any such
> option in the future, and --dry-run is very often used that it deserves to
> use -n as its short-hand."
> 
> I tend to agree with the first two points, but I am not sure about the
> third point.  Do people dry-push that often?

I personally use --dry-run almost every time I push, which is what
inspired this patch. Especially now that the push.default can change
the behavior of push from repo to repo, I want to be sure I know what
I'm about to push. The recent 'git push --confirm' thread suggests I
am not the only person with this concern.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
  2009-09-13  3:40   ` Nelson Elhage
@ 2009-09-13  3:54     ` Nelson Elhage
  2009-09-13  5:23       ` Junio C Hamano
  2009-09-13  5:18     ` Junio C Hamano
  1 sibling, 1 reply; 8+ messages in thread
From: Nelson Elhage @ 2009-09-13  3:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Sat, Sep 12, 2009 at 11:40:31PM -0400, Nelson Elhage wrote:
> On Sat, Sep 12, 2009 at 07:44:29PM -0700, Junio C Hamano wrote:
> Can you point to an example of a git command supporting --dry-run, and
> using -n for something else? I personally would find that confusing,
> since -n is a common alias for dry-run both inside and outside of git
> (c.f. make, rsync, libtool). I guess patch(1) has that property, but
> none of your examples from git use -n to mean something else.

Oops, I missed 'commit' in your list, which I see (as of recently) has
that property. In that case, though, --dry-run was added after an
established -n option had been there for a long time; I think my
general argument still stands for commands where that is not the case.

- Nelson

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
  2009-09-13  3:40   ` Nelson Elhage
  2009-09-13  3:54     ` Nelson Elhage
@ 2009-09-13  5:18     ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2009-09-13  5:18 UTC (permalink / raw)
  To: Nelson Elhage; +Cc: git

Nelson Elhage <nelhage@MIT.EDU> writes:

>> commit, push (as you identified), reflog, and send-email have --dry-run
>> but -n is not a synonym for it.  Some of them even use -n as a shorthand
>> for a more often used option than --dry-run.
>
> Can you point to an example of a git command supporting --dry-run, and
> using -n for something else?

Doesn't commit -n stand for no-verify?  I think that is how it is
documented.

> In fact, reflog already supports '-n' to mean dry-run,

Huh?  "git reflog -n 4" is for show-four-entries-from-the-top.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
  2009-09-13  3:54     ` Nelson Elhage
@ 2009-09-13  5:23       ` Junio C Hamano
  2009-09-13  6:10         ` Junio C Hamano
  2009-09-13 17:07         ` Nelson Elhage
  0 siblings, 2 replies; 8+ messages in thread
From: Junio C Hamano @ 2009-09-13  5:23 UTC (permalink / raw)
  To: Nelson Elhage; +Cc: Junio C Hamano, git

Nelson Elhage <nelhage@MIT.EDU> writes:

> ... I think my
> general argument still stands for commands where that is not the case.

Cool down.

It is a mere subset of what I already said, so you are not arguing against
me at all.

    So the justification should be more like "push does not have any other
    option that deserves a short-and-sweet -n better, it will not have any
    such option in the future, and --dry-run is very often used that it
    deserves to use -n as its short-hand."

and I already said I tend to agree with the first two points.  Indeed the
first point is an absolute truth (the statement is about the current
state).

To answer the second point you need to look into the future, but I do not
foresee us adding a very useful option to the command whose usefulness far
outweigh that of dry-run and whose name begins with 'n' to want to use it
as the short-hand.  In such a case, it is likely that we would try very
hard to find a name that does not begin with 'n' to avoid the issue.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
  2009-09-13  5:23       ` Junio C Hamano
@ 2009-09-13  6:10         ` Junio C Hamano
  2009-09-13 17:07         ` Nelson Elhage
  1 sibling, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2009-09-13  6:10 UTC (permalink / raw)
  To: Nelson Elhage; +Cc: Junio C Hamano, git

Junio C Hamano <gitster@pobox.com> writes:

> ..., so you are not arguing against
> me at all.
> ... it is likely that we would try very
> hard to find a name that does not begin with 'n' to avoid the issue.

So what's my objection, in short?

It is just the wording "_the_ standard" that implies that anything that
uses -n to mean something other than --dry-run is _wrong_.

I didn't want to see anybody arguing against "commit -n".  It is used to
defeat pre-commit hook and has been there with us for a long time.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
  2009-09-13  5:23       ` Junio C Hamano
  2009-09-13  6:10         ` Junio C Hamano
@ 2009-09-13 17:07         ` Nelson Elhage
  1 sibling, 0 replies; 8+ messages in thread
From: Nelson Elhage @ 2009-09-13 17:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Sat, Sep 12, 2009 at 10:23:47PM -0700, Junio C Hamano wrote:
> Nelson Elhage <nelhage@MIT.EDU> writes:
> 
> > ... I think my
> > general argument still stands for commands where that is not the case.
> 
> Cool down.
> 
> It is a mere subset of what I already said, so you are not arguing against
> me at all.

My apologies for continuing an argument where there was none. I've
sent a patch with an improved commit message, and we can continue
discussing on that thread if necessary.

- Nelson

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-09-13 17:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-13  0:05 [PATCH] git-push: Accept -n as a synonym for --dry-run Nelson Elhage
2009-09-13  2:44 ` Junio C Hamano
2009-09-13  3:40   ` Nelson Elhage
2009-09-13  3:54     ` Nelson Elhage
2009-09-13  5:23       ` Junio C Hamano
2009-09-13  6:10         ` Junio C Hamano
2009-09-13 17:07         ` Nelson Elhage
2009-09-13  5:18     ` Junio C Hamano

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).