summaryrefslogtreecommitdiff
path: root/builtin/pull.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-02-19 00:05:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-01 02:57:38 (GMT)
commitfbfc089d913772f96f9562a3dbddaed28809fe72 (patch)
tree688d0a9dd064f81d7a7d3074b4e5b9d99c6e78e9 /builtin/pull.c
parent24dd363ed586f5edbdea96689d4e0e40a7d3f7fa (diff)
downloadgit-fbfc089d913772f96f9562a3dbddaed28809fe72.zip
git-fbfc089d913772f96f9562a3dbddaed28809fe72.tar.gz
git-fbfc089d913772f96f9562a3dbddaed28809fe72.tar.bz2
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>
Diffstat (limited to 'builtin/pull.c')
-rw-r--r--builtin/pull.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/builtin/pull.c b/builtin/pull.c
index 33db889..9bd6a78 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -369,9 +369,10 @@ static void get_merge_heads(struct oid_array *merge_heads)
fp = xfopen(filename, "r");
while (strbuf_getline_lf(&sb, fp) != EOF) {
- if (get_oid_hex(sb.buf, &oid))
- continue; /* invalid line: does not start with SHA1 */
- if (starts_with(sb.buf + GIT_SHA1_HEXSZ, "\tnot-for-merge\t"))
+ const char *p;
+ if (parse_oid_hex(sb.buf, &oid, &p))
+ continue; /* invalid line: does not start with object ID */
+ if (starts_with(p, "\tnot-for-merge\t"))
continue; /* ref is not-for-merge */
oid_array_append(merge_heads, &oid);
}
@@ -760,7 +761,7 @@ static int get_rebase_fork_point(struct object_id *fork_point, const char *repo,
cp.no_stderr = 1;
cp.git_cmd = 1;
- ret = capture_command(&cp, &sb, GIT_SHA1_HEXSZ);
+ ret = capture_command(&cp, &sb, GIT_MAX_HEXSZ);
if (ret)
goto cleanup;
@@ -805,7 +806,7 @@ static int get_octopus_merge_base(struct object_id *merge_base,
}
/**
- * Given the current HEAD SHA1, the merge head returned from git-fetch and the
+ * Given the current HEAD oid, the merge head returned from git-fetch and the
* fork point calculated by get_rebase_fork_point(), runs git-rebase with the
* appropriate arguments and returns its exit status.
*/