{"thread":{"id":"35978","subject":"[PATCH v2] branch: change install_branch_config() to use skip_prefix()","startedAt":"2014-02-27T15:35:29Z","lastAt":"2014-02-27T22:17:29Z","messageCount":3,"participants":["Dmitry S. Dolzhenko","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"235481","messageId":"530F5B41.1050900@yandex.ru","threadId":"35978","inReplyTo":null,"subject":"[PATCH v2] branch: change install_branch_config() to use skip_prefix()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-27T15:35:29Z","receivedAt":"2014-02-27T15:35:29Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Change install_branch_config() to use skip_prefix()\nfor getting the short name of the remote branch.\n\nSigned-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n branch.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 723a36b..9382e02 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -49,8 +49,8 @@ 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-\tint remote_is_branch = starts_with(remote, \"refs/heads/\");\n+\tconst char *shortname = skip_prefix(remote, \"refs/heads/\");\n+\tint remote_is_branch = shortname != NULL;\n \tstruct strbuf key = STRBUF_INIT;\n \tint rebasing = should_setup_rebase(origin);\n \n-- \n1.8.3.2\n"},{"id":"235496","messageId":"xmqq4n3kz6jb.fsf@gitster.dls.corp.google.com","threadId":"35978","inReplyTo":"530F5B41.1050900@yandex.ru","subject":"Re: [PATCH v2] branch: change install_branch_config() to use skip_prefix()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-27T19:42:32Z","receivedAt":"2014-02-27T19:42:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Dmitry S. Dolzhenko\" <dmitrys.dolzhenko@yandex.ru> writes:\n\n> Change install_branch_config() to use skip_prefix()\n> for getting the short name of the remote branch.\n>\n> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n> ---\n>  branch.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/branch.c b/branch.c\n> index 723a36b..9382e02 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -49,8 +49,8 @@ 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> -\tint remote_is_branch = starts_with(remote, \"refs/heads/\");\n> +\tconst char *shortname = skip_prefix(remote, \"refs/heads/\");\n> +\tint remote_is_branch = shortname != NULL;\n\nThat sounds more reasonable, compared to the previous round.\nI'd probably say this\n\n\tint remote_is_branch = !shortname;\n\ninstead, if I were doing this patch myself, though.\n\n>  \tstruct strbuf key = STRBUF_INIT;\n>  \tint rebasing = should_setup_rebase(origin);\n"},{"id":"235520","messageId":"xmqqy50ww686.fsf@gitster.dls.corp.google.com","threadId":"35978","inReplyTo":"xmqq4n3kz6jb.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2] branch: change install_branch_config() to use skip_prefix()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-27T22:17:29Z","receivedAt":"2014-02-27T22:17:29Z","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> \"Dmitry S. Dolzhenko\" <dmitrys.dolzhenko@yandex.ru> writes:\n>\n>> Change install_branch_config() to use skip_prefix()\n>> for getting the short name of the remote branch.\n>>\n>> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n>> ---\n>>  branch.c | 4 ++--\n>>  1 file changed, 2 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/branch.c b/branch.c\n>> index 723a36b..9382e02 100644\n>> --- a/branch.c\n>> +++ b/branch.c\n>> @@ -49,8 +49,8 @@ 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>> -\tint remote_is_branch = starts_with(remote, \"refs/heads/\");\n>> +\tconst char *shortname = skip_prefix(remote, \"refs/heads/\");\n>> +\tint remote_is_branch = shortname != NULL;\n>\n> That sounds more reasonable, compared to the previous round.\n> I'd probably say this\n>\n> \tint remote_is_branch = !shortname;\n>\n> instead, if I were doing this patch myself, though.\n\nHeh, that is !!, not !.\n\n>\n>>  \tstruct strbuf key = STRBUF_INIT;\n>>  \tint rebasing = should_setup_rebase(origin);\n"}]}