{"thread":{"id":"36027","subject":"[PATCH v3] branch.c: change install_branch_config() to use skip_prefix()","startedAt":"2014-03-03T02:24:55Z","lastAt":"2014-03-03T06:20:48Z","messageCount":4,"participants":["Guanglin Xu","He Sun"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"235823","messageId":"1393813495-9079-1-git-send-email-mzguanglin@gmail.com","threadId":"36027","inReplyTo":null,"subject":"[PATCH v3] branch.c: change install_branch_config() to use skip_prefix()","fromName":"Guanglin Xu","fromEmail":"mzguanglin@gmail.com","sentAt":"2014-03-03T02:24:55Z","receivedAt":"2014-03-03T02:24:55Z","isPatch":true,"sender":{"key":"mzguanglin@gmail.com","avatar":"https://gravatar.com/avatar/fb3a07ac20762e91fec45813fa7b91f5497c3ed748441e9d14e888900d5653c0?d=mp&s=160"},"body":"to avoid a magic code of 11.\n\nHelped-by: Eric Sunshine <sunsh...@sunshineco.com>\nHelped-by: Jacopo Notarstefano <jaco...@gmail.com>\nSigned-off-by: Guanglin Xu <mzguanglin@gmail.com>\n---\n\nThis is an implementation of the idea#2 of GSoC 2014 microproject.\n\n branch.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/branch.c b/branch.c\nindex 723a36b..3e2551e 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -49,7 +49,7 @@ static int should_setup_rebase(const char *origin)\n \n void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n {\n-\tconst char *shortname = remote + 11;\n+\tconst char *shortname = skip_prefix(remote ,\"refs/heads/\");\n \tint remote_is_branch = starts_with(remote, \"refs/heads/\");\n \tstruct strbuf key = STRBUF_INIT;\n \tint rebasing = should_setup_rebase(origin);\n-- \n1.9.0\n"},{"id":"235825","messageId":"CAJr59C09sued4KJf+Gfp10yyD8NtXOKAjV0SZGbVw=Pn4hNZ7A@mail.gmail.com","threadId":"36027","inReplyTo":"1393813495-9079-1-git-send-email-mzguanglin@gmail.com","subject":"Re: [PATCH v3] branch.c: change install_branch_config() to use skip_prefix()","fromName":"He Sun","fromEmail":"sunheehnus@gmail.com","sentAt":"2014-03-03T05:30:23Z","receivedAt":"2014-03-03T05:30:23Z","isPatch":true,"sender":{"key":"sunheehnus@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2889804?v=4"},"body":"2014-03-03 10:24 GMT+08:00 Guanglin Xu <mzguanglin@gmail.com>:\n> to avoid a magic code of 11.\n>\n> Helped-by: Eric Sunshine <sunsh...@sunshineco.com>\n> Helped-by: Jacopo Notarstefano <jaco...@gmail.com>\n> Signed-off-by: Guanglin Xu <mzguanglin@gmail.com>\n> ---\n>\n> This is an implementation of the idea#2 of GSoC 2014 microproject.\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..3e2551e 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -49,7 +49,7 @@ static int should_setup_rebase(const char *origin)\n>\n>  void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n>  {\n> -       const char *shortname = remote + 11;\n> +       const char *shortname = skip_prefix(remote ,\"refs/heads/\");\n\nMaybe it is more proper to avoid the test of remote_is_branch, by\ntesting shortname instead.\nAnd add the comment \"skip_prefix only return NULL when refs/heads/ is\nnot the prefix of remote\"\n\n>         int remote_is_branch = starts_with(remote, \"refs/heads/\");\n>         struct strbuf key = STRBUF_INIT;\n>         int rebasing = should_setup_rebase(origin);\n> --\n> 1.9.0\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\nCheers,\nHe Sun\n"},{"id":"235826","messageId":"CAJr59C1hoc6FPrgHLLy8_xBPNEvCkDHurGSETqPM5j51w7zrHg@mail.gmail.com","threadId":"36027","inReplyTo":"1393813495-9079-1-git-send-email-mzguanglin@gmail.com","subject":"Re: [PATCH v3] branch.c: change install_branch_config() to use skip_prefix()","fromName":"He Sun","fromEmail":"sunheehnus@gmail.com","sentAt":"2014-03-03T05:39:00Z","receivedAt":"2014-03-03T05:39:00Z","isPatch":true,"sender":{"key":"sunheehnus@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2889804?v=4"},"body":"2014-03-03 10:24 GMT+08:00 Guanglin Xu <mzguanglin@gmail.com>:\n> to avoid a magic code of 11.\n>\n> Helped-by: Eric Sunshine <sunsh...@sunshineco.com>\n> Helped-by: Jacopo Notarstefano <jaco...@gmail.com>\n> Signed-off-by: Guanglin Xu <mzguanglin@gmail.com>\n> ---\n>\n> This is an implementation of the idea#2 of GSoC 2014 microproject.\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..3e2551e 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -49,7 +49,7 @@ static int should_setup_rebase(const char *origin)\n>\n>  void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n>  {\n> -       const char *shortname = remote + 11;\n> +       const char *shortname = skip_prefix(remote ,\"refs/heads/\");\n>         int remote_is_branch = starts_with(remote, \"refs/heads/\");\n\nOr it may be better to keep remote_is_branch, and replace starts_with\nwith something\nyou have just fixed.\n\n>         struct strbuf key = STRBUF_INIT;\n>         int rebasing = should_setup_rebase(origin);\n> --\n> 1.9.0\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"235827","messageId":"CAATe9ugFxfcPukBoboGsb6A_cVkEchk4SpG-VHVE+uCrRqj2wg@mail.gmail.com","threadId":"36027","inReplyTo":"CAJr59C1hoc6FPrgHLLy8_xBPNEvCkDHurGSETqPM5j51w7zrHg@mail.gmail.com","subject":"Re: [PATCH v3] branch.c: change install_branch_config() to use skip_prefix()","fromName":"Guanglin Xu","fromEmail":"mzguanglin@gmail.com","sentAt":"2014-03-03T06:20:48Z","receivedAt":"2014-03-03T06:20:48Z","isPatch":true,"sender":{"key":"mzguanglin@gmail.com","avatar":"https://gravatar.com/avatar/fb3a07ac20762e91fec45813fa7b91f5497c3ed748441e9d14e888900d5653c0?d=mp&s=160"},"body":"2014-03-03 13:39 GMT+08:00 He Sun <sunheehnus@gmail.com>:\n> 2014-03-03 10:24 GMT+08:00 Guanglin Xu <mzguanglin@gmail.com>:\n>> to avoid a magic code of 11.\n>>\n>> Helped-by: Eric Sunshine <sunsh...@sunshineco.com>\n>> Helped-by: Jacopo Notarstefano <jaco...@gmail.com>\n>> Signed-off-by: Guanglin Xu <mzguanglin@gmail.com>\n>> ---\n>>\n>> This is an implementation of the idea#2 of GSoC 2014 microproject.\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..3e2551e 100644\n>> --- a/branch.c\n>> +++ b/branch.c\n>> @@ -49,7 +49,7 @@ static int should_setup_rebase(const char *origin)\n>>\n>>  void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n>>  {\n>> -       const char *shortname = remote + 11;\n>> +       const char *shortname = skip_prefix(remote ,\"refs/heads/\");\n>>         int remote_is_branch = starts_with(remote, \"refs/heads/\");\n>\n> Or it may be better to keep remote_is_branch, and replace starts_with\n> with something\n> you have just fixed.\n\nHi He,\n\nThanks for your comments.\n\nThis PATCH v3 scans the \"remote\" twice. It's unnecessary at all. So I\ndecide to post PATCH v4 like this:\n\n- const char *shortname = remote + 11;\n- int remote_is_branch = starts_with(remote, \"refs/heads/\");\n+ const char *shortname = skip_prefix(remote ,\"refs/heads/\");\n+ int remote_is_branch;\n+ if (NULL == shortname)\n+ remote_is_branch = 0;\n+ else\n+ remote_is_branch = 1;\n\nGuanglin\n\n\n>\n>>         struct strbuf key = STRBUF_INIT;\n>>         int rebasing = should_setup_rebase(origin);\n>> --\n>> 1.9.0\n>>\n>> --\n>> To unsubscribe from this list: send the line \"unsubscribe git\" in\n>> the body of a message to majordomo@vger.kernel.org\n>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}