git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.

From
Nelson Elhage <nelhage@mit.edu>
Date
Sep 13, 2009, 03:40 UTC
Message-ID
<20090913034031.GO4275@mit.edu>
In-Reply-To
<7vfxar5zsi.fsf@alter.siamese.dyndns.org>
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).

Show 7 quoted lines
> 
> 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.

Show 8 quoted lines
> 
> 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.

Previous: Junio C HamanoNext: Nelson Elhage
Message 3 of 8 in “git-push: Accept -n as a synonym for --dry-run.”
  1. git-push: Accept -n as a synonym for --dry-run.Nelson Elhage, Sep 13, 2009
  2. Junio C HamanoSep 13, 2009
  3. Nelson ElhageSep 13, 2009
  4. Nelson ElhageSep 13, 2009
  5. Junio C HamanoSep 13, 2009
  6. Junio C HamanoSep 13, 2009
  7. Nelson ElhageSep 13, 2009
  8. Junio C HamanoSep 13, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.