{"thread":{"id":"36009","subject":"[PATCH] git-compat-util.h:rewrite skip_prefix() as loop","startedAt":"2014-03-01T13:32:04Z","lastAt":"2014-03-02T05:02:16Z","messageCount":4,"participants":["Siddharth Goel","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"235748","messageId":"1393680724-19983-1-git-send-email-siddharth98391@gmail.com","threadId":"36009","inReplyTo":null,"subject":"[PATCH] git-compat-util.h:rewrite skip_prefix() as loop","fromName":"Siddharth Goel","fromEmail":"siddharth98391@gmail.com","sentAt":"2014-03-01T13:32:04Z","receivedAt":"2014-03-01T13:32:04Z","isPatch":true,"sender":{"key":"siddharth98391@gmail.com","avatar":"https://gravatar.com/avatar/a951feb4fe81ca0581ee1719eb493b15bf8bb86107ae07510bd669811808ee19?d=mp&s=160"},"body":"Rewrote skip_prefix() function so that prefix is scanned once.\n\nSigned-off-by: Siddharth Goel <siddharth98391@gmail.com>\n---\n git-compat-util.h | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 614a5e9..550dce3 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -357,8 +357,11 @@ extern int suffixcmp(const char *str, const char *suffix);\n \n static inline const char *skip_prefix(const char *str, const char *prefix)\n {\n-\tsize_t len = strlen(prefix);\n-\treturn strncmp(str, prefix, len) ? NULL : str + len;\n+\twhile (*prefix != '\\0' && *str == *prefix) {\n+\t\tstr++;\n+\t\tprefix++;\n+\t}\n+\treturn (*prefix == '\\0' ? str : NULL);\n }\n \n #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)\n-- \n1.9.0.138.g2de3478.dirty\n"},{"id":"235778","messageId":"CANQLRip4zpOuF=GUsuhsQtQ4z5Z9VtCHo8yBb6vL3npuMHHgZA@mail.gmail.com","threadId":"36009","inReplyTo":"1393680724-19983-1-git-send-email-siddharth98391@gmail.com","subject":"Re: [PATCH] git-compat-util.h:rewrite skip_prefix() as loop","fromName":"Siddharth Goel","fromEmail":"siddharth98391@gmail.com","sentAt":"2014-03-02T03:22:43Z","receivedAt":"2014-03-02T03:22:43Z","isPatch":true,"sender":{"key":"siddharth98391@gmail.com","avatar":"https://gravatar.com/avatar/a951feb4fe81ca0581ee1719eb493b15bf8bb86107ae07510bd669811808ee19?d=mp&s=160"},"body":"To my surprise, git format-patch had removed the Git Notes that I had\nput to my commit (regarding GSoC). I have written this patch as a part\nof the GSoC 2014 MicroProject for Git. Going through the mail-chain I\nobserved that many students have attempted this Microproject. So is it\nok if I stick to this Microproject or should I go with another one?\n\nOn Sat, Mar 1, 2014 at 9:32 PM, Siddharth Goel <siddharth98391@gmail.com> wrote:\n> Rewrote skip_prefix() function so that prefix is scanned once.\n>\n> Signed-off-by: Siddharth Goel <siddharth98391@gmail.com>\n> ---\n>  git-compat-util.h | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 614a5e9..550dce3 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -357,8 +357,11 @@ extern int suffixcmp(const char *str, const char *suffix);\n>\n>  static inline const char *skip_prefix(const char *str, const char *prefix)\n>  {\n> -       size_t len = strlen(prefix);\n> -       return strncmp(str, prefix, len) ? NULL : str + len;\n> +       while (*prefix != '\\0' && *str == *prefix) {\n> +               str++;\n> +               prefix++;\n> +       }\n> +       return (*prefix == '\\0' ? str : NULL);\n>  }\n>\n>  #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)\n> --\n> 1.9.0.138.g2de3478.dirty\n>\n"},{"id":"235782","messageId":"CAPig+cRDHb9usJW2zC20zXXM_9KxuEQ+=dkFmghp9JiVPcL1_w@mail.gmail.com","threadId":"36009","inReplyTo":"1393680724-19983-1-git-send-email-siddharth98391@gmail.com","subject":"Re: [PATCH] git-compat-util.h:rewrite skip_prefix() as loop","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-03-02T05:00:22Z","receivedAt":"2014-03-02T05:00:22Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Thanks for the submission. Minor comments below to give you a taste of\nwhat it's like to contribute to this project...\n\nOn Sat, Mar 1, 2014 at 8:32 AM, Siddharth Goel <siddharth98391@gmail.com> wrote:\n> Rewrote skip_prefix() function so that prefix is scanned once.\n\nGood description. In this project, use imperative tone, so say\n\"Rewrite skip_prefix()...\" as you did in the subject. In fact, this\ndescription is short enough and conveys sufficient information that it\ncould just be placed in the subject as the entire commit message.\n\n    Subject: skip_prefix: rewrite so that prefix is scanned once\n\n> Signed-off-by: Siddharth Goel <siddharth98391@gmail.com>\n> ---\n>  git-compat-util.h | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 614a5e9..550dce3 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -357,8 +357,11 @@ extern int suffixcmp(const char *str, const char *suffix);\n>\n>  static inline const char *skip_prefix(const char *str, const char *prefix)\n>  {\n> -       size_t len = strlen(prefix);\n> -       return strncmp(str, prefix, len) ? NULL : str + len;\n> +       while (*prefix != '\\0' && *str == *prefix) {\n> +               str++;\n> +               prefix++;\n> +       }\n> +       return (*prefix == '\\0' ? str : NULL);\n>  }\n>\n>  #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)\n> --\n> 1.9.0.138.g2de3478.dirty\n"},{"id":"235783","messageId":"CAPig+cRkRZkjTB4WpQTKxfAofC7iqn8HZvU03egQhMe0NJktpQ@mail.gmail.com","threadId":"36009","inReplyTo":"CANQLRip4zpOuF=GUsuhsQtQ4z5Z9VtCHo8yBb6vL3npuMHHgZA@mail.gmail.com","subject":"Re: [PATCH] git-compat-util.h:rewrite skip_prefix() as loop","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-03-02T05:02:16Z","receivedAt":"2014-03-02T05:02:16Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sat, Mar 1, 2014 at 10:22 PM, Siddharth Goel\n<siddharth98391@gmail.com> wrote:\n> To my surprise, git format-patch had removed the Git Notes that I had\n> put to my commit (regarding GSoC). I have written this patch as a part\n> of the GSoC 2014 MicroProject for Git.\n\nYou probably wanted to use the --notes option with format-patch.\n\n> Going through the mail-chain I\n> observed that many students have attempted this Microproject. So is it\n> ok if I stick to this Microproject or should I go with another one?\n\nThat's okay. The purpose of the miniprojects is for you to get a taste\nof what it's like to contribute to this project and to understand what\nwill be expected of you as a GSoC student; and to give the GSoC\nmentors a chance to judge your abilities and observe how you interact\nwith reviewers.\n"}]}