builtin/pull: make hash-size independent
Instead of using get_oid_hex and GIT_SHA1_HEXSZ, use parse_oid_hex to avoid the need for a constant and simplify the code. Additionally, fix some comments to refer to object IDs instead of SHA-1 and update a constant used to provide an allocation hint. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Feb 19, 2019 at 00:05 UTC
fbfc089d913772f96f9562a3dbddaed28809fe72
1 file changed
+6
-5
builtin/pull.c
+6
-5
@@ -369,9 +369,10 @@ static void get_merge_heads(struct oid_array *merge_heads)
369
370
fp = xfopen(filename, "r");
371
while (strbuf_getline_lf(&sb, fp) != EOF) {
372
- if (get_oid_hex(sb.buf, &oid))
373
- continue; /* invalid line: does not start with SHA1 */
374
- if (starts_with(sb.buf + GIT_SHA1_HEXSZ, "\tnot-for-merge\t"))
372
+ const char *p;
373
+ if (parse_oid_hex(sb.buf, &oid, &p))
374
+ continue; /* invalid line: does not start with object ID */
375
+ if (starts_with(p, "\tnot-for-merge\t"))
376
continue; /* ref is not-for-merge */
377
oid_array_append(merge_heads, &oid);
378
}
@@ -760,7 +761,7 @@ static int get_rebase_fork_point(struct object_id *fork_point, const char *repo,
761
cp.no_stderr = 1;
762
cp.git_cmd = 1;
763
763
- ret = capture_command(&cp, &sb, GIT_SHA1_HEXSZ);
764
+ ret = capture_command(&cp, &sb, GIT_MAX_HEXSZ);
765
if (ret)
766
goto cleanup;
767
@@ -805,7 +806,7 @@ static int get_octopus_merge_base(struct object_id *merge_base,
806
}
807
808
/**
808
- * Given the current HEAD SHA1, the merge head returned from git-fetch and the
809
+ * Given the current HEAD oid, the merge head returned from git-fetch and the
810
* fork point calculated by get_rebase_fork_point(), runs git-rebase with the
811
* appropriate arguments and returns its exit status.
812
*/