* [PATCH 1/2] reflog: make the 'show' subcommand really the default @ 2010-04-19 9:52 SZEDER Gábor 2010-04-19 9:52 ` [PATCH 2/2] reflog: remove 'show' from 'expire's usage string SZEDER Gábor 2010-04-20 0:46 ` [PATCH 1/2] reflog: make the 'show' subcommand really the default Junio C Hamano 0 siblings, 2 replies; 6+ messages in thread From: SZEDER Gábor @ 2010-04-19 9:52 UTC (permalink / raw) To: Junio C Hamano; +Cc: Linus Torvalds, git, SZEDER Gábor Since the introduction of the 'show' subcommand in cf39f54e (git reflog show, 2007-02-08), 'git reflog's documentation states that in the absence of any subcommands 'show' is the default. Although 'git reflog <log-options>' works as described, i.e. it defaults to 'show', the command 'git reflog <ref>' errors out showing the usage instead of showing the specified ref's reflog. Fix this by treating an unknown subcommand as a ref for 'show'. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> --- builtin/reflog.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index 64e45bd..d4d4409 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -712,6 +712,5 @@ int cmd_reflog(int argc, const char **argv, const char *prefix) if (!strcmp(argv[1], "delete")) return cmd_reflog_delete(argc - 1, argv + 1, prefix); - /* Not a recognized reflog command..*/ - usage(reflog_usage); + return cmd_log_reflog(argc, argv, prefix); } -- 1.7.1.rc1.43.gf0841 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] reflog: remove 'show' from 'expire's usage string 2010-04-19 9:52 [PATCH 1/2] reflog: make the 'show' subcommand really the default SZEDER Gábor @ 2010-04-19 9:52 ` SZEDER Gábor 2010-04-20 0:46 ` [PATCH 1/2] reflog: make the 'show' subcommand really the default Junio C Hamano 1 sibling, 0 replies; 6+ messages in thread From: SZEDER Gábor @ 2010-04-19 9:52 UTC (permalink / raw) To: Junio C Hamano; +Cc: Linus Torvalds, git, SZEDER Gábor Most of 'expire's options are not recognized by the 'show' subcommand, hence it errors out. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> --- builtin/reflog.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index d4d4409..fe8b36d 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -13,7 +13,7 @@ */ static const char reflog_expire_usage[] = -"git reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>..."; +"git reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>..."; static const char reflog_delete_usage[] = "git reflog delete [--verbose] [--dry-run] [--rewrite] [--updateref] <refs>..."; -- 1.7.1.rc1.43.gf0841 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] reflog: make the 'show' subcommand really the default 2010-04-19 9:52 [PATCH 1/2] reflog: make the 'show' subcommand really the default SZEDER Gábor 2010-04-19 9:52 ` [PATCH 2/2] reflog: remove 'show' from 'expire's usage string SZEDER Gábor @ 2010-04-20 0:46 ` Junio C Hamano 2010-04-20 11:37 ` Jeff King 1 sibling, 1 reply; 6+ messages in thread From: Junio C Hamano @ 2010-04-20 0:46 UTC (permalink / raw) To: SZEDER Gábor; +Cc: Linus Torvalds, git SZEDER Gábor <szeder@ira.uka.de> writes: > diff --git a/builtin/reflog.c b/builtin/reflog.c > index 64e45bd..d4d4409 100644 > --- a/builtin/reflog.c > +++ b/builtin/reflog.c > @@ -712,6 +712,5 @@ int cmd_reflog(int argc, const char **argv, const char *prefix) > if (!strcmp(argv[1], "delete")) > return cmd_reflog_delete(argc - 1, argv + 1, prefix); > > - /* Not a recognized reflog command..*/ > - usage(reflog_usage); > + return cmd_log_reflog(argc, argv, prefix); 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'd rather see a fix for the documentation. Your [PATCH 2/2] looks very sane, though. Thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] reflog: make the 'show' subcommand really the default 2010-04-20 0:46 ` [PATCH 1/2] reflog: make the 'show' subcommand really the default Junio C Hamano @ 2010-04-20 11:37 ` Jeff King 2010-04-22 13:57 ` SZEDER Gábor 0 siblings, 1 reply; 6+ messages in thread From: Jeff King @ 2010-04-20 11:37 UTC (permalink / raw) To: Junio C Hamano; +Cc: SZEDER Gábor, Linus Torvalds, git On Mon, Apr 19, 2010 at 05:46:02PM -0700, Junio C Hamano wrote: > SZEDER Gábor <szeder@ira.uka.de> writes: > > > diff --git a/builtin/reflog.c b/builtin/reflog.c > > index 64e45bd..d4d4409 100644 > > --- a/builtin/reflog.c > > +++ b/builtin/reflog.c > > @@ -712,6 +712,5 @@ int cmd_reflog(int argc, const char **argv, const char *prefix) > > if (!strcmp(argv[1], "delete")) > > return cmd_reflog_delete(argc - 1, argv + 1, prefix); > > > > - /* Not a recognized reflog command..*/ > > - usage(reflog_usage); > > + return cmd_log_reflog(argc, argv, prefix); > > 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. 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. 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. So I don't think the patch is a huge mistake (at least not as huge as the stash one). However, I personally "git log -g [--oneline]" to be much easier to remember to use and to type. -Peff ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] reflog: make the 'show' subcommand really the default 2010-04-20 11:37 ` Jeff King @ 2010-04-22 13:57 ` SZEDER Gábor 2010-04-22 14:40 ` Jeff King 0 siblings, 1 reply; 6+ messages in thread From: SZEDER Gábor @ 2010-04-22 13:57 UTC (permalink / raw) To: Jeff King; +Cc: Junio C Hamano, Linus Torvalds, git Hi, On Tue, Apr 20, 2010 at 07:37:36AM -0400, Jeff King wrote: > 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 > 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. > 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] reflog: make the 'show' subcommand really the default 2010-04-22 13:57 ` SZEDER Gábor @ 2010-04-22 14:40 ` Jeff King 0 siblings, 0 replies; 6+ messages in thread From: Jeff King @ 2010-04-22 14:40 UTC (permalink / raw) To: SZEDER Gábor; +Cc: Junio C Hamano, Linus Torvalds, git On Thu, Apr 22, 2010 at 03:57:31PM +0200, SZEDER Gábor wrote: > > 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 Er, yeah, that is what I meant. Sorry, thinko on my part. > > 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. Right, what you quoted from me was not Junio's concern. But I argued against Junio's concern earlier in the mail. Basically, it is a corner case. _If_ we add a new command to "git reflog", and _if_ that command is the same as the name of your ref, you must stop using the short form for that ref, and instead use "git reflog show $ref". So for things like scripts that don't know what $ref will be, and want to be on the safe side, they should continue to use the explicit "git reflog show $ref" form. But there is no reason that humans typing a command need to be bound by that restriction when it is unlikely to happen (and even if it did, they would recover from it easily). Personally, I don't care either way whether the documentation is updated to match the behavior of vice versa. But I just don't see what your original patch did as very harmful, and I can see how it would be helpful (on the few occassions when I did use "git reflog show", I first typed it forgetting the "show"). -Peff ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-22 14:41 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-04-19 9:52 [PATCH 1/2] reflog: make the 'show' subcommand really the default SZEDER Gábor 2010-04-19 9:52 ` [PATCH 2/2] reflog: remove 'show' from 'expire's usage string SZEDER Gábor 2010-04-20 0:46 ` [PATCH 1/2] reflog: make the 'show' subcommand really the default Junio C Hamano 2010-04-20 11:37 ` Jeff King 2010-04-22 13:57 ` SZEDER Gábor 2010-04-22 14:40 ` Jeff King
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).