mirror of
https://github.com/git/git.git
synced 2024-11-28 04:23:30 +08:00
Merge branch 'rs/patch-id-use-skip-prefix'
Code clean-up. * rs/patch-id-use-skip-prefix: patch-id: use starts_with() and skip_prefix()
This commit is contained in:
commit
29e54b019f
@ -81,16 +81,13 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,
|
|||||||
|
|
||||||
while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) {
|
while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) {
|
||||||
char *line = line_buf->buf;
|
char *line = line_buf->buf;
|
||||||
char *p = line;
|
const char *p = line;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!memcmp(line, "diff-tree ", 10))
|
if (!skip_prefix(line, "diff-tree ", &p) &&
|
||||||
p += 10;
|
!skip_prefix(line, "commit ", &p) &&
|
||||||
else if (!memcmp(line, "commit ", 7))
|
!skip_prefix(line, "From ", &p) &&
|
||||||
p += 7;
|
starts_with(line, "\\ ") && 12 < strlen(line))
|
||||||
else if (!memcmp(line, "From ", 5))
|
|
||||||
p += 5;
|
|
||||||
else if (!memcmp(line, "\\ ", 2) && 12 < strlen(line))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!get_oid_hex(p, next_oid)) {
|
if (!get_oid_hex(p, next_oid)) {
|
||||||
@ -99,14 +96,14 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore commit comments */
|
/* Ignore commit comments */
|
||||||
if (!patchlen && memcmp(line, "diff ", 5))
|
if (!patchlen && !starts_with(line, "diff "))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Parsing diff header? */
|
/* Parsing diff header? */
|
||||||
if (before == -1) {
|
if (before == -1) {
|
||||||
if (!memcmp(line, "index ", 6))
|
if (starts_with(line, "index "))
|
||||||
continue;
|
continue;
|
||||||
else if (!memcmp(line, "--- ", 4))
|
else if (starts_with(line, "--- "))
|
||||||
before = after = 1;
|
before = after = 1;
|
||||||
else if (!isalpha(line[0]))
|
else if (!isalpha(line[0]))
|
||||||
break;
|
break;
|
||||||
@ -114,14 +111,14 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,
|
|||||||
|
|
||||||
/* Looking for a valid hunk header? */
|
/* Looking for a valid hunk header? */
|
||||||
if (before == 0 && after == 0) {
|
if (before == 0 && after == 0) {
|
||||||
if (!memcmp(line, "@@ -", 4)) {
|
if (starts_with(line, "@@ -")) {
|
||||||
/* Parse next hunk, but ignore line numbers. */
|
/* Parse next hunk, but ignore line numbers. */
|
||||||
scan_hunk_header(line, &before, &after);
|
scan_hunk_header(line, &before, &after);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Split at the end of the patch. */
|
/* Split at the end of the patch. */
|
||||||
if (memcmp(line, "diff ", 5))
|
if (!starts_with(line, "diff "))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Else we're parsing another header. */
|
/* Else we're parsing another header. */
|
||||||
|
Loading…
Reference in New Issue
Block a user