{"thread":{"id":"28780","subject":"git alias and --help","startedAt":"2011-10-27T22:20:56Z","lastAt":"2011-10-28T20:23:58Z","messageCount":14,"participants":["Gelonida N","Junio C Hamano","Miles Bader","Michael J Gruber","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"178382","messageId":"j8clg9$ldh$1@dough.gmane.org","threadId":"28780","inReplyTo":null,"subject":"git alias and --help","fromName":"Gelonida N","fromEmail":"gelonida@gmail.com","sentAt":"2011-10-27T22:20:56Z","receivedAt":"2011-10-27T22:20:56Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"I'm having a tiny question about git aliases.\n\nin ~/.gitconfig I defined an alias\n\nb = branch\n\n\n\nThis works well execp if I type\n\n\ngit b --help\n\nNow I get the output\n`git b' is aliased to `branch'\n\n\nwhich is nice to know however what I reall wanted is to get the helptext\nfor the branch command.\n\n\nIs there any trick to get the help text of git branch without\nhaving to type\n\ngit branch --help\n"},{"id":"178384","messageId":"7vfwiexe6m.fsf@alter.siamese.dyndns.org","threadId":"28780","inReplyTo":"j8clg9$ldh$1@dough.gmane.org","subject":"Re: git alias and --help","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-27T22:28:01Z","receivedAt":"2011-10-27T22:28:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gelonida N <gelonida@gmail.com> writes:\n\n> Is there any trick to get the help text of git branch without\n> having to type\n>\n> git branch --help\n\nHow about \"git help branch\"?\n"},{"id":"178386","messageId":"7v8vo6xd4u.fsf@alter.siamese.dyndns.org","threadId":"28780","inReplyTo":"7vfwiexe6m.fsf@alter.siamese.dyndns.org","subject":"Re: git alias and --help","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-27T22:50:41Z","receivedAt":"2011-10-27T22:50:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Gelonida N <gelonida@gmail.com> writes:\n>\n>> Is there any trick to get the help text of git branch without\n>> having to type\n>>\n>> git branch --help\n>\n> How about \"git help branch\"?\n\nIt was bad of me to write a tongue-in-cheek answer, get distracted and\nended up sending it without the real answer.\n\nThe reason why we do not do what you seem to be suggesting is because\ngiving the same behaviour to \"git b --help\" as \"git branch --help\" is\nwrong.\n\nTo see why, imagine you have configured an alias that is not a simple and\nstupid substitution \"b == branch\", but something like \"bt == branch -t\",\nand then want to know what you should write after \"git bt\".  Giving the\nmanpage for branch without giving them any hint that they configured that\nalias to produce customized behaviour that is different from plain vanilla\n\"branch\" is not quite acceptable.\n\nI think you _could_ make a patch that special cases a simple and straight\nsubstitution and skip the \"foo is aliased to bar\" step, but I doubt it is\nworth it to lose consistency between \"git b --help\" vs \"git bt --help\"\nthat way.\n"},{"id":"178392","messageId":"j8csn7$v1u$1@dough.gmane.org","threadId":"28780","inReplyTo":"7v8vo6xd4u.fsf@alter.siamese.dyndns.org","subject":"Re: git alias and --help","fromName":"Gelonida N","fromEmail":"gelonida@gmail.com","sentAt":"2011-10-28T00:24:07Z","receivedAt":"2011-10-28T00:24:07Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"On 10/28/2011 12:50 AM, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> Gelonida N <gelonida@gmail.com> writes:\n>>\n>>> Is there any trick to get the help text of git branch without\n>>> having to type\n>>>\n>>> git branch --help\n>>\n>> How about \"git help branch\"?\n> \n> It was bad of me to write a tongue-in-cheek answer, get distracted and\n> ended up sending it without the real answer.\nNo issues. At least I got an answer :-)\n> \n> The reason why we do not do what you seem to be suggesting is because\n> giving the same behaviour to \"git b --help\" as \"git branch --help\" is\n> wrong.\n> \n> To see why, imagine you have configured an alias that is not a simple and\n> stupid substitution \"b == branch\", but something like \"bt == branch -t\",\n> and then want to know what you should write after \"git bt\".  Giving the\n> manpage for branch without giving them any hint that they configured that\n> alias to produce customized behaviour that is different from plain vanilla\n> \"branch\" is not quite acceptable.\n> \n> I think you _could_ make a patch that special cases a simple and straight\n> substitution and skip the \"foo is aliased to bar\" step, but I doubt it is\n> worth it to lose consistency between \"git b --help\" vs \"git bt --help\"\n> that way.\n\n\nI understand the reasoning and agree, that as general case it might not\nbe a good idea to have the behaviour, taht I expected to be the default\nbehaviour\n\nIt's just, that I am lazy so I shortened  my most common commands\n\nFor example:\nco=checkout\nci=commit\nb=branch\nsm=submodule\n\nHowever I'm not smart enough to remember all options for all commands\nand so I have to ask git for occasional help.\n\n\nIt feels so 'unlazy' to have to type the full command 'just' to get help\n\n\nWhat I wondered though is whether there couldn't be a way to be lazy and\navoid confusion.\n\n1.) prompt for full help\n-------------------------\n\nOne option would be to display what the command is aliased to and to\nprompt whether one wants to see the full help of the base command.\n\n`git b' is aliased to `branch'\npleaset press h if you want to see the full help for git branch\nor press q to quit\n\n\n2.) allow copy paste by displaying the command to be typed for help.\n---------------------------------------------------------------------\ndisplay sometihing like:\n\n`git b' is aliased to `branch'\nfor help about the branch command type:  git --help\n\n\nThen lazy people could copy paste the command instead of typing it.\n\n\n3.) special alias syntax to allow 'forwarding' of --help\n------------------------------------------------------------\n\nsome kind of special alias syntax, which explicitely forces that --help\nis 'forwarded' to the alias and not treated by git\n\n\nexample:\n\nb = branch   # --help would have the current behaviour\n\nI tried following to see whether '--help' is now being 'forwarded'\n\nb = ! git branch\nbut also  here --help is treated by git\n\nA possibility could be another 'special' character. For the sake of the\nexample I used '?'\nb = ?branch # 'the question mark would allow 'forwarding' the\n             # --help option to the alias'\n\nb = ?! git branch\n\n\n\nMy workaround\n------------\n\nFort the time being I might do something like\n\nbhlp = branch --help\n\nI would have prefered b_hlp or b_h, but it seems underscore isn't\nallowed in an alias.\n"},{"id":"178394","messageId":"buoty6t9937.fsf@dhlpc061.dev.necel.com","threadId":"28780","inReplyTo":"7v8vo6xd4u.fsf@alter.siamese.dyndns.org","subject":"Re: git alias and --help","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2011-10-28T01:51:56Z","receivedAt":"2011-10-28T01:51:56Z","isPatch":false,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n>>> git branch --help\n>>\n>> How about \"git help branch\"?\n>\n> The reason why we do not do what you seem to be suggesting is because\n> giving the same behaviour to \"git b --help\" as \"git branch --help\" is\n> wrong.\n\nI agree with Gelonida's followup:  although what you say makes sense,\nit's still pretty annoying behavior for the very common case of a\nsimple renaming alias...\n\nE.g., I have \"co\" aliased to \"checkout\", and so my fingers are very\nvery inclined to say \"co\" when I mean checkout... including when\nasking for help.  I actually end up typing \"git co --help\", grumbling,\nand retyping with the full command name, quite reguarly.\n\nWhat I've often wished is that git's help system would output\nsomething like:\n\n   $ git help co\n   `git co' is aliased to `checkout'\n\n   Here's the help entry for `checkout':\n\n   GIT-CHECKOUT(1)                   Git Manual                   GIT-CHECKOUT(1)\n\n   NAME\n          git-checkout - Checkout a branch or paths to the working tree\n   ...\n\n[with the \"`git co' is aliased ...\" header included in the pager\noutput.]\n\nOf course, that would be the wrong thing for somebody that just wants\nto be reminded what an alias expands too, but my intuition is that\nthis is a very tiny minority compared to people that want to examine\nthe options for the underlying command...\n\n-Miles\n\n-- \nSuburbia: where they tear out the trees and then name streets after them.\n"},{"id":"178395","messageId":"7vvcr9wyje.fsf@alter.siamese.dyndns.org","threadId":"28780","inReplyTo":"buoty6t9937.fsf@dhlpc061.dev.necel.com","subject":"Re: git alias and --help","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-28T04:05:57Z","receivedAt":"2011-10-28T04:05:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miles Bader <miles@gnu.org> writes:\n\n> Of course, that would be the wrong thing for somebody that just wants\n> to be reminded what an alias expands too, but my intuition is that\n> this is a very tiny minority compared to people that want to examine\n> the options for the underlying command...\n\nAnd it is doubly wrong if help backend is configured to be anything but\nmanpages, no?\n\nAs I said, you should be able to come up with a patch that detects and\nspecial cases the no frills case (replacement to single token) to get what\nyou want.\n"},{"id":"178401","messageId":"4EAA6F2F.5020301@drmicha.warpmail.net","threadId":"28780","inReplyTo":"7vvcr9wyje.fsf@alter.siamese.dyndns.org","subject":"Re: git alias and --help","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-10-28T09:00:31Z","receivedAt":"2011-10-28T09:00:31Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano venit, vidit, dixit 28.10.2011 06:05:\n> Miles Bader <miles@gnu.org> writes:\n> \n>> Of course, that would be the wrong thing for somebody that just wants\n>> to be reminded what an alias expands too, but my intuition is that\n>> this is a very tiny minority compared to people that want to examine\n>> the options for the underlying command...\n> \n> And it is doubly wrong if help backend is configured to be anything but\n> manpages, no?\n> \n> As I said, you should be able to come up with a patch that detects and\n> special cases the no frills case (replacement to single token) to get what\n> you want.\n\nBut \"help\" is still too much to type for the OP ;) How about this in\nyour config:\n\n[alias]\n\th = help\n\thh = \"!sh -c 'a=$(git config --get alias.$1); : ${a:=$1}; git help\n${a%% *}' -\"\n\nUgly as hell, I know, and works only for aliases whose first word is the\nname of a git command, as well as for non-aliases. Catching \"!command\"\ntype aliases is left as an exercise to the reader.\n\nMichael\n"},{"id":"178403","messageId":"j8ds01$fc7$1@dough.gmane.org","threadId":"28780","inReplyTo":"7vvcr9wyje.fsf@alter.siamese.dyndns.org","subject":"Re: git alias and --help","fromName":"Gelonida N","fromEmail":"gelonida@gmail.com","sentAt":"2011-10-28T09:17:52Z","receivedAt":"2011-10-28T09:17:52Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"On 10/28/2011 06:05 AM, Junio C Hamano wrote:\n> Miles Bader <miles@gnu.org> writes:\n> \n>> Of course, that would be the wrong thing for somebody that just wants\n>> to be reminded what an alias expands too, but my intuition is that\n>> this is a very tiny minority compared to people that want to examine\n>> the options for the underlying command...\n> \n> And it is doubly wrong if help backend is configured to be anything but\n> manpages, no?\n\nWell. Then it is already doubly wrong today, isnt it?\nThe output of 'git help b'\nis not a man page I assume.\n\nIn my opinion chaning it to a short message + the output of a man page\nis not really worse than today's behaviour.\n\n> \n> As I said, you should be able to come up with a patch that detects and\n> special cases the no frills case (replacement to single token) to get what\n> you want.\n\nThat's perhaps the most comfortable one, though occasionally I am even\ninterested in the help text of a git command if I had an alias like\n\nl = log --name-status\n\nto see what other switches I could add\n\n\n(Thus an alternative suggestion to display both or to have a special\nsyntax allowing to force displaying of a man page)\n\n\n\nAnother small detail:\n\nLet's assume I have following alias:\n\nlog = log --name-status\n\n\nIn this case I directly get the help text for git log\nif I typed 'git log --help' (or 'git help log').\nI don't even see, that my log is in reality aliased.\n"},{"id":"178465","messageId":"m362j95jv3.fsf@localhost.localdomain","threadId":"28780","inReplyTo":"buoty6t9937.fsf@dhlpc061.dev.necel.com","subject":"Re: git alias and --help","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-10-28T13:26:04Z","receivedAt":"2011-10-28T13:26:04Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Miles Bader <miles@gnu.org> writes:\n> Junio C Hamano <gitster@pobox.com> writes:\n\n> > > > git branch --help\n> > >\n> > > How about \"git help branch\"?\n> >\n> > The reason why we do not do what you seem to be suggesting is because\n> > giving the same behaviour to \"git b --help\" as \"git branch --help\" is\n> > wrong.\n> \n> I agree with Gelonida's followup:  although what you say makes sense,\n> it's still pretty annoying behavior for the very common case of a\n> simple renaming alias...\n> \n> E.g., I have \"co\" aliased to \"checkout\", and so my fingers are very\n> very inclined to say \"co\" when I mean checkout... including when\n> asking for help.  I actually end up typing \"git co --help\", grumbling,\n> and retyping with the full command name, quite reguarly.\n> \n> What I've often wished is that git's help system would output\n> something like:\n> \n>    $ git help co\n>    `git co' is aliased to `checkout'\n> \n>    Here's the help entry for `checkout':\n> \n>    GIT-CHECKOUT(1)                   Git Manual                   GIT-CHECKOUT(1)\n\nWouldn't it be more useful to say something like this:\n\n  $ git co --help\n  `git co' is aliased to `checkout'\n \n  You can see help entry for `checkout' with \"git checkout --help\"\n\nThen help is only copy'n'paste away.  \n\n(This helping text probably should be controlled by some advice.*\nconfig variable).\n\n\nP.S. I wonder if allowing to run command if you specify unambiguous\nprefix would be a good replacement for such aliases?\n\n-- \nJakub Narębski\n"},{"id":"178466","messageId":"m31utx5js7.fsf@localhost.localdomain","threadId":"28780","inReplyTo":"j8ds01$fc7$1@dough.gmane.org","subject":"Re: git alias and --help","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-10-28T13:27:27Z","receivedAt":"2011-10-28T13:27:27Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Gelonida N <gelonida@gmail.com> writes:\n\n[...]\n\n> Another small detail:\n> \n> Let's assume I have following alias:\n> \n> log = log --name-status\n> \n> \n> In this case I directly get the help text for git log\n> if I typed 'git log --help' (or 'git help log').\n> I don't even see, that my log is in reality aliased.\n\nThat is because it doesn't work: git does not allow for aliasing its\nbuilt-in commands.\n\n-- \nJakub Narębski\n"},{"id":"178478","messageId":"7v62j9t2gj.fsf@alter.siamese.dyndns.org","threadId":"28780","inReplyTo":"m362j95jv3.fsf@localhost.localdomain","subject":"Re: git alias and --help","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-28T18:07:08Z","receivedAt":"2011-10-28T18:07:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n>> What I've often wished is that git's help system would output\n>> something like:\n>> \n>>    $ git help co\n>>    `git co' is aliased to `checkout'\n>> \n>>    Here's the help entry for `checkout':\n>> \n>>    GIT-CHECKOUT(1)                   Git Manual                   GIT-CHECKOUT(1)\n>\n> Wouldn't it be more useful to say something like this:\n>\n>   $ git co --help\n>   `git co' is aliased to `checkout'\n>  \n>   You can see help entry for `checkout' with \"git checkout --help\"\n>\n> Then help is only copy'n'paste away.  \n\nDescribe your algorithm to come up with the equivalent to the above\n'checkout' in this example:\n\n    $ git one --help\n    `git one' is aliased to `!sh -c 'git show -s --pretty=\"format:%h (%s, %ai\" \"$@\" | sed -e \"s/ [012][0-9]:[0-5][0-9]:[0-5][0-9] [-+][0-9][0-9][0-9][0-9]$/)/\"' -'\n\nIf we decide to punt on the '! <cmd>' form, i.e. \"take the first token and\nif it is a git command then do this special thing but otherwise don't make\nthings worse\", then you could improve this example:\n\n    $ git lgf --help\n    'git lgf' is aliased to 'log --oneline --boundary --first-parent'\n\nwith \"git log --help\", but that is aiming too low for my taste.\n\nIf you are redesigning the help system, isn't it a shame that you are\ndiscarding other tokens in the alias when giving help? Wouldn't it be\nwonderful if you extracted the option descriptions for these three options\nspecified and showing only that, for example?\n\nYou would need to ensure that the manual pages for all commands share the\nsame structure to make that happen, which goes without saying.\n"},{"id":"178481","messageId":"CADCnXoaPbCK0B=XZwdAY=yEb61YhvyQ6FA=BAxkADJ6hra-_Lg@mail.gmail.com","threadId":"28780","inReplyTo":"7v62j9t2gj.fsf@alter.siamese.dyndns.org","subject":"Re: git alias and --help","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2011-10-28T18:25:09Z","receivedAt":"2011-10-28T18:25:09Z","isPatch":false,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"2011/10/29 Junio C Hamano <gitster@pobox.com>:\n>    $ git lgf --help\n>    'git lgf' is aliased to 'log --oneline --boundary --first-parent'\n>\n> with \"git log --help\", but that is aiming too low for my taste.\n>\n> If you are redesigning the help system, isn't it a shame that you are\n> discarding other tokens in the alias when giving help? Wouldn't it be\n> wonderful if you extracted the option descriptions for these three options\n> specified and showing only that, for example?\n\nI think that would be the wrong thing in most cases though:  an alias\nlike the above happily allows the user to specify other git-log\noptions on the command line; when I get help on an aliased option,\nit's often precisely because I want to see the _other_ options I can\nuse...\n\nE.g., I have:\n\n   $ git slog --help\n   `git slog' is aliased to `log --date=short --pretty=tformat:\"%h\n%ad  %s\" --abbrev-commit'\n\nBut the typical question I want to answer is something like \"OK, how\ndo I reverse the output order of slog?\" or \"how do I limit the output\nof slog to a certain date range?\"\n\n-miles\n\n-- \nCat is power.  Cat is peace.\n"},{"id":"178487","messageId":"j8f2rr$ghe$1@dough.gmane.org","threadId":"28780","inReplyTo":"m31utx5js7.fsf@localhost.localdomain","subject":"Re: git alias and --help","fromName":"Gelonida N","fromEmail":"gelonida@gmail.com","sentAt":"2011-10-28T20:21:15Z","receivedAt":"2011-10-28T20:21:15Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"On 10/28/2011 03:27 PM, Jakub Narebski wrote:\n> Gelonida N <gelonida@gmail.com> writes:\n> \n> [...]\n> \n>> Another small detail:\n>>\n>> Let's assume I have following alias:\n>>\n>> log = log --name-status\n>>\n>>\n>> In this case I directly get the help text for git log\n>> if I typed 'git log --help' (or 'git help log').\n>> I don't even see, that my log is in reality aliased.\n> \n> That is because it doesn't work: git does not allow for aliasing its\n> built-in commands.\n\n\nWell this explains why.\nThanks\n"},{"id":"178488","messageId":"j8f30u$ghe$2@dough.gmane.org","threadId":"28780","inReplyTo":"m362j95jv3.fsf@localhost.localdomain","subject":"Re: git alias and --help","fromName":"Gelonida N","fromEmail":"gelonida@gmail.com","sentAt":"2011-10-28T20:23:58Z","receivedAt":"2011-10-28T20:23:58Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"On 10/28/2011 03:26 PM, Jakub Narebski wrote:\n> Miles Bader <miles@gnu.org> writes:\n>> Junio C Hamano <gitster@pobox.com> writes:\n> \n>>>>> git branch --help\n>>>>\n>>>> How about \"git help branch\"?\n>>>\n>>> The reason why we do not do what you seem to be suggesting is because\n>>> giving the same behaviour to \"git b --help\" as \"git branch --help\" is\n>>> wrong.\n>>\n>> I agree with Gelonida's followup:  although what you say makes sense,\n>> it's still pretty annoying behavior for the very common case of a\n>> simple renaming alias...\n>>\n>> E.g., I have \"co\" aliased to \"checkout\", and so my fingers are very\n>> very inclined to say \"co\" when I mean checkout... including when\n>> asking for help.  I actually end up typing \"git co --help\", grumbling,\n>> and retyping with the full command name, quite reguarly.\n>>\n>> What I've often wished is that git's help system would output\n>> something like:\n>>\n>>    $ git help co\n>>    `git co' is aliased to `checkout'\n>>\n>>    Here's the help entry for `checkout':\n>>\n>>    GIT-CHECKOUT(1)                   Git Manual                   GIT-CHECKOUT(1)\n> \n> Wouldn't it be more useful to say something like this:\n> \n>   $ git co --help\n>   `git co' is aliased to `checkout'\n>  \n>   You can see help entry for `checkout' with \"git checkout --help\"\n> \n> Then help is only copy'n'paste away.  \n> \n> (This helping text probably should be controlled by some advice.*\n> config variable).\n\nThis is definitely an option and something which I suggested as one\noption myself (however my example had a typo and was perhaps therefore\nnot understandable)\n"}]}