@@ -81,16 +81,13 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,
8181
8282 while (strbuf_getwholeline (line_buf , stdin , '\n' ) != EOF ) {
8383 char * line = line_buf -> buf ;
84- char * p = line ;
84+ const char * p = line ;
8585 int len ;
8686
87- if (!memcmp (line , "diff-tree " , 10 ))
88- p += 10 ;
89- else if (!memcmp (line , "commit " , 7 ))
90- p += 7 ;
91- else if (!memcmp (line , "From " , 5 ))
92- p += 5 ;
93- else if (!memcmp (line , "\\ " , 2 ) && 12 < strlen (line ))
87+ if (!skip_prefix (line , "diff-tree " , & p ) &&
88+ !skip_prefix (line , "commit " , & p ) &&
89+ !skip_prefix (line , "From " , & p ) &&
90+ starts_with (line , "\\ " ) && 12 < strlen (line ))
9491 continue ;
9592
9693 if (!get_oid_hex (p , next_oid )) {
@@ -99,29 +96,29 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,
9996 }
10097
10198 /* Ignore commit comments */
102- if (!patchlen && memcmp (line , "diff " , 5 ))
99+ if (!patchlen && ! starts_with (line , "diff " ))
103100 continue ;
104101
105102 /* Parsing diff header? */
106103 if (before == -1 ) {
107- if (! memcmp (line , "index " , 6 ))
104+ if (starts_with (line , "index " ))
108105 continue ;
109- else if (! memcmp (line , "--- " , 4 ))
106+ else if (starts_with (line , "--- " ))
110107 before = after = 1 ;
111108 else if (!isalpha (line [0 ]))
112109 break ;
113110 }
114111
115112 /* Looking for a valid hunk header? */
116113 if (before == 0 && after == 0 ) {
117- if (! memcmp (line , "@@ -" , 4 )) {
114+ if (starts_with (line , "@@ -" )) {
118115 /* Parse next hunk, but ignore line numbers. */
119116 scan_hunk_header (line , & before , & after );
120117 continue ;
121118 }
122119
123120 /* Split at the end of the patch. */
124- if (memcmp (line , "diff " , 5 ))
121+ if (! starts_with (line , "diff " ))
125122 break ;
126123
127124 /* Else we're parsing another header. */
0 commit comments