summaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-30 05:04:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-30 05:04:10 (GMT)
commit42c8ce1c49f862c98b35e4d89c88aa3d489d6608 (patch)
treedce3eb119c51e3d539f5a703411787d3a333b175 /upload-pack.c
parent3d241297991c6f6ac6b1e50e52a4ae35bc431f28 (diff)
parent7882fa220c1f86e3f9707270e2e94d54149394ed (diff)
downloadgit-42c8ce1c49f862c98b35e4d89c88aa3d489d6608.zip
git-42c8ce1c49f862c98b35e4d89c88aa3d489d6608.tar.gz
git-42c8ce1c49f862c98b35e4d89c88aa3d489d6608.tar.bz2
Merge branch 'bc/object-id'
Conversion from uchar[20] to struct object_id continues. * bc/object-id: (42 commits) merge-one-file: compute empty blob object ID add--interactive: compute the empty tree value Update shell scripts to compute empty tree object ID sha1_file: only expose empty object constants through git_hash_algo dir: use the_hash_algo for empty blob object ID sequencer: use the_hash_algo for empty tree object ID cache-tree: use is_empty_tree_oid sha1_file: convert cached object code to struct object_id builtin/reset: convert use of EMPTY_TREE_SHA1_BIN builtin/receive-pack: convert one use of EMPTY_TREE_SHA1_HEX wt-status: convert two uses of EMPTY_TREE_SHA1_HEX submodule: convert several uses of EMPTY_TREE_SHA1_HEX sequencer: convert one use of EMPTY_TREE_SHA1_HEX merge: convert empty tree constant to the_hash_algo builtin/merge: switch tree functions to use object_id builtin/am: convert uses of EMPTY_TREE_SHA1_BIN to the_hash_algo sha1-file: add functions for hex empty tree and blob OIDs builtin/receive-pack: avoid hard-coded constants for push certs diff: specify abbreviation size in terms of the_hash_algo upload-pack: replace use of several hard-coded constants ...
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 87b4d32..bacc92b 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -444,7 +444,7 @@ static int get_common_commits(void)
break;
default:
got_common = 1;
- memcpy(last_hex, oid_to_hex(&oid), 41);
+ oid_to_hex_r(last_hex, &oid);
if (multi_ack == 2)
packet_write_fmt(1, "ACK %s common\n", last_hex);
else if (multi_ack)
@@ -486,7 +486,7 @@ static int do_reachable_revlist(struct child_process *cmd,
"rev-list", "--stdin", NULL,
};
struct object *o;
- char namebuf[42]; /* ^ + SHA-1 + LF */
+ char namebuf[GIT_MAX_HEXSZ + 2]; /* ^ + hash + LF */
int i;
cmd->argv = argv;
@@ -555,15 +555,17 @@ static int get_reachable_list(struct object_array *src,
struct child_process cmd = CHILD_PROCESS_INIT;
int i;
struct object *o;
- char namebuf[42]; /* ^ + SHA-1 + LF */
+ char namebuf[GIT_MAX_HEXSZ + 2]; /* ^ + hash + LF */
+ const unsigned hexsz = the_hash_algo->hexsz;
if (do_reachable_revlist(&cmd, src, reachable) < 0)
return -1;
- while ((i = read_in_full(cmd.out, namebuf, 41)) == 41) {
+ while ((i = read_in_full(cmd.out, namebuf, hexsz + 1)) == hexsz + 1) {
struct object_id sha1;
+ const char *p;
- if (namebuf[40] != '\n' || get_oid_hex(namebuf, &sha1))
+ if (parse_oid_hex(namebuf, &sha1, &p) || *p != '\n')
break;
o = lookup_object(sha1.hash);
@@ -895,11 +897,9 @@ static void receive_needs(void)
}
if (!skip_prefix(line, "want ", &arg) ||
- get_oid_hex(arg, &oid_buf))
+ parse_oid_hex(arg, &oid_buf, &features))
die("git upload-pack: protocol error, "
- "expected to get sha, not '%s'", line);
-
- features = arg + 40;
+ "expected to get object ID, not '%s'", line);
if (parse_feature_request(features, "deepen-relative"))
deepen_relative = 1;