From: Junio C Hamano Date: Wed, 11 Apr 2018 01:46:32 +0000 (+0900) Subject: Merge branch 'bw/c-plus-plus' into ds/lazy-load-trees X-Git-Tag: v2.18.0-rc0~62^2~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2d5792f0716605ff0059fe4b5c865d6821c0161e Merge branch 'bw/c-plus-plus' into ds/lazy-load-trees * bw/c-plus-plus: (37 commits) replace: rename 'new' variables trailer: rename 'template' variables tempfile: rename 'template' variables wrapper: rename 'template' variables environment: rename 'namespace' variables diff: rename 'template' variables environment: rename 'template' variables init-db: rename 'template' variables unpack-trees: rename 'new' variables trailer: rename 'new' variables submodule: rename 'new' variables split-index: rename 'new' variables remote: rename 'new' variables ref-filter: rename 'new' variables read-cache: rename 'new' variables line-log: rename 'new' variables imap-send: rename 'new' variables http: rename 'new' variables entry: rename 'new' variables diffcore-delta: rename 'new' variables ... --- 2d5792f0716605ff0059fe4b5c865d6821c0161e diff --cc builtin/index-pack.c index ca5a3d0248,8b87090e23..157bceb264 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@@ -448,11 -448,11 +448,11 @@@ static void *unpack_entry_data(off_t of int hdrlen; if (!is_delta_type(type)) { - hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), size) + 1; + hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), size) + 1; - git_SHA1_Init(&c); - git_SHA1_Update(&c, hdr, hdrlen); + the_hash_algo->init_fn(&c); + the_hash_algo->update_fn(&c, hdr, hdrlen); } else - sha1 = NULL; + oid = NULL; if (type == OBJ_BLOB && size > big_file_threshold) buf = fixed_buf; else @@@ -958,8 -958,9 +958,8 @@@ static void resolve_delta(struct object free(delta_data); if (!result->data) bad_object(delta_obj->idx.offset, _("failed to apply delta")); - hash_sha1_file(result->data, result->size, - type_name(delta_obj->real_type), - delta_obj->idx.oid.hash); + hash_object_file(result->data, result->size, - typename(delta_obj->real_type), &delta_obj->idx.oid); ++ type_name(delta_obj->real_type), &delta_obj->idx.oid); sha1_object(result->data, NULL, result->size, delta_obj->real_type, &delta_obj->idx.oid); counter_lock(); diff --cc builtin/replace.c index 83d3235721,303ca134dc..9f01f3fc7f --- a/builtin/replace.c +++ b/builtin/replace.c @@@ -355,7 -355,7 +355,7 @@@ static void check_one_mergetag(struct c struct tag *tag; int i; - hash_object_file(extra->value, extra->len, typename(OBJ_TAG), &tag_oid); - hash_sha1_file(extra->value, extra->len, type_name(OBJ_TAG), tag_oid.hash); ++ hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &tag_oid); tag = lookup_tag(&tag_oid); if (!tag) die(_("bad mergetag in commit '%s'"), ref); @@@ -410,7 -410,7 +410,7 @@@ static int create_graft(int argc, cons check_mergetags(commit, argc, argv); - if (write_object_file(buf.buf, buf.len, commit_type, &new)) - if (write_sha1_file(buf.buf, buf.len, commit_type, new_oid.hash)) ++ if (write_object_file(buf.buf, buf.len, commit_type, &new_oid)) die(_("could not write replacement commit for: '%s'"), old_ref); strbuf_release(&buf); diff --cc builtin/unpack-objects.c index 7235d2ffbf,e930790701..9f96949bc0 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@@ -172,8 -172,7 +172,8 @@@ static void write_cached_object(struct { struct object_id oid; - if (write_sha1_file(obj_buf->buffer, obj_buf->size, type_name(obj->type), oid.hash) < 0) + if (write_object_file(obj_buf->buffer, obj_buf->size, - typename(obj->type), &oid) < 0) ++ type_name(obj->type), &oid) < 0) die("failed to write object %s", oid_to_hex(&obj->oid)); obj->flags |= FLAG_WRITTEN; } @@@ -238,16 -237,14 +238,16 @@@ static void write_object(unsigned nr, e void *buf, unsigned long size) { if (!strict) { - if (write_object_file(buf, size, typename(type), - if (write_sha1_file(buf, size, type_name(type), obj_list[nr].oid.hash) < 0) ++ if (write_object_file(buf, size, type_name(type), + &obj_list[nr].oid) < 0) die("failed to write object"); added_object(nr, type, buf, size); free(buf); obj_list[nr].obj = NULL; } else if (type == OBJ_BLOB) { struct blob *blob; - if (write_object_file(buf, size, typename(type), - if (write_sha1_file(buf, size, type_name(type), obj_list[nr].oid.hash) < 0) ++ if (write_object_file(buf, size, type_name(type), + &obj_list[nr].oid) < 0) die("failed to write object"); added_object(nr, type, buf, size); free(buf); @@@ -261,7 -258,7 +261,7 @@@ } else { struct object *obj; int eaten; - hash_object_file(buf, size, typename(type), &obj_list[nr].oid); - hash_sha1_file(buf, size, type_name(type), obj_list[nr].oid.hash); ++ hash_object_file(buf, size, type_name(type), &obj_list[nr].oid); added_object(nr, type, buf, size); obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf, &eaten); diff --cc bulk-checkin.c index a3e1b59d0e,bb788494fd..70b14fdf41 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@@ -203,9 -203,9 +203,9 @@@ static int deflate_to_pack(struct bulk_ return error("cannot find the current offset"); header_len = xsnprintf((char *)obuf, sizeof(obuf), "%s %" PRIuMAX, - typename(type), (uintmax_t)size) + 1; + type_name(type), (uintmax_t)size) + 1; - git_SHA1_Init(&ctx); - git_SHA1_Update(&ctx, obuf, header_len); + the_hash_algo->init_fn(&ctx); + the_hash_algo->update_fn(&ctx, obuf, header_len); /* Note: idx is non-NULL when we are writing */ if ((flags & HASH_WRITE_OBJECT) != 0) diff --cc fast-import.c index 1b58fca9f0,92b89d191a..2e5d17318d --- a/fast-import.c +++ b/fast-import.c @@@ -1096,11 -1096,11 +1096,11 @@@ static int store_object git_zstream s; hdrlen = xsnprintf((char *)hdr, sizeof(hdr), "%s %lu", - typename(type), (unsigned long)dat->len) + 1; + type_name(type), (unsigned long)dat->len) + 1; - git_SHA1_Init(&c); - git_SHA1_Update(&c, hdr, hdrlen); - git_SHA1_Update(&c, dat->buf, dat->len); - git_SHA1_Final(oid.hash, &c); + the_hash_algo->init_fn(&c); + the_hash_algo->update_fn(&c, hdr, hdrlen); + the_hash_algo->update_fn(&c, dat->buf, dat->len); + the_hash_algo->final_fn(oid.hash, &c); if (oidout) oidcpy(oidout, &oid); diff --cc log-tree.c index 22b2fb6c58,2eeddbeb35..bdf23c5f7b --- a/log-tree.c +++ b/log-tree.c @@@ -499,7 -499,7 +499,7 @@@ static void show_one_mergetag(struct co int status, nth; size_t payload_size, gpg_message_offset; - hash_object_file(extra->value, extra->len, typename(OBJ_TAG), &oid); - hash_sha1_file(extra->value, extra->len, type_name(OBJ_TAG), oid.hash); ++ hash_object_file(extra->value, extra->len, type_name(OBJ_TAG), &oid); tag = lookup_tag(&oid); if (!tag) return; /* error message already given */ diff --cc read-cache.c index 28bf0db9d9,b22668bfa9..977921d90c --- a/read-cache.c +++ b/read-cache.c @@@ -1440,9 -1440,8 +1440,9 @@@ int refresh_index(struct index_state *i continue; } - replace_index_entry(istate, i, new); + replace_index_entry(istate, i, new_entry); } + trace_performance_since(start, "refresh index"); return has_errors; } diff --cc sha1_file.c index 826d7a0ae3,2288bb75cd..1b94f39c4c --- a/sha1_file.c +++ b/sha1_file.c @@@ -804,11 -805,11 +804,11 @@@ int check_sha1_signature(const unsigne return -1; /* Generate the header */ - hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(obj_type), size) + 1; + hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(obj_type), size) + 1; /* Sha1.. */ - git_SHA1_Init(&c); - git_SHA1_Update(&c, hdr, hdrlen); + the_hash_algo->init_fn(&c); + the_hash_algo->update_fn(&c, hdr, hdrlen); for (;;) { char buf[1024 * 16]; ssize_t readlen = read_istream(st, buf, sizeof(buf)); @@@ -1339,8 -1317,8 +1339,8 @@@ int pretend_object_file(void *buf, unsi { struct cached_object *co; - hash_object_file(buf, len, typename(type), oid); - hash_sha1_file(buf, len, type_name(type), sha1); - if (has_sha1_file(sha1) || find_cached_object(sha1)) ++ hash_object_file(buf, len, type_name(type), oid); + if (has_sha1_file(oid->hash) || find_cached_object(oid->hash)) return 0; ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc); co = &cached_objects[cached_object_nr++]; @@@ -1709,13 -1678,13 +1709,13 @@@ int force_object_loose(const struct obj int hdrlen; int ret; - if (has_loose_object(sha1)) + if (has_loose_object(oid->hash)) return 0; - buf = read_object(sha1, &type, &len); + buf = read_object(oid->hash, &type, &len); if (!buf) - return error("cannot read sha1_file for %s", sha1_to_hex(sha1)); + return error("cannot read sha1_file for %s", oid_to_hex(oid)); - hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), len) + 1; + hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1; - ret = write_loose_object(sha1, hdr, hdrlen, buf, len, mtime); + ret = write_loose_object(oid, hdr, hdrlen, buf, len, mtime); free(buf); return ret; @@@ -1798,9 -1767,9 +1798,9 @@@ static int index_mem(struct object_id * } if (write_object) - ret = write_object_file(buf, size, typename(type), oid); - ret = write_sha1_file(buf, size, type_name(type), oid->hash); ++ ret = write_object_file(buf, size, type_name(type), oid); else - ret = hash_object_file(buf, size, typename(type), oid); - ret = hash_sha1_file(buf, size, type_name(type), oid->hash); ++ ret = hash_object_file(buf, size, type_name(type), oid); if (re_allocated) free(buf); return ret; @@@ -1817,14 -1786,14 +1817,14 @@@ static int index_stream_convert_blob(st assert(would_convert_to_git_filter_fd(path)); convert_to_git_filter_fd(&the_index, path, fd, &sbuf, - get_safe_crlf(flags)); + get_conv_flags(flags)); if (write_object) - ret = write_object_file(sbuf.buf, sbuf.len, typename(OBJ_BLOB), - ret = write_sha1_file(sbuf.buf, sbuf.len, type_name(OBJ_BLOB), - oid->hash); ++ ret = write_object_file(sbuf.buf, sbuf.len, type_name(OBJ_BLOB), + oid); else - ret = hash_object_file(sbuf.buf, sbuf.len, typename(OBJ_BLOB), - ret = hash_sha1_file(sbuf.buf, sbuf.len, type_name(OBJ_BLOB), - oid->hash); ++ ret = hash_object_file(sbuf.buf, sbuf.len, type_name(OBJ_BLOB), + oid); strbuf_release(&sbuf); return ret; }