{"thread":{"id":"24778","subject":"[PATCH] Do not display 'Switched to a new branch' when the branch existed","startedAt":"2010-08-18T08:28:26Z","lastAt":"2010-08-25T11:51:31Z","messageCount":10,"participants":["Knittl","Jonathan Nieder","Tay Ray Chuan","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"148343","messageId":"AANLkTimaZF1Q6BPB7CN0Wa5-Ov2ejVfPsmL34vps2VqK@mail.gmail.com","threadId":"24778","inReplyTo":null,"subject":"[PATCH] Do not display 'Switched to a new branch' when the branch existed","fromName":"Knittl","fromEmail":"knittl89@googlemail.com","sentAt":"2010-08-18T08:28:26Z","receivedAt":"2010-08-18T08:28:26Z","isPatch":true,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"From cc6410b89b85822aadc5a7843b7398209957e549 Mon Sep 17 00:00:00 2001\nFrom: Tay Ray Chuan <rctay89@gmail.com>\nDate: Thu, 24 Jun 2010 03:29:00 +0800\nSubject: [PATCH] builtin/checkout: fix info message for `git checkout <branch>`\n\nSince 02ac98374eefbe4a46d4b53a8a78057ad8ad39b7 `git checkout` would\nalways display 'Switched to a new branch <branch>` even if the branch\nhad already existed.\n\nSigned-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n---\n\ngit checkout should only display 'Switched to a new branch <branch>'\nwhen it creates a new branch, not when it simply switches branches.\n\nps. I'm not sure about the style used in git for nested ternary\nstatements (if they should even be used …)\n\n builtin/checkout.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 4ad7427..ed7cde1 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -536,7 +536,9 @@ static void update_refs_for_switch(struct\ncheckout_opts *opts,\n \t\t\t\t\tnew->name);\n \t\t\telse\n \t\t\t\tfprintf(stderr, \"Switched to%s branch '%s'\\n\",\n-\t\t\t\t\topts->branch_exists ? \" and reset\" : \" a new\",\n+\t\t\t\t\topts->branch_exists\n+\t\t\t\t\t\t? \" and reset\"\n+\t\t\t\t\t\t: opts->new_branch ? \" a new\" : \"\",\n \t\t\t\t\tnew->name);\n \t\t}\n \t\tif (old->path && old->name) {\n-- \n1.7.1.574.g421e3\n"},{"id":"148344","messageId":"AANLkTi=3z9gJdT8LL3NANFyppUjvOVcrszjf5J5zAKPe@mail.gmail.com","threadId":"24778","inReplyTo":"AANLkTimaZF1Q6BPB7CN0Wa5-Ov2ejVfPsmL34vps2VqK@mail.gmail.com","subject":"[PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Knittl","fromEmail":"knittl89@googlemail.com","sentAt":"2010-08-18T08:38:04Z","receivedAt":"2010-08-18T08:38:04Z","isPatch":true,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"From 16f540c87f8c7b87692dfd488d507802ae975312 Mon Sep 17 00:00:00 2001\nFrom: Daniel Knittl-Frank <knittl89+git@googlemail.com>\nDate: Wed, 18 Aug 2010 10:35:42 +0200\nSubject: [PATCH] builtin/checkout: fix info message for `git checkout <branch>`\n\nSince 02ac98374eefbe4a46d4b53a8a78057ad8ad39b7 `git checkout` would\nalways display 'Switched to a new branch <branch>` even if the branch\nhad already existed.\n\nSigned-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n---\n\nstupid me, i forgot to reset author in re-used commit …\n\n builtin/checkout.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 4ad7427..ed7cde1 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -536,7 +536,9 @@ static void update_refs_for_switch(struct\ncheckout_opts *opts,\n \t\t\t\t\tnew->name);\n \t\t\telse\n \t\t\t\tfprintf(stderr, \"Switched to%s branch '%s'\\n\",\n-\t\t\t\t\topts->branch_exists ? \" and reset\" : \" a new\",\n+\t\t\t\t\topts->branch_exists\n+\t\t\t\t\t\t? \" and reset\"\n+\t\t\t\t\t\t: opts->new_branch ? \" a new\" : \"\",\n \t\t\t\t\tnew->name);\n \t\t}\n \t\tif (old->path && old->name) {\n-- \n1.7.1.574.g421e3\n\n\n-- \ntyped with http://neo-layout.org\nmyFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!\n"},{"id":"148349","messageId":"20100818091603.GA6263@burratino","threadId":"24778","inReplyTo":"AANLkTi=3z9gJdT8LL3NANFyppUjvOVcrszjf5J5zAKPe@mail.gmail.com","subject":"Re: [PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-18T09:16:03Z","receivedAt":"2010-08-18T09:16:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nWarning: nitpicks coming.\n\nKnittl wrote:\n\n> From 16f540c87f8c7b87692dfd488d507802ae975312 Mon Sep 17 00:00:00 2001\n> From: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n> Date: Wed, 18 Aug 2010 10:35:42 +0200\n> Subject: [PATCH] builtin/checkout: fix info message for `git checkout <branch>`\n\nOn the git list, there are two formats often used for patches (see\nDocumentation/SubmittingPatches for details): whole-message patches,\nwhich look like this:\n\n\tgit checkout should only display 'Switched to a new branch <branch>'\n\twhen it creates a new branch, not when it simply switches branches.\n\n\tThis fixes a bug introduced by 02ac9837 (builtin/checkout:\n\tlearn -B, 2010-06-24).\n\n\tSigned-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com>\n\t---\n\tcomments of the moment\n\n\t diffstat\n\t...\n\nand \"inline\" patches, which look like this:\n\n\tcomments of the moment\n\t-- 8< --\n\tSubject: patch subject\n\n\tpatch rationale\n\t---\n\t diffstat\n\t...\n\nand sometimes get used when it is more natural for discussion.\n\nThe \"From \" line and so on output by \"git format-patch\" are for your\nmailer.  Clarifying From:, Date:, and Subject: lines at the start of\nyour message are allowed, though, and can be useful when forwarding\npatches from someone else.\n\n> +++ b/builtin/checkout.c\n> @@ -536,7 +536,9 @@ static void update_refs_for_switch(struct\n> checkout_opts *opts,\n>  \t\t\t\t\tnew->name);\n>  \t\t\telse\n>  \t\t\t\tfprintf(stderr, \"Switched to%s branch '%s'\\n\",\n> -\t\t\t\t\topts->branch_exists ? \" and reset\" : \" a new\",\n> +\t\t\t\t\topts->branch_exists\n> +\t\t\t\t\t\t? \" and reset\"\n> +\t\t\t\t\t\t: opts->new_branch ? \" a new\" : \"\",\n\nMaybe it would be clearer to write\n\n\topts->new_branch ? \" a new\"\n\t\t: opts->branch_exists ? \" and reset\"\n\t\t: \"\",\n\nto emphasize that this is a list of condition/result pairs?\n\nThe functionality of your patch is obviously good.  Thanks.\n\nJonathan\n"},{"id":"148375","messageId":"AANLkTikHbj4zA6Kj0wUp6uQUY3w6cM_z0=Pes1jLLTky@mail.gmail.com","threadId":"24778","inReplyTo":"20100818091603.GA6263@burratino","subject":"Re: [PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-08-18T13:39:20Z","receivedAt":"2010-08-18T13:39:20Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Wed, Aug 18, 2010 at 5:16 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Hi,\n\nJohnathan, thanks for the heads up.\n\n> [snip]\n>\n> The \"From \" line and so on output by \"git format-patch\" are for your\n> mailer.  Clarifying From:, Date:, and Subject: lines at the start of\n> your message are allowed, though, and can be useful when forwarding\n> patches from someone else.\n\nKnittl, I wonder how you generated this patch? Were you working on top\nof the \"bad\" commit?\n\n>> +++ b/builtin/checkout.c\n>> @@ -536,7 +536,9 @@ static void update_refs_for_switch(struct\n>> checkout_opts *opts,\n>>                                       new->name);\n>>                       else\n>>                               fprintf(stderr, \"Switched to%s branch '%s'\\n\",\n>> -                                     opts->branch_exists ? \" and reset\" : \" a new\",\n>> +                                     opts->branch_exists\n>> +                                             ? \" and reset\"\n>> +                                             : opts->new_branch ? \" a new\" : \"\",\n\nStrange - I thought I had this sorted out. Thanks for spotting this.\n\n> Maybe it would be clearer to write\n>\n>        opts->new_branch ? \" a new\"\n>                : opts->branch_exists ? \" and reset\"\n>                : \"\",\n>\n> to emphasize that this is a list of condition/result pairs?\n\nWe could do with some parentheses - here's my take:\n\n\tfprintf(stderr, \"Switched to%s branch '%s'\\n\",\n\t\t(opts->branch_exists ? \" and reset\" :\n\t\t\t(opts->new_branch ? \" a new\" : \"\")),\n\t\tnew->name);\n\n-- \nCheers,\nRay Chuan\n"},{"id":"148413","messageId":"7voccz8wo8.fsf@alter.siamese.dyndns.org","threadId":"24778","inReplyTo":"20100818091603.GA6263@burratino","subject":"Re: [PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-18T20:59:03Z","receivedAt":"2010-08-18T20:59:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> The functionality of your patch is obviously good.  Thanks.\n\nIn what way is it good?  I am especially worried about the word \"reset\"\nbeing confusing.\n\nYou are switching to a new context to work on something else, so I don't\nnecessarily think it is confusing that the word \"new branch\" in this\nmessage does not mean \"a branch that did not exist before this operation\n(i.e. a newly created branch).\"\n"},{"id":"148424","messageId":"7v4oer8paz.fsf@alter.siamese.dyndns.org","threadId":"24778","inReplyTo":"7voccz8wo8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-18T23:38:12Z","receivedAt":"2010-08-18T23:38:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n>\n>> The functionality of your patch is obviously good.  Thanks.\n>\n> In what way is it good?  I am especially worried about the word \"reset\"\n> being confusing.\n>\n> You are switching to a new context to work on something else, so I don't\n> necessarily think it is confusing that the word \"new branch\" in this\n> message does not mean \"a branch that did not exist before this operation\n> (i.e. a newly created branch).\"\n\nAhh, please disregard the above; I somehow failed to see that this is only\nin the \"-b/-B\" codepath.  Sorry for the noise.\n"},{"id":"148434","messageId":"AANLkTi=fkgmx4+oYO71OiaayEpehcmxb5aOeR6WvU7DL@mail.gmail.com","threadId":"24778","inReplyTo":"AANLkTimU75krdgQFvw0fEvAPqJb-eKaPXHg_5Hv2A8wh@mail.gmail.com","subject":"Re: [PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-08-19T03:21:31Z","receivedAt":"2010-08-19T03:21:31Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\noops, seems like you dropped everyone from the Cc list, including the\nmailing list. Try using the \"Reply to all\" next time.\n\nOn Wed, Aug 18, 2010 at 9:56 PM, Knittl <knittl89@googlemail.com> wrote:\n> [snip\n> yes, i branched off of your bad commit (or rather the commit after\n> your bad commit \"fix detached head usage\") and created the commit with\n> git commit -c HEAD^ to have the same heading and similar wording\n> without opening a second terminal to copy it over. so i accidentally\n> sent the patch with your name as author, which i then fixed with git\n> amend --reset-author\n\nWhy copy over the old commit message? You should be writing one that\nfits what you're did, not what *I* did.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"148824","messageId":"AANLkTim7DNasVmaBxWBcUGyGBCZq_HXNdq_=4uKRdxE-@mail.gmail.com","threadId":"24778","inReplyTo":"AANLkTikHbj4zA6Kj0wUp6uQUY3w6cM_z0=Pes1jLLTky@mail.gmail.com","subject":"Re: [PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Knittl","fromEmail":"knittl89@googlemail.com","sentAt":"2010-08-24T06:50:41Z","receivedAt":"2010-08-24T06:50:41Z","isPatch":true,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"sorry for the late reply, i hadn't had access to internet for the last\nweek and as it turns i sent my response only to tay\n\nOn Wed, Aug 18, 2010 at 3:39 PM, Tay Ray Chuan <rctay89@gmail.com> wrote:\n> Hi,\n>\n> On Wed, Aug 18, 2010 at 5:16 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> [snip]\n>\n>> The \"From \" line and so on output by \"git format-patch\" are for your\n>> mailer.  Clarifying From:, Date:, and Subject: lines at the start of\n>> your message are allowed, though, and can be useful when forwarding\n>> patches from someone else.\n>\n> Knittl, I wonder how you generated this patch? Were you working on top\n> of the \"bad\" commit?\n\nyes, i branched off of your bad commit (or rather the commit after\nyour bad commit \"fix detached head usage\") and created the commit with\ngit commit -c HEAD^ to have the same heading and similar wording\nwithout opening a second terminal to copy it over. so i accidentally\nsent the patch with your name as author, which i then fixed with git\namend --reset-author\n\n>>> +++ b/builtin/checkout.c\n>>> @@ -536,7 +536,9 @@ static void update_refs_for_switch(struct\n>>> checkout_opts *opts,\n>>>                                       new->name);\n>>>                       else\n>>>                               fprintf(stderr, \"Switched to%s branch '%s'\\n\",\n>>> -                                     opts->branch_exists ? \" and reset\" : \" a new\",\n>>> +                                     opts->branch_exists\n>>> +                                             ? \" and reset\"\n>>> +                                             : opts->new_branch ? \" a new\" : \"\",\n>\n> Strange - I thought I had this sorted out. Thanks for spotting this.\n\ni tested with next and pu and both tips had the same (confusing) message.\n\n>> Maybe it would be clearer to write\n>>\n>>        opts->new_branch ? \" a new\"\n>>                : opts->branch_exists ? \" and reset\"\n>>                : \"\",\n>>\n>> to emphasize that this is a list of condition/result pairs?\n>\n> We could do with some parentheses - here's my take:\n>\n>        fprintf(stderr, \"Switched to%s branch '%s'\\n\",\n>                (opts->branch_exists ? \" and reset\" :\n>                        (opts->new_branch ? \" a new\" : \"\")),\n>                new->name);\n\nthat's not really for me to decide, but i'm fine with either version\n\ncheers\n\n-- \ntyped with http://neo-layout.org\nmyFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!\n"},{"id":"148837","messageId":"AANLkTinXKwUwfXuCzghUgiyck=JBoQLrUn=kPRe0X+a5@mail.gmail.com","threadId":"24778","inReplyTo":"AANLkTim7DNasVmaBxWBcUGyGBCZq_HXNdq_=4uKRdxE-@mail.gmail.com","subject":"Re: [PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-08-24T13:06:13Z","receivedAt":"2010-08-24T13:06:13Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Tue, Aug 24, 2010 at 2:50 PM, Knittl <knittl89@googlemail.com> wrote:\n> sorry for the late reply, i hadn't had access to internet for the last\n> week and as it turns i sent my response only to tay\n\njust a heads-up - this has already been fixed since 09a0ec5 in master.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"148967","messageId":"AANLkTi=1dRw_rkaAV174r2SVLbxE6v9Wu2NjjzZCZ63T@mail.gmail.com","threadId":"24778","inReplyTo":"AANLkTinXKwUwfXuCzghUgiyck=JBoQLrUn=kPRe0X+a5@mail.gmail.com","subject":"Re: [PATCH re-roll] Do not display 'Switched to a new branch' when the branch existed","fromName":"Knittl","fromEmail":"knittl89@googlemail.com","sentAt":"2010-08-25T11:51:31Z","receivedAt":"2010-08-25T11:51:31Z","isPatch":true,"sender":{"key":"knittl89@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/2149217?v=4"},"body":"On Tue, Aug 24, 2010 at 3:06 PM, Tay Ray Chuan <rctay89@gmail.com> wrote:\n> Hi,\n>\n> On Tue, Aug 24, 2010 at 2:50 PM, Knittl <knittl89@googlemail.com> wrote:\n>> sorry for the late reply, i hadn't had access to internet for the last\n>> week and as it turns i sent my response only to tay\n>\n> just a heads-up - this has already been fixed since 09a0ec5 in master.\n\n\noh. good :)\n\n\n-- \ntyped with http://neo-layout.org\nmyFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!\n"}]}