{"thread":{"id":"36023","subject":"[PATCH v2] branch.c: change install_branch_config() to use skip_prefix()","startedAt":"2014-03-02T15:55:55Z","lastAt":"2014-03-03T18:49:27Z","messageCount":4,"participants":["Guanglin Xu","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"235802","messageId":"1393775755-15359-1-git-send-email-mzguanglin@gmail.com","threadId":"36023","inReplyTo":null,"subject":"[PATCH v2] branch.c: change install_branch_config() to use skip_prefix()","fromName":"Guanglin Xu","fromEmail":"mzguanglin@gmail.com","sentAt":"2014-03-02T15:55:55Z","receivedAt":"2014-03-02T15:55:55Z","isPatch":true,"sender":{"key":"mzguanglin@gmail.com","avatar":"https://gravatar.com/avatar/fb3a07ac20762e91fec45813fa7b91f5497c3ed748441e9d14e888900d5653c0?d=mp&s=160"},"body":"Change install_branch_config() to use skip_prefix() and make it conform to the usage of previous starts_with(). This is because the proper usage of skip_prefix() overrides the functionality of starts_with(). Thorough replacements may finally remove the starts_with() function and reduce  code redundency.\n\nSigned-off-by: Guanglin Xu <mzguanglin@gmail.com>\n---\n branch.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/branch.c b/branch.c\nindex 723a36b..ca4e824 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -50,7 +50,7 @@ static int should_setup_rebase(const char *origin)\n void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n {\n \tconst char *shortname = remote + 11;\n-\tint remote_is_branch = starts_with(remote, \"refs/heads/\");\n+\tint remote_is_branch = (NULL != skip_prefix(remote ,\"refs/heads/\"));\n \tstruct strbuf key = STRBUF_INIT;\n \tint rebasing = should_setup_rebase(origin);\n \n-- \n1.9.0\n\n\nHi,\nI am Guanglin Xu. I plan to apply for GSoC 2014.\n\nThis patch is in accordance with the idea#2 of GSoC2014 Microproject. Any comments are welcomed.\n"},{"id":"235814","messageId":"CAPig+cRy2Jt_3DAS=ARzN-8HT3rdMCSGP5QfU8sJZGwqsJTG3g@mail.gmail.com","threadId":"36023","inReplyTo":"1393775755-15359-1-git-send-email-mzguanglin@gmail.com","subject":"Re: [PATCH v2] branch.c: change install_branch_config() to use skip_prefix()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-03-02T22:56:09Z","receivedAt":"2014-03-02T22:56:09Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Thanks for the submission. Comments below to give you a taste of the\nGit review process...\n\nOn Sun, Mar 2, 2014 at 10:55 AM, Guanglin Xu <mzguanglin@gmail.com> wrote:\n> Change install_branch_config() to use skip_prefix() and make it conform to the usage of previous starts_with(). This is because the proper usage of skip_prefix() overrides the functionality of starts_with(). Thorough replacements may finally remove the starts_with() function and reduce  code redundency.\n\nJustifying a change is certainly a good idea, however, the above\nreasoning for this particular change is off mark. See below.\n\nAlso, wrap commit message lines to 65-70 characters or so.\n\n> Signed-off-by: Guanglin Xu <mzguanglin@gmail.com>\n> ---\n>  branch.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/branch.c b/branch.c\n> index 723a36b..ca4e824 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -50,7 +50,7 @@ static int should_setup_rebase(const char *origin)\n>  void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n>  {\n>         const char *shortname = remote + 11;\n> -       int remote_is_branch = starts_with(remote, \"refs/heads/\");\n> +       int remote_is_branch = (NULL != skip_prefix(remote ,\"refs/heads/\"));\n\nThis actually makes the code more difficult to read and understand.\nThere's a more fundamental reason to use skip_prefix() here. See if\nyou can figure it out. (Hint: shortname)\n\n>         struct strbuf key = STRBUF_INIT;\n>         int rebasing = should_setup_rebase(origin);\n>\n> --\n> 1.9.0\n>\n> Hi,\n> I am Guanglin Xu. I plan to apply for GSoC 2014.\n>\n> This patch is in accordance with the idea#2 of GSoC2014 Microproject. Any comments are welcomed.\n\nThis sort of commentary, which is appropriate to the email discussion\nbut not meant for permanent project history, should be placed\nimmediately below the \"---\" line following your sign-off.\n"},{"id":"235822","messageId":"CAATe9uhK88Gy4_EJTjJ=8ULKY0ADGrBkRArwBiVncf_2exWZEQ@mail.gmail.com","threadId":"36023","inReplyTo":"CAPig+cRy2Jt_3DAS=ARzN-8HT3rdMCSGP5QfU8sJZGwqsJTG3g@mail.gmail.com","subject":"Re: [PATCH v2] branch.c: change install_branch_config() to use skip_prefix()","fromName":"Guanglin Xu","fromEmail":"mzguanglin@gmail.com","sentAt":"2014-03-03T01:41:42Z","receivedAt":"2014-03-03T01:41:42Z","isPatch":true,"sender":{"key":"mzguanglin@gmail.com","avatar":"https://gravatar.com/avatar/fb3a07ac20762e91fec45813fa7b91f5497c3ed748441e9d14e888900d5653c0?d=mp&s=160"},"body":"2014-03-03 6:56 GMT+08:00 Eric Sunshine <sunshine@sunshineco.com>:\n> Thanks for the submission. Comments below to give you a taste of the\n> Git review process...\n>\n> On Sun, Mar 2, 2014 at 10:55 AM, Guanglin Xu <mzguanglin@gmail.com> wrote:\n>> Change install_branch_config() to use skip_prefix() and make it conform to the usage of previous starts_with(). This is because the proper usage of skip_prefix() overrides the functionality of starts_with(). Thorough replacements may finally remove the starts_with() function and reduce  code redundency.\n>\n> Justifying a change is certainly a good idea, however, the above\n> reasoning for this particular change is off mark. See below.\n>\n> Also, wrap commit message lines to 65-70 characters or so.\n>\n>> Signed-off-by: Guanglin Xu <mzguanglin@gmail.com>\n>> ---\n>>  branch.c | 2 +-\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/branch.c b/branch.c\n>> index 723a36b..ca4e824 100644\n>> --- a/branch.c\n>> +++ b/branch.c\n>> @@ -50,7 +50,7 @@ static int should_setup_rebase(const char *origin)\n>>  void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n>>  {\n>>         const char *shortname = remote + 11;\n>> -       int remote_is_branch = starts_with(remote, \"refs/heads/\");\n>> +       int remote_is_branch = (NULL != skip_prefix(remote ,\"refs/heads/\"));\n>\n> This actually makes the code more difficult to read and understand.\n> There's a more fundamental reason to use skip_prefix() here. See if\n> you can figure it out. (Hint: shortname)\n\nHi Eric,\n\nThanks for your hint. Now I wonder this idea is just to remove the\nmagic code of 11.\n\nSo I would like to replace this line:\nconst char *shortname = remote + 11;\nby this line:\nconst char *shortname = skip_prefix(remote, \"refs/heads/\");\n\nand keep the next line unchanged.\n\nAm I right?\n>\n>>         struct strbuf key = STRBUF_INIT;\n>>         int rebasing = should_setup_rebase(origin);\n>>\n>> --\n>> 1.9.0\n>>\n>> Hi,\n>> I am Guanglin Xu. I plan to apply for GSoC 2014.\n>>\n>> This patch is in accordance with the idea#2 of GSoC2014 Microproject. Any comments are welcomed.\n>\n> This sort of commentary, which is appropriate to the email discussion\n> but not meant for permanent project history, should be placed\n> immediately below the \"---\" line following your sign-off.\n\nApologize for bad format. I am going to fix it by PATCH v3.\n\nGuanglin\n"},{"id":"235903","messageId":"xmqq61nvqfrc.fsf@gitster.dls.corp.google.com","threadId":"36023","inReplyTo":"CAPig+cRy2Jt_3DAS=ARzN-8HT3rdMCSGP5QfU8sJZGwqsJTG3g@mail.gmail.com","subject":"Re: [PATCH v2] branch.c: change install_branch_config() to use skip_prefix()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-03-03T18:49:27Z","receivedAt":"2014-03-03T18:49:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n>> diff --git a/branch.c b/branch.c\n>> index 723a36b..ca4e824 100644\n>> --- a/branch.c\n>> +++ b/branch.c\n>> @@ -50,7 +50,7 @@ static int should_setup_rebase(const char *origin)\n>>  void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n>>  {\n>>         const char *shortname = remote + 11;\n>> -       int remote_is_branch = starts_with(remote, \"refs/heads/\");\n>> +       int remote_is_branch = (NULL != skip_prefix(remote ,\"refs/heads/\"));\n>\n> This actually makes the code more difficult to read and understand.\n> There's a more fundamental reason to use skip_prefix() here. See if\n> you can figure it out. (Hint: shortname)\n\nI've already queued 0630aa49 (branch: use skip_prefix() in\ninstall_branch_config(), 2014-02-28) on this topic, by the way.\n"}]}