Skip to content

Commit ebe4df5

Browse files
bk2204gitster
authored andcommitted
builtin/difftool: use parse_oid_hex
Instead of using get_oid_hex and adding constants to the result, use parse_oid_hex to make this code independent of the hash size. Additionally, correct a typo that would cause us to print one too few characters on error, since we will already have incremented the pointer to point to the beginning of the object ID before we get to printing the error message. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b8d45d0 commit ebe4df5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

builtin/difftool.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ static int parse_index_info(char *p, int *mode1, int *mode2,
6565
*mode2 = (int)strtol(p + 1, &p, 8);
6666
if (*p != ' ')
6767
return error("expected ' ', got '%c'", *p);
68-
if (get_oid_hex(++p, oid1))
69-
return error("expected object ID, got '%s'", p + 1);
70-
p += GIT_SHA1_HEXSZ;
68+
if (parse_oid_hex(++p, oid1, (const char **)&p))
69+
return error("expected object ID, got '%s'", p);
7170
if (*p != ' ')
7271
return error("expected ' ', got '%c'", *p);
73-
if (get_oid_hex(++p, oid2))
74-
return error("expected object ID, got '%s'", p + 1);
75-
p += GIT_SHA1_HEXSZ;
72+
if (parse_oid_hex(++p, oid2, (const char **)&p))
73+
return error("expected object ID, got '%s'", p);
7674
if (*p != ' ')
7775
return error("expected ' ', got '%c'", *p);
7876
*status = *++p;

0 commit comments

Comments
 (0)