From: Junio C Hamano Date: Tue, 30 Oct 2018 06:43:42 +0000 (+0900) Subject: Merge branch 'bc/hash-transition-part-15' X-Git-Tag: v2.20.0-rc0~122 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d829d491eebddc2eefcaa9279ac4b67c7eefbd52;p=thirdparty%2Fgit.git Merge branch 'bc/hash-transition-part-15' More codepaths are moving away from hardcoded hash sizes. * bc/hash-transition-part-15: rerere: convert to use the_hash_algo submodule: make zero-oid comparison hash function agnostic apply: rename new_sha1_prefix and old_sha1_prefix apply: replace hard-coded constants tag: express constant in terms of the_hash_algo transport: use parse_oid_hex instead of a constant upload-pack: express constants in terms of the_hash_algo refs/packed-backend: express constants using the_hash_algo packfile: express constants in terms of the_hash_algo pack-revindex: express constants in terms of the_hash_algo builtin/fetch-pack: remove constants with parse_oid_hex builtin/mktree: remove hard-coded constant builtin/repack: replace hard-coded constants pack-bitmap-write: use GIT_MAX_RAWSZ for allocation object_id.cocci: match only expressions of type 'struct object_id' --- d829d491eebddc2eefcaa9279ac4b67c7eefbd52 diff --cc rerere.c index 887e26d45b,ceb98015ff..b5b2357411 --- a/rerere.c +++ b/rerere.c @@@ -462,8 -465,7 +465,8 @@@ static int handle_path(unsigned char *h * Scan the path for conflicts, do the "handle_path()" thing above, and * return the number of conflict hunks found. */ - static int handle_file(struct index_state *istate, const char *path, - unsigned char *sha1, const char *output) -static int handle_file(const char *path, unsigned char *hash, const char *output) ++static int handle_file(struct index_state *istate, ++ const char *path, unsigned char *hash, const char *output) { int has_conflicts = 0; struct rerere_io_file io; @@@ -830,7 -826,7 +833,7 @@@ static int do_plain_rerere(struct repos * conflict ID. No need to write anything out * yet. */ - ret = handle_file(r->index, path, sha1, NULL); - ret = handle_file(path, hash, NULL); ++ ret = handle_file(r->index, path, hash, NULL); if (ret != 0 && string_list_has_string(rr, path)) { remove_variant(string_list_lookup(rr, path)->util); string_list_remove(rr, path, 1); @@@ -949,8 -945,7 +952,8 @@@ static int rerere_mem_getline(struct st return 0; } - static int handle_cache(struct index_state *istate, const char *path, - unsigned char *sha1, const char *output) -static int handle_cache(const char *path, unsigned char *hash, const char *output) ++static int handle_cache(struct index_state *istate, ++ const char *path, unsigned char *hash, const char *output) { mmfile_t mmfile[3] = {{NULL}}; mmbuffer_t result = {NULL, 0}; @@@ -1031,7 -1023,7 +1034,7 @@@ static int rerere_forget_one_path(struc * Recreate the original conflict from the stages in the * index and compute the conflict ID */ - ret = handle_cache(istate, path, sha1, NULL); - ret = handle_cache(path, hash, NULL); ++ ret = handle_cache(istate, path, hash, NULL); if (ret < 1) return error(_("could not parse conflict hunks in '%s'"), path); @@@ -1048,7 -1040,7 +1051,7 @@@ if (!has_rerere_resolution(id)) continue; - handle_cache(istate, path, sha1, rerere_path(id, "thisimage")); - handle_cache(path, hash, rerere_path(id, "thisimage")); ++ handle_cache(istate, path, hash, rerere_path(id, "thisimage")); if (read_mmfile(&cur, rerere_path(id, "thisimage"))) { free(cur.ptr); error(_("failed to update conflicted state in '%s'"), path); @@@ -1080,7 -1072,7 +1083,7 @@@ * conflict in the working tree, run us again to record * the postimage. */ - handle_cache(istate, path, sha1, rerere_path(id, "preimage")); - handle_cache(path, hash, rerere_path(id, "preimage")); ++ handle_cache(istate, path, hash, rerere_path(id, "preimage")); fprintf_ln(stderr, _("Updated preimage for '%s'"), path); /* diff --cc transport.c index f4ffbd96cb,44b9ddf670..01ce11a325 --- a/transport.c +++ b/transport.c @@@ -1413,9 -1346,10 +1413,9 @@@ static void read_alternate_refs(const c fh = xfdopen(cmd.out, "r"); while (strbuf_getline_lf(&line, fh) != EOF) { struct object_id oid; + const char *p; - if (get_oid_hex(line.buf, &oid) || - line.buf[GIT_SHA1_HEXSZ]) { - if (parse_oid_hex(line.buf, &oid, &p) || - *p != ' ') { ++ if (parse_oid_hex(line.buf, &oid, &p) || *p) { warning(_("invalid line while parsing alternate refs: %s"), line.buf); break;