]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'rs/patch-id-use-skip-prefix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 3 Jun 2016 21:38:03 +0000 (14:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 3 Jun 2016 21:38:03 +0000 (14:38 -0700)
Code clean-up.

* rs/patch-id-use-skip-prefix:
  patch-id: use starts_with() and skip_prefix()

1  2 
builtin/patch-id.c

index 366ce5a5d419649dba34f607ed3f54b6a28bd3ea,f21b6e34f6d79942638aeddd1e3cdbeac52a3940..a84d0003a3087c842b6eab6a987a93eebaddec79
@@@ -81,19 -81,16 +81,16 @@@ static int get_one_patchid(struct objec
  
        while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) {
                char *line = line_buf->buf;
-               char *p = line;
+               const char *p = line;
                int len;
  
-               if (!memcmp(line, "diff-tree ", 10))
-                       p += 10;
-               else if (!memcmp(line, "commit ", 7))
-                       p += 7;
-               else if (!memcmp(line, "From ", 5))
-                       p += 5;
-               else if (!memcmp(line, "\\ ", 2) && 12 < strlen(line))
+               if (!skip_prefix(line, "diff-tree ", &p) &&
+                   !skip_prefix(line, "commit ", &p) &&
+                   !skip_prefix(line, "From ", &p) &&
+                   starts_with(line, "\\ ") && 12 < strlen(line))
                        continue;
  
 -              if (!get_sha1_hex(p, next_sha1)) {
 +              if (!get_oid_hex(p, next_oid)) {
                        found_next = 1;
                        break;
                }