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

Re: [PATCH 1/2] reflog: make the 'show' subcommand really the default

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Apr 22, 2010, 13:57 UTC
Message-ID
<20100422135731.GS4440@neumann>
In-Reply-To
<20100420113736.GA22907@coredump.intra.peff.net>
Hi,
On Tue, Apr 20, 2010 at 07:37:36AM -0400, Jeff King wrote:
Show 17 quoted lines
> On Mon, Apr 19, 2010 at 05:46:02PM -0700, Junio C Hamano wrote:
> 
> > I am not convinced that this is a good change.
> > 
> > It may be that show/expire/delete happens to be the _only_ subcommands
> > today, but if we had this patch, the command will change the behaviour
> > when we add a new subcommand (the name of that subcommand may happen to be
> > also a refname).
> 
> I don't think it is that big a deal. Scripts should always use the
> explicit "git reflog show <ref>" form, which will remain safe. "git
> reflog <ref>" is handy for humans.
> 
> That being said, we tried this same experiment with "git stash [show]
> <msg>" and ended up rejecting it. However, the main complaint with that
> was the failure mode for typos. Typing "git stash sohw" would make a new
> stash.
I think you meant "git stash [save] <msg>" here, right?
http://thread.gmane.org/gmane.comp.version-control.git/63566/focus=63645
Show 10 quoted lines
> In this case, typing "git reflog exipre" would get you:
> 
>   fatal: ambiguous argument 'exipre': unknown revision or path not in
>   the working tree.
>   Use '--' to separate paths from revisions
> 
> and you would repeat the command with the typo fixed, which is perhaps
> not as bad. And unlike stash, "show" is really the dominant command (I
> don't think I have ever manually used 'delete' or 'expire'), so it is
> more likely to be right than not.

If I understood Junio correctly, he is concerned about a different case.

With my patch "git reflog foo" would show foo's reflog, assuming there is a branch named "foo". This is what people would expect according to the documentation. However, once we implement the subcommand "foo", "git reflog foo" will no longer print foo's reflog but instead will perform whatever the subcommand "foo" is supposed to do by default, which might be difficult to recover from.

Show 9 quoted lines
> The current behavior is also weirdly inconsistent:
> 
>   git reflog ;# works, shows HEAD
>   git reflog -p ;# works, shows HEAD with -p
>   git reflog -p foo ;# works, shows foo with -p
>   git reflog foo ;# does not work
> 
> I can see allowing the first two, but the fact that the third works and
> the fourth doesn't seems odd to me.

Indeed. I tried to whip up a patch to fix the documentation to match the current behaviour, but my first attempt failed because of these inconsistencies.

> However, I personally "git log -g [--oneline]" to be
> much easier to remember to use and to type.

Just as sidenote: I rarely use reflog, but then for me it's easier to remember to "reflog" than "-g". But even then I never remember "show" for the first time, that's why I wrote this patch.

Best, Gábor

Previous: Jeff KingNext: Jeff King
Message 5 of 6 in “reflog: make the 'show' subcommand really the default”
  1. 1/2 reflog: make the 'show' subcommand really the defaultSZEDER Gábor, Apr 19, 2010
  2. 2/2 reflog: remove 'show' from 'expire's usage stringSZEDER Gábor, Apr 19, 2010
  3. Junio C HamanoApr 20, 2010
  4. Jeff KingApr 20, 2010
  5. SZEDER GáborApr 22, 2010
  6. Jeff KingApr 22, 2010

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.