{"thread":{"id":"35970","subject":"[PATCH] branch: change install_branch_config() to use skip_prefix()","startedAt":"2014-02-27T11:13:49Z","lastAt":"2014-02-27T13:05:48Z","messageCount":4,"participants":["Dmitry S. Dolzhenko","Michael Haggerty","David Kastrup"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"235457","messageId":"530F1DED.50308@yandex.ru","threadId":"35970","inReplyTo":null,"subject":"[PATCH] branch: change install_branch_config() to use skip_prefix()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-27T11:13:49Z","receivedAt":"2014-02-27T11:13:49Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Change install_branch_config() function to use skip_prefix()\nfor getting short name of remote branch.\n\nSigned-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n branch.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 723a36b..310749b 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -4,6 +4,8 @@\n #include \"remote.h\"\n #include \"commit.h\"\n \n+static const char refs_heads_prefix[] = \"refs/heads/\";\n+\n struct tracking {\n \tstruct refspec spec;\n \tchar *src;\n@@ -49,8 +51,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_prefix);\n+\tint remote_is_branch = starts_with(remote, refs_heads_prefix);\n \tstruct strbuf key = STRBUF_INIT;\n \tint rebasing = should_setup_rebase(origin);\n \n-- \n1.8.5.3\n"},{"id":"235462","messageId":"530F248B.6030506@alum.mit.edu","threadId":"35970","inReplyTo":"530F1DED.50308@yandex.ru","subject":"Re: [PATCH] branch: change install_branch_config() to use skip_prefix()","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2014-02-27T11:42:03Z","receivedAt":"2014-02-27T11:42:03Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"Dmitry,\n\nThanks for your patch.  Please see my comments below.\n\nOn 02/27/2014 12:13 PM, Dmitry S. Dolzhenko wrote:\n> Change install_branch_config() function to use skip_prefix()\n> for getting short name of remote branch.\n\nEnglish tweak suggestion:\n\nChange THE install_branch_config() function to use skip_prefix()\nfor getting THE short name of THE remote branch.\n\n> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n> ---\n>  branch.c | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n> \n> diff --git a/branch.c b/branch.c\n> index 723a36b..310749b 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -4,6 +4,8 @@\n>  #include \"remote.h\"\n>  #include \"commit.h\"\n>  \n> +static const char refs_heads_prefix[] = \"refs/heads/\";\n> +\n>  struct tracking {\n>  \tstruct refspec spec;\n>  \tchar *src;\n> @@ -49,8 +51,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_prefix);\n> +\tint remote_is_branch = starts_with(remote, refs_heads_prefix);\n>  \tstruct strbuf key = STRBUF_INIT;\n>  \tint rebasing = should_setup_rebase(origin);\n>  \n> \n\nIf you look at what skip_prefix() and starts_with() do, I think you will\nfind that you are doing too much work here.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"235464","messageId":"87r46o4v6v.fsf@fencepost.gnu.org","threadId":"35970","inReplyTo":"530F248B.6030506@alum.mit.edu","subject":"Re: [PATCH] branch: change install_branch_config() to use skip_prefix()","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-02-27T12:05:44Z","receivedAt":"2014-02-27T12:05:44Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> Dmitry,\n>\n> Thanks for your patch.  Please see my comments below.\n>\n> On 02/27/2014 12:13 PM, Dmitry S. Dolzhenko wrote:\n>> Change install_branch_config() function to use skip_prefix()\n>> for getting short name of remote branch.\n>\n> English tweak suggestion:\n>\n> Change THE install_branch_config() function to use skip_prefix()\n> for getting THE short name of THE remote branch.\n\nChange install_branch_config() to use skip_prefix()\nfor getting the short name of the remote branch.\n\n-- \nDavid Kastrup\n"},{"id":"235471","messageId":"530F382C.2030101@yandex.ru","threadId":"35970","inReplyTo":"530F248B.6030506@alum.mit.edu","subject":"Re: [PATCH] branch: change install_branch_config() to use skip_prefix()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-27T13:05:48Z","receivedAt":"2014-02-27T13:05:48Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Michael,\n\nThank you for your remarks.\n\n> If you look at what skip_prefix() and starts_with() do, I think you will\n> find that you are doing too much work here.\n\nHow about this one?\n\n\tconst char *shortname = skip_prefix(remote, \"refs/heads/\");\n\tint remote_is_branch = shortname != NULL;\n"}]}