{"thread":{"id":"39445","subject":"Redirect \"git\" subcommand to itself?","startedAt":"2015-05-28T00:28:34Z","lastAt":"2015-05-29T16:49:22Z","messageCount":11,"participants":["Stefan Beller","Junio C Hamano","Jeff King","Konstantin Khomoutov","Matthieu Moy","Christian Neukirchen","Aaron Schrab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"262302","messageId":"CAGZ79kZHa9wUrRsWfHgGdSdx+cN9VAirAAfu3YLVTuSmggcehg@mail.gmail.com","threadId":"39445","inReplyTo":null,"subject":"Redirect \"git\" subcommand to itself?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-05-28T00:28:34Z","receivedAt":"2015-05-28T00:28:34Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Hi,\n\nso I just run into this problem again (which happens to me maybe twice a week):\nI want to do a git operations, so I type \"git \" into my shell, and\nthen I look around what\nexactly I want to do and usually I find it in the help text of a\nprevious command such as\n    You are currently reverting commit 383c14b.\n      (fix conflicts and run \"git revert --continue\")\n      (use \"git revert --abort\" to cancel the revert operation)\n\nthen I copy the whole operation \"git revert --abort\" in this case and\npaste it to the shell\nand let go.\nThe result looks like\n    $ git git revert --abort\n    git: 'git' is not a git command. See 'git --help'.\n\n    Did you mean this?\n    init\n\nI wonder if we want to make a \"git\" subcommand, which behaves exactly\nthe same as git itself?\nThen \"git git git status\" would just return the same as \"git status\".\n\nThanks,\nStefan\n"},{"id":"262304","messageId":"xmqqoal5ii21.fsf@gitster.dls.corp.google.com","threadId":"39445","inReplyTo":"CAGZ79kZHa9wUrRsWfHgGdSdx+cN9VAirAAfu3YLVTuSmggcehg@mail.gmail.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-28T01:53:26Z","receivedAt":"2015-05-28T01:53:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> so I just run into this problem again (which happens to me maybe twice a week):\n> I want to do a git operations, so I type \"git \" into my shell, and\n> then I look around what\n> exactly I want to do and usually I find it in the help text of a\n> previous command such as\n>     You are currently reverting commit 383c14b.\n>       (fix conflicts and run \"git revert --continue\")\n>       (use \"git revert --abort\" to cancel the revert operation)\n>\n> then I copy the whole operation \"git revert --abort\" in this case and\n> paste it to the shell\n> and let go.\n> The result looks like\n>     $ git git revert --abort\n>     git: 'git' is not a git command. See 'git --help'.\n>\n>     Did you mean this?\n>     init\n>\n> I wonder if we want to make a \"git\" subcommand, which behaves exactly\n> the same as git itself?\n> Then \"git git git status\" would just return the same as \"git status\".\n\nA few unrelated thoughts.\n\n * Perhaps we should omit 'git' from these advice-texts?  E.g.\n\n     use \"revert --abort\" to cancel\n\n   I dunno.\n\n * While we bend over backwards to a certain degree to be helpful, I\n   somehow feel making \"git git\" a synonym to \"git\" is going too\n   far, akin to asking POSIX maintainers to define \"act\", \"cta\",\n   \"atc\", \"tca\", and \"tac\" all as synonyms to \"cat\" because you\n   often fat-finger when typing \"cat\" (yes, \"tac\" does something\n   else that is more useful, I know).\n\n * You can help yourself with something like this, I suppose:\n\n   [alias]\n\tgit = \"!sh -c 'exec git \\\"$@\\\"' -\"\n\n   but I personally feel that it is too ugly to live as part of our\n   official suggestion, so please do not send a patch to add it as\n   a built-in alias ;-).\n"},{"id":"262305","messageId":"20150528052227.GA24895@peff.net","threadId":"39445","inReplyTo":"xmqqoal5ii21.fsf@gitster.dls.corp.google.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-05-28T05:22:27Z","receivedAt":"2015-05-28T05:22:27Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 27, 2015 at 06:53:26PM -0700, Junio C Hamano wrote:\n\n> > I wonder if we want to make a \"git\" subcommand, which behaves exactly\n> > the same as git itself?\n> > Then \"git git git status\" would just return the same as \"git status\".\n> \n> A few unrelated thoughts.\n> \n>  * Perhaps we should omit 'git' from these advice-texts?  E.g.\n> \n>      use \"revert --abort\" to cancel\n> \n>    I dunno.\n\nPlease don't. You help the set of people who type \"git\" and then paste\nthe rest of the command at the expense of people who just  paste the\nwhole command. We don't know the relative numbers of those people, but\nwe know there is at least 1 in each group. ;)\n\n-Peff\n"},{"id":"262317","messageId":"20150528133625.bfececc222a4820e9fb27aaa@domain007.com","threadId":"39445","inReplyTo":"CAGZ79kZHa9wUrRsWfHgGdSdx+cN9VAirAAfu3YLVTuSmggcehg@mail.gmail.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Konstantin Khomoutov","fromEmail":"kostix+git@007spb.ru","sentAt":"2015-05-28T10:36:25Z","receivedAt":"2015-05-28T10:36:25Z","isPatch":false,"sender":{"key":"kostix+git@007spb.ru","avatar":null},"body":"On Wed, 27 May 2015 17:28:34 -0700\nStefan Beller <sbeller@google.com> wrote:\n\n> so I just run into this problem again (which happens to me maybe\n> twice a week): I want to do a git operations, so I type \"git \" into\n> my shell,\n[...]\n> then I copy the whole operation \"git revert --abort\" in this case and\n> paste it to the shell and let go.\n> The result looks like\n>     $ git git revert --abort\n>     git: 'git' is not a git command. See 'git --help'.\n[...]\n> I wonder if we want to make a \"git\" subcommand, which behaves exactly\n> the same as git itself?\n> Then \"git git git status\" would just return the same as \"git status\".\n\nIn your ~/.whateverrc, put this:\n\ngit() {\n  while [ $# -gt 0 ]; do\n    test \"$1\" != \"git\" && break;\n    shift;\n  done;\n  command git $@;\n}\n\nThis assumes a POSIX-compatible shell but I think you've got the idea.\n(\"command\" is a builtin which forces interpreting the following word as\nthe name of an external program.)\n"},{"id":"262329","messageId":"vpqegm0onii.fsf@anie.imag.fr","threadId":"39445","inReplyTo":"CAGZ79kZHa9wUrRsWfHgGdSdx+cN9VAirAAfu3YLVTuSmggcehg@mail.gmail.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-05-28T13:11:17Z","receivedAt":"2015-05-28T13:11:17Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> so I just run into this problem again (which happens to me maybe twice\n> a week):\n> I want to do a git operations, so I type \"git \" into my shell, and\n> then [...] I copy the whole operation \"git revert --abort\" in this case and\n> paste it to the shell\n\nOn my side, that wouldn't be twice a week, but I often do the same\nmistake. I find your idea for a solution conceptually ugly but\npractically very convenient ;-), so I'd be in favor of doing it.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"262397","messageId":"87zj4n4w3t.fsf@gmail.com","threadId":"39445","inReplyTo":"xmqqoal5ii21.fsf@gitster.dls.corp.google.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Christian Neukirchen","fromEmail":"chneukirchen@gmail.com","sentAt":"2015-05-29T08:38:14Z","receivedAt":"2015-05-29T08:38:14Z","isPatch":false,"sender":{"key":"chneukirchen@gmail.com","avatar":"https://avatars.githubusercontent.com/u/139?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>  * You can help yourself with something like this, I suppose:\n>\n>    [alias]\n> \tgit = \"!sh -c 'exec git \\\"$@\\\"' -\"\n>\n>    but I personally feel that it is too ugly to live as part of our\n>    official suggestion, so please do not send a patch to add it as\n>    a built-in alias ;-).\n\nSo I thought I was clever, but this didn't work:\n\n% ln -s /usr/bin/git ~/bin/git-git  \n% git git\nfatal: cannot handle git as a builtin\n\n-- \nChristian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org\n"},{"id":"262421","messageId":"20150529132453.GA1308@pug.qqx.org","threadId":"39445","inReplyTo":"87zj4n4w3t.fsf@gmail.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Aaron Schrab","fromEmail":"aaron@schrab.com","sentAt":"2015-05-29T13:24:53Z","receivedAt":"2015-05-29T13:24:53Z","isPatch":false,"sender":{"key":"aaron@schrab.com","avatar":"https://avatars.githubusercontent.com/u/39620?v=4"},"body":"At 10:38 +0200 29 May 2015, Christian Neukirchen <chneukirchen@gmail.com> wrote:\n>Junio C Hamano <gitster@pobox.com> writes:\n>\n>>  * You can help yourself with something like this, I suppose:\n>>\n>>    [alias]\n>> \tgit = \"!sh -c 'exec git \\\"$@\\\"' -\"\n>>\n>>    but I personally feel that it is too ugly to live as part of our\n>>    official suggestion, so please do not send a patch to add it as\n>>    a built-in alias ;-).\n>\n>So I thought I was clever, but this didn't work:\n\nI've done the same as the original poster a few times myself, so awhile \nago I added the following to my .gitconfig file:\n\n[alias]\n    git         = \"!f() { git $@; }; f\"\n\nAnd this has worked for me.\n"},{"id":"262426","messageId":"xmqqsiafe6md.fsf@gitster.dls.corp.google.com","threadId":"39445","inReplyTo":"87zj4n4w3t.fsf@gmail.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-29T15:38:34Z","receivedAt":"2015-05-29T15:38:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Neukirchen <chneukirchen@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>>  * You can help yourself with something like this, I suppose:\n>>\n>>    [alias]\n>> \tgit = \"!sh -c 'exec git \\\"$@\\\"' -\"\n>>\n>>    but I personally feel that it is too ugly to live as part of our\n>>    official suggestion, so please do not send a patch to add it as\n>>    a built-in alias ;-).\n>\n> So I thought I was clever, but this didn't work:\n>\n> % ln -s /usr/bin/git ~/bin/git-git  \n> % git git\n> fatal: cannot handle git as a builtin\n\nWhy did you have to do that when I already gave an alias that works?\n\nOr didn't the alias work?\n"},{"id":"262430","messageId":"CAGZ79kbOCUDVUT_WFQUNppD6QLr=kUUpZbuGi13ot=j_D7Zf8w@mail.gmail.com","threadId":"39445","inReplyTo":"xmqqsiafe6md.fsf@gitster.dls.corp.google.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-05-29T16:00:20Z","receivedAt":"2015-05-29T16:00:20Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Thanks a lot for the discussion!\nSo I'll just fix it locally for me and we keep the state as is.\n"},{"id":"262436","messageId":"87r3pz49r5.fsf@gmail.com","threadId":"39445","inReplyTo":"xmqqsiafe6md.fsf@gitster.dls.corp.google.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Christian Neukirchen","fromEmail":"chneukirchen@gmail.com","sentAt":"2015-05-29T16:41:02Z","receivedAt":"2015-05-29T16:41:02Z","isPatch":false,"sender":{"key":"chneukirchen@gmail.com","avatar":"https://avatars.githubusercontent.com/u/139?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Christian Neukirchen <chneukirchen@gmail.com> writes:\n>\n>> Junio C Hamano <gitster@pobox.com> writes:\n>>\n>>>  * You can help yourself with something like this, I suppose:\n>>>\n>>>    [alias]\n>>> \tgit = \"!sh -c 'exec git \\\"$@\\\"' -\"\n>>>\n>>>    but I personally feel that it is too ugly to live as part of our\n>>>    official suggestion, so please do not send a patch to add it as\n>>>    a built-in alias ;-).\n>>\n>> So I thought I was clever, but this didn't work:\n>>\n>> % ln -s /usr/bin/git ~/bin/git-git  \n>> % git git\n>> fatal: cannot handle git as a builtin\n>\n> Why did you have to do that when I already gave an alias that works?\n\nI was just toying around, and it would have been cute.\n\n> Or didn't the alias work?\n\nIt does.  This seems to work just as well, and is easier:\n\n\tgit = !git\n\nThanks,\n-- \nChristian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org\n"},{"id":"262438","messageId":"xmqq1thze3cd.fsf@gitster.dls.corp.google.com","threadId":"39445","inReplyTo":"87r3pz49r5.fsf@gmail.com","subject":"Re: Redirect \"git\" subcommand to itself?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-29T16:49:22Z","receivedAt":"2015-05-29T16:49:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Neukirchen <chneukirchen@gmail.com> writes:\n\n> I was just toying around, and it would have been cute.\n>\n>> Or didn't the alias work?\n>\n> It does.  This seems to work just as well, and is easier:\n\nThanks; I was wondering if I gave something that was not portable or\nsomething.\n\n> \tgit = !git\n\nI'd call that the ultimate cuteness.\n\nWe have a winner ;-) ;-) ;-).\n"}]}