{"thread":{"id":"45326","subject":"[PATCH] Allow \"-\" as a short-hand for \"@{-1}\" in branch deletions","startedAt":"2017-03-09T03:31:11Z","lastAt":"2017-03-10T06:08:38Z","messageCount":6,"participants":["Shuyang Shi","Stefan Beller","Siddharth Kannan"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"313608","messageId":"0102015ab11e8237-01e52ffe-882f-4589-8886-2c0b231ac3c6-000000@eu-west-1.amazonses.com","threadId":"45326","inReplyTo":null,"subject":"[PATCH] Allow \"-\" as a short-hand for \"@{-1}\" in branch deletions","fromName":"Shuyang Shi","fromEmail":"shuyang790@gmail.com","sentAt":"2017-03-09T03:30:51Z","receivedAt":"2017-03-09T03:31:11Z","isPatch":true,"sender":{"key":"shuyang790@gmail.com","avatar":null},"body":"The \"-\" shorthand that stands for \"the branch we were previously on\",\nlike we did for \"git merge -\" sometime after we introduced \"git checkout -\".\nNow I am introducing this shorthand to branch delete, i.e.\n\"git branch -d -\".\n\nMore reference:\n  https://public-inbox.org/git/7vppuewl6h.fsf@alter.siamese.dyndns.org/\n\nAnd this has been tested:\n\n\tIvan:git Ivan$ (cd t; prove --timer --jobs 1 ./t3200-branch.sh)\n\t[00:21:26] ./t3200-branch.sh .. ok    12293 ms ( 0.04 usr  0.01 sys +\n\t5.97 cusr  2.52 csys =  8.54 CPU)\n\t[00:21:39]\n\tAll tests successful.\n\tFiles=1, Tests=113, 13 wallclock secs ( 0.07 usr  0.02 sys +\n\t5.97 cusr  2.52 csys =  8.58 CPU)\n\tResult: PASS\n\nSigned-off-by: Shuyang Shi <shuyang790@gmail.com>\n---\n builtin/branch.c | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 94f7de7f..1b72d80 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -215,8 +215,12 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \tfor (i = 0; i < argc; i++, strbuf_release(&bname)) {\n \t\tchar *target = NULL;\n \t\tint flags = 0;\n+\t\tconst char *arg = argv[i];\n \n-\t\tstrbuf_branchname(&bname, argv[i]);\n+\t\tif (!strcmp(arg, \"-\"))\n+\t\t\targ = \"@{-1}\";\n+\n+\t\tstrbuf_branchname(&bname, arg);\n \t\tfree(name);\n \t\tname = mkpathdup(fmt, bname.buf);\n \n\n--\nhttps://github.com/git/git/pull/337\n"},{"id":"313609","messageId":"0102015ab11ee091-f9f11bb5-559a-4c92-b5f6-9f7755e8f4b9-000000@eu-west-1.amazonses.com","threadId":"45326","inReplyTo":"0102015ab11e8237-01e52ffe-882f-4589-8886-2c0b231ac3c6-000000@eu-west-1.amazonses.com","subject":"[PATCH GSoC] Allow \"-\" as a short-hand for \"@{-1}\" in branch deletions","fromName":"Shuyang Shi","fromEmail":"shuyang790@gmail.com","sentAt":"2017-03-09T03:31:15Z","receivedAt":"2017-03-09T03:31:21Z","isPatch":true,"sender":{"key":"shuyang790@gmail.com","avatar":null},"body":"The \"-\" shorthand that stands for \"the branch we were previously on\",\nlike we did for \"git merge -\" sometime after we introduced \"git checkout -\".\nNow I am introducing this shorthand to branch delete, i.e.\n\"git branch -d -\".\n\nMore reference:\n  https://public-inbox.org/git/7vppuewl6h.fsf@alter.siamese.dyndns.org/\n\nAnd this has been tested:\n\n\tIvan:git Ivan$ (cd t; prove --timer --jobs 1 ./t3200-branch.sh)\n\t[00:21:26] ./t3200-branch.sh .. ok    12293 ms ( 0.04 usr  0.01 sys +\n\t5.97 cusr  2.52 csys =  8.54 CPU)\n\t[00:21:39]\n\tAll tests successful.\n\tFiles=1, Tests=113, 13 wallclock secs ( 0.07 usr  0.02 sys +\n\t5.97 cusr  2.52 csys =  8.58 CPU)\n\tResult: PASS\n\nSigned-off-by: Shuyang Shi <shuyang790@gmail.com>\n---\n builtin/branch.c | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 94f7de7f..1b72d80 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -215,8 +215,12 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \tfor (i = 0; i < argc; i++, strbuf_release(&bname)) {\n \t\tchar *target = NULL;\n \t\tint flags = 0;\n+\t\tconst char *arg = argv[i];\n \n-\t\tstrbuf_branchname(&bname, argv[i]);\n+\t\tif (!strcmp(arg, \"-\"))\n+\t\t\targ = \"@{-1}\";\n+\n+\t\tstrbuf_branchname(&bname, arg);\n \t\tfree(name);\n \t\tname = mkpathdup(fmt, bname.buf);\n \n\n--\nhttps://github.com/git/git/pull/337\n"},{"id":"313652","messageId":"CAGZ79kYUkQ4u9zX=qXL_+ip74mi3DgbzGiJNxybrVYbr3m1U=A@mail.gmail.com","threadId":"45326","inReplyTo":"0102015ab11ee091-f9f11bb5-559a-4c92-b5f6-9f7755e8f4b9-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH GSoC] Allow \"-\" as a short-hand for \"@{-1}\" in branch deletions","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-03-09T17:47:12Z","receivedAt":"2017-03-09T17:49:08Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Welcome to the Git community!\n\nOn Wed, Mar 8, 2017 at 7:31 PM, Shuyang Shi <shuyang790@gmail.com> wrote:\n> The \"-\" shorthand that stands for \"the branch we were previously on\",\n> like we did for \"git merge -\" sometime after we introduced \"git checkout -\".\n> Now I am introducing this shorthand to branch delete, i.e.\n> \"git branch -d -\".\n>\n> More reference:\n>   https://public-inbox.org/git/7vppuewl6h.fsf@alter.siamese.dyndns.org/\n\nFollowing that link:\n\n> But there is a very commonly accepted long tradition for \"-\" to mean\n> \"read from the standard input\", so we cannot reuse it to mean \"the\n> branch I was previously on\" for every command without first making\n> sure the command will never want to use \"-\" for the other common\n> purpose.\n\nThis contradicts the introduction of \"git branch -d -\" to mean to delete\nthe last branch, but rather could mean \"read from stdin which branches\nto delete\"? It would be nice if you could clarify in your commit message\nwhich of both this is and how this fits into the big picture of \"design\ncleanliness\".\n\n>\n> And this has been tested:\n>\n>         Ivan:git Ivan$ (cd t; prove --timer --jobs 1 ./t3200-branch.sh)\n>         [00:21:26] ./t3200-branch.sh .. ok    12293 ms ( 0.04 usr  0.01 sys +\n>         5.97 cusr  2.52 csys =  8.54 CPU)\n>         [00:21:39]\n>         All tests successful.\n>         Files=1, Tests=113, 13 wallclock secs ( 0.07 usr  0.02 sys +\n>         5.97 cusr  2.52 csys =  8.58 CPU)\n>         Result: PASS\n\nThanks for being cautious when developing on Git. However this part\nof the email would end up as part of the commit message. And as we expect\nall commits that land eventually to not break tests, this information is better\nput at a more non-permanent place, such as below the '---' line (where there is\nalso the built stat. For example see [1] how to have different message parts\n(one permanent section and some chatter that is relevant for the process\nat the moment)\n\nAlso for testing, the tests only ensure that the old behavior does not break;\nbut we'd want to make sure the new functionality doesn't break in the\nfuture either,\nwhich can be done best by writing a test as well for this functionality.\n\n[1] https://public-inbox.org/git/xmqqvarj1kix.fsf_-_@gitster.mtv.corp.google.com/\nand as a commit:\nhttps://github.com/gitster/git/commit/83218867fbf6d27c78efe3cfba01790b2f1d15d4\n\n> https://github.com/git/git/pull/337\n\nOh I see, you're using submitgit to communicate the patch to the mailing list.\nI am not sure if it supports splitting up the message as I eluded to above.\nIIRC some people use submitgit for the patch and then use a webmailer\n(e.g. gmail) to send followup messages such as successful tests or what changed\nto prior versions.\n\nThanks,\nStefan\n"},{"id":"313730","messageId":"20170310033058.GA1984@instance-1.c.mfqp-source.internal","threadId":"45326","inReplyTo":"0102015ab11ee091-f9f11bb5-559a-4c92-b5f6-9f7755e8f4b9-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH GSoC] Allow \"-\" as a short-hand for \"@{-1}\" in branch deletions","fromName":"Siddharth Kannan","fromEmail":"kannan.siddharth12@gmail.com","sentAt":"2017-03-10T03:30:58Z","receivedAt":"2017-03-10T03:31:06Z","isPatch":true,"sender":{"key":"kannan.siddharth12@gmail.com","avatar":"https://gravatar.com/avatar/f555b34abc9cec49fd7e7ca4a55b58be0e0af0fc58e75b7887210199b7d4ca5a?d=mp&s=160"},"body":"Hey Shuyang,\nOn Thu, Mar 09, 2017 at 09:47:12AM -0800, Stefan Beller wrote:\n> > The \"-\" shorthand that stands for \"the branch we were previously on\",\n> > like we did for \"git merge -\" sometime after we introduced \"git checkout -\".\n> > Now I am introducing this shorthand to branch delete, i.e.\n> > \"git branch -d -\".\n> >\n> > More reference:\n> >   https://public-inbox.org/git/7vppuewl6h.fsf@alter.siamese.dyndns.org/\n> \n\n1. I have already worked on this project, and my patch is in the\n\"Needs review\" section in \"What's cooking\". It implements this change\ninside sha1_name.c and doesn't touch git branch. So, your patch is\nmutually exclusive to my previous patch.\n\n2. Matthieu made an argument against enabling commands like \"git\nbranch -D -\" even by mistake [1]. The way that I have implemented\nensured that not a lot of \"rm\"-like commands were enabled.\n\nMy patch that would enable this shorthand for other projects is\nhere[2].\n\n[1]: http://public-inbox.org/git/vpqh944eof7.fsf@anie.imag.fr/\n[2]: http://public-inbox.org/git/1488007487-12965-5-git-send-email-kannan.siddharth12@gmail.com/\n\nThanks,\nSiddharth.\n"},{"id":"313734","messageId":"CAE9=6bpVs5bqTgzt1uLDYsF2-Mtx3mgfEZB_ag2VzMg7MmmwYQ@mail.gmail.com","threadId":"45326","inReplyTo":"20170310033058.GA1984@instance-1.c.mfqp-source.internal","subject":"Re: [PATCH GSoC] Allow \"-\" as a short-hand for \"@{-1}\" in branch deletions","fromName":"Shuyang Shi","fromEmail":"shuyang790@gmail.com","sentAt":"2017-03-10T06:07:57Z","receivedAt":"2017-03-10T06:08:20Z","isPatch":true,"sender":{"key":"shuyang790@gmail.com","avatar":null},"body":"Hey Siddharth,\n\nIt is good to know that you have been working on this, and sorry for\nthis \"bump\".\nAlthough I see \"git branch -d -\" not so dangerous, it is okay for me that we\nkeep it out of the shorthand range.\n\nAnd your work is awesome.\n\nThanks,\nShuyang\n史舒扬 Shuyang Shi\nUndergraduate\nDepartment of CS, School of EECS, Peking University\nEmail: shuyang790@gmail.com\nMobile: +86-18301336991\n\n\nOn Fri, Mar 10, 2017 at 11:30 AM, Siddharth Kannan\n<kannan.siddharth12@gmail.com> wrote:\n> Hey Shuyang,\n> On Thu, Mar 09, 2017 at 09:47:12AM -0800, Stefan Beller wrote:\n>> > The \"-\" shorthand that stands for \"the branch we were previously on\",\n>> > like we did for \"git merge -\" sometime after we introduced \"git checkout -\".\n>> > Now I am introducing this shorthand to branch delete, i.e.\n>> > \"git branch -d -\".\n>> >\n>> > More reference:\n>> >   https://public-inbox.org/git/7vppuewl6h.fsf@alter.siamese.dyndns.org/\n>>\n>\n> 1. I have already worked on this project, and my patch is in the\n> \"Needs review\" section in \"What's cooking\". It implements this change\n> inside sha1_name.c and doesn't touch git branch. So, your patch is\n> mutually exclusive to my previous patch.\n>\n> 2. Matthieu made an argument against enabling commands like \"git\n> branch -D -\" even by mistake [1]. The way that I have implemented\n> ensured that not a lot of \"rm\"-like commands were enabled.\n>\n> My patch that would enable this shorthand for other projects is\n> here[2].\n>\n> [1]: http://public-inbox.org/git/vpqh944eof7.fsf@anie.imag.fr/\n> [2]: http://public-inbox.org/git/1488007487-12965-5-git-send-email-kannan.siddharth12@gmail.com/\n>\n> Thanks,\n> Siddharth.\n"},{"id":"313735","messageId":"CAE9=6briC+CW+yqpn-r_QbQmZq-oy-hQJ9DNhBkxd_A1FSquyw@mail.gmail.com","threadId":"45326","inReplyTo":"CAGZ79kYUkQ4u9zX=qXL_+ip74mi3DgbzGiJNxybrVYbr3m1U=A@mail.gmail.com","subject":"Re: [PATCH GSoC] Allow \"-\" as a short-hand for \"@{-1}\" in branch deletions","fromName":"Shuyang Shi","fromEmail":"shuyang790@gmail.com","sentAt":"2017-03-10T06:08:32Z","receivedAt":"2017-03-10T06:08:38Z","isPatch":true,"sender":{"key":"shuyang790@gmail.com","avatar":null},"body":"Hi Stefan,\n\nReally appreciate your help on this, but I guess I am cancelling this\npatch for Siddharth's.\n\nThanks,\nShuyang\n史舒扬 Shuyang Shi\nUndergraduate\nDepartment of CS, School of EECS, Peking University\nEmail: shuyang790@gmail.com\nMobile: +86-18301336991\n\n\nOn Fri, Mar 10, 2017 at 1:47 AM, Stefan Beller <sbeller@google.com> wrote:\n> Welcome to the Git community!\n>\n> On Wed, Mar 8, 2017 at 7:31 PM, Shuyang Shi <shuyang790@gmail.com> wrote:\n>> The \"-\" shorthand that stands for \"the branch we were previously on\",\n>> like we did for \"git merge -\" sometime after we introduced \"git checkout -\".\n>> Now I am introducing this shorthand to branch delete, i.e.\n>> \"git branch -d -\".\n>>\n>> More reference:\n>>   https://public-inbox.org/git/7vppuewl6h.fsf@alter.siamese.dyndns.org/\n>\n> Following that link:\n>\n>> But there is a very commonly accepted long tradition for \"-\" to mean\n>> \"read from the standard input\", so we cannot reuse it to mean \"the\n>> branch I was previously on\" for every command without first making\n>> sure the command will never want to use \"-\" for the other common\n>> purpose.\n>\n> This contradicts the introduction of \"git branch -d -\" to mean to delete\n> the last branch, but rather could mean \"read from stdin which branches\n> to delete\"? It would be nice if you could clarify in your commit message\n> which of both this is and how this fits into the big picture of \"design\n> cleanliness\".\n>\n>>\n>> And this has been tested:\n>>\n>>         Ivan:git Ivan$ (cd t; prove --timer --jobs 1 ./t3200-branch.sh)\n>>         [00:21:26] ./t3200-branch.sh .. ok    12293 ms ( 0.04 usr  0.01 sys +\n>>         5.97 cusr  2.52 csys =  8.54 CPU)\n>>         [00:21:39]\n>>         All tests successful.\n>>         Files=1, Tests=113, 13 wallclock secs ( 0.07 usr  0.02 sys +\n>>         5.97 cusr  2.52 csys =  8.58 CPU)\n>>         Result: PASS\n>\n> Thanks for being cautious when developing on Git. However this part\n> of the email would end up as part of the commit message. And as we expect\n> all commits that land eventually to not break tests, this information is better\n> put at a more non-permanent place, such as below the '---' line (where there is\n> also the built stat. For example see [1] how to have different message parts\n> (one permanent section and some chatter that is relevant for the process\n> at the moment)\n>\n> Also for testing, the tests only ensure that the old behavior does not break;\n> but we'd want to make sure the new functionality doesn't break in the\n> future either,\n> which can be done best by writing a test as well for this functionality.\n>\n> [1] https://public-inbox.org/git/xmqqvarj1kix.fsf_-_@gitster.mtv.corp.google.com/\n> and as a commit:\n> https://github.com/gitster/git/commit/83218867fbf6d27c78efe3cfba01790b2f1d15d4\n>\n>> https://github.com/git/git/pull/337\n>\n> Oh I see, you're using submitgit to communicate the patch to the mailing list.\n> I am not sure if it supports splitting up the message as I eluded to above.\n> IIRC some people use submitgit for the patch and then use a webmailer\n> (e.g. gmail) to send followup messages such as successful tests or what changed\n> to prior versions.\n>\n> Thanks,\n> Stefan\n"}]}