From patchwork Sun Aug 18 20:04:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C128C1399 for ; Sun, 18 Aug 2019 20:05:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7049285C4 for ; Sun, 18 Aug 2019 20:05:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96C95285C9; Sun, 18 Aug 2019 20:05:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8C5C285C4 for ; Sun, 18 Aug 2019 20:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727058AbfHRUFc (ORCPT ); Sun, 18 Aug 2019 16:05:32 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57922 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbfHRUFc (ORCPT ); Sun, 18 Aug 2019 16:05:32 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 8B76060736; Sun, 18 Aug 2019 20:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158730; bh=/nmn0i5q3JUP/cv3g4NowB0M04ikozX42rCfItcnQoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=n4ihViONEKbGi78gKna3QsAjBi7QC85vMNSZG8Fo7QvMxP17us4ckn7kYTJV9piXn AePaiIovaXKsyFPh4PaHwNx4NTOH7u8NRfNMOOLGcPHonspEydc5BzZKlct25P97mw g8LhKwzdBquP7mM4phusl3vFwkjV97qXuQtJP3mRqYeRZxKXuWcn6mp2LObC2j3FuH ngudiScIdbQMp90I4EaAxpTpaZoLd3gOuqRbH/7bC8msXTLtHye7IZLtqXy9XbfQat UX905TJnxO7ZcoRf2r2i1pMDnAibdLlFas5LPaZdOLCv+Etn5U/bEOq7+7BXoLa5Y7 dq2TZYxfTymXS2x7Y2y9pw8grnwMG0jmAmnC+ztdlNI96UC8HTzn9P8Mg0XosxQFRK WzjI9WbhvaazwWRk7DPr/ouiWijQxpCtjqXRFFQhPAatU96M3nLu0o/60G/8Ekp81c dmxMbvZ2ZqfCWrweeDBsK8IZJMQfpgRjn7BlrH9d4YwUlFV3PlB From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 01/26] builtin/replace: make hash size independent Date: Sun, 18 Aug 2019 20:04:02 +0000 Message-Id: <20190818200427.870753-2-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using GIT_SHA1_HEXSZ and hard-coded constants, switch to using the_hash_algo. Signed-off-by: brian m. carlson --- builtin/replace.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/replace.c b/builtin/replace.c index 644b21ca8d..4b00f1d84e 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -272,7 +272,7 @@ static int import_object(struct object_id *oid, enum object_type type, return error(_("unable to spawn mktree")); } - if (strbuf_read(&result, cmd.out, 41) < 0) { + if (strbuf_read(&result, cmd.out, the_hash_algo->hexsz + 1) < 0) { error_errno(_("unable to read from mktree")); close(fd); close(cmd.out); @@ -358,14 +358,15 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv) struct strbuf new_parents = STRBUF_INIT; const char *parent_start, *parent_end; int i; + const unsigned hexsz = the_hash_algo->hexsz; /* find existing parents */ parent_start = buf->buf; - parent_start += GIT_SHA1_HEXSZ + 6; /* "tree " + "hex sha1" + "\n" */ + parent_start += hexsz + 6; /* "tree " + "hex sha1" + "\n" */ parent_end = parent_start; while (starts_with(parent_end, "parent ")) - parent_end += 48; /* "parent " + "hex sha1" + "\n" */ + parent_end += hexsz + 8; /* "parent " + "hex sha1" + "\n" */ /* prepare new parents */ for (i = 0; i < argc; i++) { From patchwork Sun Aug 18 20:04:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D2B31399 for ; Sun, 18 Aug 2019 20:05:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E51227C2D for ; Sun, 18 Aug 2019 20:05:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 110B3285C7; Sun, 18 Aug 2019 20:05:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D7E627C2D for ; Sun, 18 Aug 2019 20:05:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727198AbfHRUFh (ORCPT ); Sun, 18 Aug 2019 16:05:37 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57926 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfHRUFd (ORCPT ); Sun, 18 Aug 2019 16:05:33 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 3D59260737; Sun, 18 Aug 2019 20:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158731; bh=fVzFyS69xZld2x+FViFNvo9u8IAZq+Ld3bt/89vjH84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=zUTS1WMn7B2P5pEMfFJB6mvsZ2XRlh9JhWMaJ3yUKr6lpLGFcGhWd7+HwgxqaWefr bLYUujf20V6bBF+nZlpTdQSeGkvpTq2+tU+rGHOWrVK3z/gUmQ274/OiwgO3C970SU 1N/DMVGqApcSnyOsjVgO3zh+6UxODEZ1tAyv5Yo0dZ8Vhf7DSLYM+BoHgVK2Y358ib KqM61HtK8tyox89CDzoo4dGemwH2lnxH1Ycb7wAIpozGJPd9tPW61uptKNVzAE+FLD 0HcAEEUb3JHnHvxSrLfGeZgf4LMNKX8yhzflhCI5cr4ZqKzQGKlzcaNOal4XPhQ+Yc BgwwbVPjn6rejwG3DtdA31U5daI8Mg43uE8J4GZjwkjSloD8Zz0zlZ0ORa5sfDA5w2 BrMLPWscKFOrTOTC+eSrkI7lAjExaG4It3rFQhMWT9S886gVLHK/zm8qs5F+uX0kua eIuNfF2h4fmCiuUyXgjyXlmq1JkHbZ/onXvgJZs6kgUkIvxX9Ow From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 02/26] patch-id: convert to use the_hash_algo Date: Sun, 18 Aug 2019 20:04:03 +0000 Message-Id: <20190818200427.870753-3-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert the two separate patch-id implementations to use the_hash_algo in their implementation. Signed-off-by: brian m. carlson Signed-off-by: René Scharfe --- builtin/patch-id.c | 11 ++++++----- diff.c | 46 +++++++++++++++++++++++----------------------- diff.h | 2 +- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/builtin/patch-id.c b/builtin/patch-id.c index bd28b80b2d..3059e525b8 100644 --- a/builtin/patch-id.c +++ b/builtin/patch-id.c @@ -1,15 +1,16 @@ +#include "cache.h" #include "builtin.h" #include "config.h" #include "diff.h" static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result) { - char name[50]; + char name[GIT_MAX_HEXSZ + 1]; if (!patchlen) return; - memcpy(name, oid_to_hex(id), GIT_SHA1_HEXSZ + 1); + memcpy(name, oid_to_hex(id), the_hash_algo->hexsz + 1); printf("%s %s\n", oid_to_hex(result), name); } @@ -60,9 +61,9 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result, { int patchlen = 0, found_next = 0; int before = -1, after = -1; - git_SHA_CTX ctx; + git_hash_ctx ctx; - git_SHA1_Init(&ctx); + the_hash_algo->init_fn(&ctx); oidclr(result); while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) { @@ -122,7 +123,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result, /* Compute the sha without whitespace */ len = remove_space(line); patchlen += len; - git_SHA1_Update(&ctx, line, len); + the_hash_algo->update_fn(&ctx, line, len); } if (!found_next) diff --git a/diff.c b/diff.c index efe42b341a..bf51c94804 100644 --- a/diff.c +++ b/diff.c @@ -5978,7 +5978,7 @@ static void diff_summary(struct diff_options *opt, struct diff_filepair *p) } struct patch_id_t { - git_SHA_CTX *ctx; + git_hash_ctx *ctx; int patchlen; }; @@ -5995,16 +5995,16 @@ static int remove_space(char *line, int len) return dst - line; } -void flush_one_hunk(struct object_id *result, git_SHA_CTX *ctx) +void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx) { unsigned char hash[GIT_MAX_RAWSZ]; unsigned short carry = 0; int i; - git_SHA1_Final(hash, ctx); - git_SHA1_Init(ctx); + the_hash_algo->final_fn(hash, ctx); + the_hash_algo->init_fn(ctx); /* 20-byte sum, with carry */ - for (i = 0; i < GIT_SHA1_RAWSZ; ++i) { + for (i = 0; i < the_hash_algo->rawsz; ++i) { carry += result->hash[i] + hash[i]; result->hash[i] = carry; carry >>= 8; @@ -6018,21 +6018,21 @@ static void patch_id_consume(void *priv, char *line, unsigned long len) new_len = remove_space(line, len); - git_SHA1_Update(data->ctx, line, new_len); + the_hash_algo->update_fn(data->ctx, line, new_len); data->patchlen += new_len; } -static void patch_id_add_string(git_SHA_CTX *ctx, const char *str) +static void patch_id_add_string(git_hash_ctx *ctx, const char *str) { - git_SHA1_Update(ctx, str, strlen(str)); + the_hash_algo->update_fn(ctx, str, strlen(str)); } -static void patch_id_add_mode(git_SHA_CTX *ctx, unsigned mode) +static void patch_id_add_mode(git_hash_ctx *ctx, unsigned mode) { /* large enough for 2^32 in octal */ char buf[12]; int len = xsnprintf(buf, sizeof(buf), "%06o", mode); - git_SHA1_Update(ctx, buf, len); + the_hash_algo->update_fn(ctx, buf, len); } /* returns 0 upon success, and writes result into oid */ @@ -6040,10 +6040,10 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid { struct diff_queue_struct *q = &diff_queued_diff; int i; - git_SHA_CTX ctx; + git_hash_ctx ctx; struct patch_id_t data; - git_SHA1_Init(&ctx); + the_hash_algo->init_fn(&ctx); memset(&data, 0, sizeof(struct patch_id_t)); data.ctx = &ctx; oidclr(oid); @@ -6076,27 +6076,27 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid len2 = remove_space(p->two->path, strlen(p->two->path)); patch_id_add_string(&ctx, "diff--git"); patch_id_add_string(&ctx, "a/"); - git_SHA1_Update(&ctx, p->one->path, len1); + the_hash_algo->update_fn(&ctx, p->one->path, len1); patch_id_add_string(&ctx, "b/"); - git_SHA1_Update(&ctx, p->two->path, len2); + the_hash_algo->update_fn(&ctx, p->two->path, len2); if (p->one->mode == 0) { patch_id_add_string(&ctx, "newfilemode"); patch_id_add_mode(&ctx, p->two->mode); patch_id_add_string(&ctx, "---/dev/null"); patch_id_add_string(&ctx, "+++b/"); - git_SHA1_Update(&ctx, p->two->path, len2); + the_hash_algo->update_fn(&ctx, p->two->path, len2); } else if (p->two->mode == 0) { patch_id_add_string(&ctx, "deletedfilemode"); patch_id_add_mode(&ctx, p->one->mode); patch_id_add_string(&ctx, "---a/"); - git_SHA1_Update(&ctx, p->one->path, len1); + the_hash_algo->update_fn(&ctx, p->one->path, len1); patch_id_add_string(&ctx, "+++/dev/null"); } else { patch_id_add_string(&ctx, "---a/"); - git_SHA1_Update(&ctx, p->one->path, len1); + the_hash_algo->update_fn(&ctx, p->one->path, len1); patch_id_add_string(&ctx, "+++b/"); - git_SHA1_Update(&ctx, p->two->path, len2); + the_hash_algo->update_fn(&ctx, p->two->path, len2); } if (diff_header_only) @@ -6108,10 +6108,10 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid if (diff_filespec_is_binary(options->repo, p->one) || diff_filespec_is_binary(options->repo, p->two)) { - git_SHA1_Update(&ctx, oid_to_hex(&p->one->oid), - GIT_SHA1_HEXSZ); - git_SHA1_Update(&ctx, oid_to_hex(&p->two->oid), - GIT_SHA1_HEXSZ); + the_hash_algo->update_fn(&ctx, oid_to_hex(&p->one->oid), + the_hash_algo->hexsz); + the_hash_algo->update_fn(&ctx, oid_to_hex(&p->two->oid), + the_hash_algo->hexsz); continue; } @@ -6128,7 +6128,7 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid } if (!stable) - git_SHA1_Final(oid->hash, &ctx); + the_hash_algo->final_fn(oid->hash, &ctx); return 0; } diff --git a/diff.h b/diff.h index c2c3056810..7f8f024feb 100644 --- a/diff.h +++ b/diff.h @@ -438,7 +438,7 @@ int run_diff_index(struct rev_info *revs, int cached); int do_diff_cache(const struct object_id *, struct diff_options *); int diff_flush_patch_id(struct diff_options *, struct object_id *, int, int); -void flush_one_hunk(struct object_id *, git_SHA_CTX *); +void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx); int diff_result_code(struct diff_options *, int); From patchwork Sun Aug 18 20:04:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C849A13A0 for ; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB0B4285C4 for ; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFCC1285C7; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CA52285CC for ; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727191AbfHRUFg (ORCPT ); Sun, 18 Aug 2019 16:05:36 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57932 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbfHRUFd (ORCPT ); Sun, 18 Aug 2019 16:05:33 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 1BC756047B; Sun, 18 Aug 2019 20:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158732; bh=JhBZFnOaQjAoCia784S193pbaRGrvBbZfYGG9sF8kA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=D3SJI3NLEGzKDJ/AGDs0soQ7LiMQYl5ny/wrfc9RUKBCPGuztOWQSAh4ozSk/WZQA 4q9xB63Lg0L73WKveqvm9tUvO1Jp26iP1ydGoAd1Yrd+Rv5TMNg2ZzqzHvt3qIjpgM kyVZFBI0aJnQyv+PhPDDuKNfBhDIYyx3pkst01NLfcFEHiRC9LsA0fuO+SXS/5kEd2 o3tb+Td3hrKSjQQXJJw1s3ziApUco1KlC7Bq8N4k7eacUY6Ai1FwmVOpZKWNBC9EtS SZJ/bVyntEjzkpiFelYa+v6r5YYwH9zaeNQWOMSLHw3v5nASTZtdIks/GMdvN3jb+O 1yr5n3G4QtKEr7VmTndzoztyZQSXcXyE6sYPXlBv/8qba47DcNCz8RCb0VX+QbBk4z XxkiiCVjK2RFKublRpGSwhhFED9zPN9kx6j0Hk1/kZNkC7LTbL3101CzyXWsitUbOZ OX8L3gE3/wR/UMqkF57h2veoRBcEAFSwKQ8YB5Dgx2KwNBNVP6c From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 03/26] fetch-pack: use parse_oid_hex Date: Sun, 18 Aug 2019 20:04:04 +0000 Message-Id: <20190818200427.870753-4-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of hard-coding constants, use parse_oid_hex to compute a pointer and use it in further parsing operations. Signed-off-by: brian m. carlson --- fetch-pack.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 65be043f2a..1f56b8a6d7 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -168,16 +168,16 @@ static enum ack_type get_ack(struct packet_reader *reader, if (!strcmp(reader->line, "NAK")) return NAK; if (skip_prefix(reader->line, "ACK ", &arg)) { - if (!get_oid_hex(arg, result_oid)) { - arg += 40; - len -= arg - reader->line; + const char *p; + if (!parse_oid_hex(arg, result_oid, &p)) { + len -= p - reader->line; if (len < 1) return ACK; - if (strstr(arg, "continue")) + if (strstr(p, "continue")) return ACK_continue; - if (strstr(arg, "common")) + if (strstr(p, "common")) return ACK_common; - if (strstr(arg, "ready")) + if (strstr(p, "ready")) return ACK_ready; return ACK; } From patchwork Sun Aug 18 20:04:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6709517E2 for ; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55DA7285C4 for ; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47593285C9; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2976285C4 for ; Sun, 18 Aug 2019 20:05:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727181AbfHRUFf (ORCPT ); Sun, 18 Aug 2019 16:05:35 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57932 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbfHRUFe (ORCPT ); Sun, 18 Aug 2019 16:05:34 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id C741060736; Sun, 18 Aug 2019 20:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158733; bh=TBcQjB7XaHafbpe/HgQ4Z66kSJ11gWytYQ1yFIJT3U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=ilaApJauB2LfttDZk065r4GsTiNaslnFqjALqyXpEzAns/FqeTPKDqs6a+qj8kGHD RN/K96OksS+66g6XR1Kry3hw63RprQp8iGpbujv5x9MEppaRrBj/WMkqxA/vGueYKA z4mek8DqS5R5x7Ytoj+s1iGKM2KBhnjTNagHVAWmZK3VbEEPrki+pYS3R/bfXJ4uxZ wGYqazu1mPIAhshPcdck0eXhpSTRXY2BRoitTphdPLvPBXPU9PcLgmRw+CA7rwVym7 KyiwQba/4hoaAOapvbnqKss+KrQCFpetaqIMFWHWOqScKAx9F4/I2X7dtDnHTHs0wu +vltrx/s0q4NbPXdfmw8SFSjBMTFlG70qtV8QXW/U8IofCninVXgqVoBPWSrG1UDP5 XkaT477JDs80N5XkOn0gNVPhNG6hvhG12RT5t+lHQsO5sv5f9fgs5rabfelLprVzes kAOJQWedr480EE+rshY+zQmj/dBASt2NZQfmmN37Ps3TJoIKfhC From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 04/26] builtin/receive-pack: switch to use the_hash_algo Date: Sun, 18 Aug 2019 20:04:05 +0000 Message-Id: <20190818200427.870753-5-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The push cert code uses HMAC-SHA-1 to create a nonce. This is a secure use of SHA-1 which is not affected by its collision resistance (or lack thereof). However, it makes sense for us to use a better algorithm if one is available, one which may even be more performant. Futhermore, until we have specialized functions for computing the hex value of an arbitrary function, it simplifies the code greatly to use the same hash algorithm everywhere. Switch this code to use GIT_MAX_BLKSZ and the_hash_algo for computing the push cert nonce, and rename the hmac_sha1 function to simply "hmac". Signed-off-by: brian m. carlson --- builtin/receive-pack.c | 44 ++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index dcf385511f..402edf34d8 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -417,24 +417,22 @@ static int copy_to_sideband(int in, int out, void *arg) return 0; } -#define HMAC_BLOCK_SIZE 64 - -static void hmac_sha1(unsigned char *out, +static void hmac(unsigned char *out, const char *key_in, size_t key_len, const char *text, size_t text_len) { - unsigned char key[HMAC_BLOCK_SIZE]; - unsigned char k_ipad[HMAC_BLOCK_SIZE]; - unsigned char k_opad[HMAC_BLOCK_SIZE]; + unsigned char key[GIT_MAX_BLKSZ]; + unsigned char k_ipad[GIT_MAX_BLKSZ]; + unsigned char k_opad[GIT_MAX_BLKSZ]; int i; - git_SHA_CTX ctx; + git_hash_ctx ctx; /* RFC 2104 2. (1) */ - memset(key, '\0', HMAC_BLOCK_SIZE); - if (HMAC_BLOCK_SIZE < key_len) { - git_SHA1_Init(&ctx); - git_SHA1_Update(&ctx, key_in, key_len); - git_SHA1_Final(key, &ctx); + memset(key, '\0', GIT_MAX_BLKSZ); + if (the_hash_algo->blksz < key_len) { + the_hash_algo->init_fn(&ctx); + the_hash_algo->update_fn(&ctx, key_in, key_len); + the_hash_algo->final_fn(key, &ctx); } else { memcpy(key, key_in, key_len); } @@ -446,29 +444,29 @@ static void hmac_sha1(unsigned char *out, } /* RFC 2104 2. (3) & (4) */ - git_SHA1_Init(&ctx); - git_SHA1_Update(&ctx, k_ipad, sizeof(k_ipad)); - git_SHA1_Update(&ctx, text, text_len); - git_SHA1_Final(out, &ctx); + the_hash_algo->init_fn(&ctx); + the_hash_algo->update_fn(&ctx, k_ipad, sizeof(k_ipad)); + the_hash_algo->update_fn(&ctx, text, text_len); + the_hash_algo->final_fn(out, &ctx); /* RFC 2104 2. (6) & (7) */ - git_SHA1_Init(&ctx); - git_SHA1_Update(&ctx, k_opad, sizeof(k_opad)); - git_SHA1_Update(&ctx, out, GIT_SHA1_RAWSZ); - git_SHA1_Final(out, &ctx); + the_hash_algo->init_fn(&ctx); + the_hash_algo->update_fn(&ctx, k_opad, sizeof(k_opad)); + the_hash_algo->update_fn(&ctx, out, the_hash_algo->rawsz); + the_hash_algo->final_fn(out, &ctx); } static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp) { struct strbuf buf = STRBUF_INIT; - unsigned char sha1[GIT_SHA1_RAWSZ]; + unsigned char hash[GIT_MAX_RAWSZ]; strbuf_addf(&buf, "%s:%"PRItime, path, stamp); - hmac_sha1(sha1, buf.buf, buf.len, cert_nonce_seed, strlen(cert_nonce_seed)); + hmac(hash, buf.buf, buf.len, cert_nonce_seed, strlen(cert_nonce_seed)); strbuf_release(&buf); /* RFC 2104 5. HMAC-SHA1-80 */ - strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, GIT_SHA1_HEXSZ, sha1_to_hex(sha1)); + strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, (int)the_hash_algo->hexsz, sha1_to_hex(hash)); return strbuf_detach(&buf, NULL); } From patchwork Sun Aug 18 20:04:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35D3F1399 for ; Sun, 18 Aug 2019 20:05:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25D2128382 for ; Sun, 18 Aug 2019 20:05:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A9B8285C8; Sun, 18 Aug 2019 20:05:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF42728382 for ; Sun, 18 Aug 2019 20:05:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbfHRUFf (ORCPT ); Sun, 18 Aug 2019 16:05:35 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57942 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbfHRUFe (ORCPT ); Sun, 18 Aug 2019 16:05:34 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 885C36073E; Sun, 18 Aug 2019 20:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158733; bh=0O9hDoNy7NpmY7YUxFAQGwnA7qjnRaIxcWNwkK0iILA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=Gu/2ZVYaWW2KKPEFjZN+sCb7qWRNzJhOWvqn9VFHb7Fi3+J0t5SuWcgke62CUW4L9 AL3ALaFvdFYw9ejcOLjV51HC44ae6k14/Xk84h8/Hg+/99APUNwYQBFKFwxmFN89mH qHkzzfL9/HlqMUWc5Ur8qrK/kEDc1EaPC6u6fTlEv4kxrIy9ACGVntLAH8SWDN5n78 ZD4PM/OWRkr7MjwnsZju//gPpkyqdHUAPBuRYJ756aDQtHD3yBjoJV8icbkvEGmkt6 YdjdnzlpT6BemFeKPXTktGiI4p6et+r+VUNYCt/98ENqpeT5okUXwY1J7NB4U+hTO5 vn+/qWhtTsaQGn/YOqZ81QcCeFanPWvsnr/t9dH/eZlGt3CavrHRnT3IQ0g/mIMigo P8Ly9d/GFZ/V7eMFXvghLxANWq61BbfnsiXPRUe83ZrNIMGfr35fyQaf30JyMyVyru Rt/RYT8UUF+ECBb0qIaw/aIhxbyFggqpnMTwDDX/NdDJdWSszrY From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 05/26] builtin/blame: switch uses of GIT_SHA1_HEXSZ to the_hash_algo Date: Sun, 18 Aug 2019 20:04:06 +0000 Message-Id: <20190818200427.870753-6-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch several uses of GIT_SHA1_HEXSZ to the_hash_algo. Signed-off-by: brian m. carlson --- builtin/blame.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/builtin/blame.c b/builtin/blame.c index b6534d4dea..5a0c0c2312 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -460,7 +460,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int for (cnt = 0; cnt < ent->num_lines; cnt++) { char ch; - int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev; + int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? the_hash_algo->hexsz : abbrev; if (opt & OUTPUT_COLOR_LINE) { if (cnt > 0) { @@ -885,6 +885,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix) struct range_set ranges; unsigned int range_i; long anchor; + const int hexsz = the_hash_algo->hexsz; setup_default_color_by_age(); git_config(git_blame_config, &output_option); @@ -931,11 +932,11 @@ int cmd_blame(int argc, const char **argv, const char *prefix) } else if (show_progress < 0) show_progress = isatty(2); - if (0 < abbrev && abbrev < GIT_SHA1_HEXSZ) + if (0 < abbrev && abbrev < hexsz) /* one more abbrev length is needed for the boundary commit */ abbrev++; else if (!abbrev) - abbrev = GIT_SHA1_HEXSZ; + abbrev = hexsz; if (revs_file && read_ancestry(revs_file)) die_errno("reading graft file '%s' failed", revs_file); From patchwork Sun Aug 18 20:04:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57C6B13A0 for ; Sun, 18 Aug 2019 20:05:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4988328382 for ; Sun, 18 Aug 2019 20:05:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E3AE285C7; Sun, 18 Aug 2019 20:05:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9B8D28382 for ; Sun, 18 Aug 2019 20:05:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727234AbfHRUFq (ORCPT ); Sun, 18 Aug 2019 16:05:46 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57950 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727118AbfHRUFf (ORCPT ); Sun, 18 Aug 2019 16:05:35 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 3501D60745; Sun, 18 Aug 2019 20:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158734; bh=xP48SyKW1icnWdBFj8Yns9F9h6R8g8uZ4exKyORwwTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=BzRiSAl2O/olI2w1GRPRYPOaxSu9yqu3c3Ae7goKeUwtrb467q3zz6Uh0Ceq94Btv dbuG53rNzdfhiHmMDuZIujoPB4Jxa81jxeB7F/TNvYROEpUqXa9iy4TDhcWWFPIkOv dMLGTHgADWh5S7b3YjKaAl1WvHnirHIIVgdFk816Do8lxEWl4f7ZoIVDSZ0VXzxCsJ dY+DOctPhoLq7M+bbGvNI8xms1zFP3V/4Z+SlWEYlEv0zVE8s3oXehUGTJ4jlbrXax hAEkA6BauCc+Gx6IAiU/zfbt+7UvxYxSHQW7F30vCdgVwIEiKaPpg3ekdbcW3UUE44 jnlJrf/ELrSYuK2CJR38ndOGLFVpsmFMXiA7H1Vnnjqs4rkIE5cKOYXHNVRxR6qqqF FLB7uGTl92zCpG+h46e8l+8oOZBvAQUgUMzP3fIxvMt9sFnDtlFK+r2KOLc4ACDFnx D3kTEdKhSgS3JSFkd84mMJnSZiwygnv7FkieKlYdLNnZehcG+Va From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 06/26] builtin/rev-parse: switch to use the_hash_algo Date: Sun, 18 Aug 2019 20:04:07 +0000 Message-Id: <20190818200427.870753-7-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch several hard-coded uses of the constant 40 to references to the_hash_algo. Signed-off-by: brian m. carlson --- builtin/rev-parse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index f8bbe6d47e..308c67e4fc 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -593,6 +593,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) const char *name = NULL; struct object_context unused; struct strbuf buf = STRBUF_INIT; + const int hexsz = the_hash_algo->hexsz; if (argc > 1 && !strcmp("--parseopt", argv[1])) return cmd_parseopt(argc - 1, argv + 1, prefix); @@ -730,8 +731,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) abbrev = strtoul(arg, NULL, 10); if (abbrev < MINIMUM_ABBREV) abbrev = MINIMUM_ABBREV; - else if (40 <= abbrev) - abbrev = 40; + else if (hexsz <= abbrev) + abbrev = hexsz; continue; } if (!strcmp(arg, "--sq")) { From patchwork Sun Aug 18 20:04:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5837D17E2 for ; Sun, 18 Aug 2019 20:05:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ABA827C2D for ; Sun, 18 Aug 2019 20:05:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F0F6285C4; Sun, 18 Aug 2019 20:05:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6D7928382 for ; Sun, 18 Aug 2019 20:05:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727201AbfHRUFi (ORCPT ); Sun, 18 Aug 2019 16:05:38 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57932 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727127AbfHRUFg (ORCPT ); Sun, 18 Aug 2019 16:05:36 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id D3C5D60748; Sun, 18 Aug 2019 20:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158735; bh=INVjGOkpeZlh5ucqkeOAjH8Scw2PZtu0y8eyEwGBhvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=VROTxXsrX3S2r4HChw1j3Y2tt6dHzoRtSuIvp5LsqU3wYC7yqdY1WidNfhN15k35B 7FkWCANt8Uqw6ZIZA5eVCm8XzmJGfWfOx/7viu5NAcQsVaZCbUDy8c2VTxV9g3sEqi xJRWfexjZw7/Mv7V8nBRelmnZ28lFBbGKGnHBxWslQ6tLnsdhl7G7dMdxIVW+ysYXa 2WYKQv+XMhN2NBKKK+aAC4ZPGS8VHhHZUDMWB0/HjD+H4wJoxJVSHA5uJKUMzrvLAe i8d1sZ+yhFcknBS1BPwFqEWrVd6LGdvjFTT8sQyg39ZQ2/MmU+s+hoY5cD57/a3RMq zrNwBOcOd7BJZefO2PbYA7iwz83qxf1fADI7h1aqdCWBhYvRLdaD0cFAkCPf/H0F6J 1KBYV+DewHvWgGl6C9ECshjVg39lH7KQ8HrvvJAzTVm/lVx91AgOHOlFFfVb/+EQh+ ejFF+oimSa28XeF6sbB0RqP3hGlEPkEVf7JedgCCbCJ1h5mPydA From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 07/26] blame: remove needless comparison with GIT_SHA1_HEXSZ Date: Sun, 18 Aug 2019 20:04:08 +0000 Message-Id: <20190818200427.870753-8-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When faking a working tree commit, we read in lines from MERGE_HEAD into a strbuf. Because the strbuf is NUL-terminated and get_oid_hex will fail if it unexpectedly encounters a NUL, the check for the length of the line is unnecessary. There is no optimization benefit from this case, either, since on failure we call die. Remove this check, since it is no longer needed. Signed-off-by: brian m. carlson --- blame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blame.c b/blame.c index 36a2e7ef11..6596d8de88 100644 --- a/blame.c +++ b/blame.c @@ -144,7 +144,7 @@ static void append_merge_parents(struct repository *r, while (!strbuf_getwholeline_fd(&line, merge_head, '\n')) { struct object_id oid; - if (line.len < GIT_SHA1_HEXSZ || get_oid_hex(line.buf, &oid)) + if (get_oid_hex(line.buf, &oid)) die("unknown line in '%s': %s", git_path_merge_head(r), line.buf); tail = append_parent(r, tail, &oid); From patchwork Sun Aug 18 20:04:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDB9813A0 for ; Sun, 18 Aug 2019 20:06:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDFB327C2D for ; Sun, 18 Aug 2019 20:06:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B280D284DB; Sun, 18 Aug 2019 20:06:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D6F527C2D for ; Sun, 18 Aug 2019 20:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727226AbfHRUFo (ORCPT ); Sun, 18 Aug 2019 16:05:44 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57942 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbfHRUFh (ORCPT ); Sun, 18 Aug 2019 16:05:37 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 78EDB60736; Sun, 18 Aug 2019 20:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158735; bh=O7wPqFA8Zmb9aa/+aWJG42J4CkB5WhXr+92fLQIoHY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=Hs1yARsdSX+gfWuPscbn65SUmPqP7y/1SPimorfhFwoYQlcHM3cW+qHO+XE/+dOZl SlsngBD6JC/2GmlENASsBRgXQ+ogqkKQ/i7kdy0EPR3eEifLZlFcVK9JWuBVehkYo+ 2rMTu2J26sxa7BaRuA4D+urCb8E3MuOqHqCJKw6S4q0v+SIiBT/xRF/QFC5xSVsUQf +lP8fTa++IeUeFH8ObQ81Effe3GiRFVSJdik5aujdyoEnnAMPUjH/KAMiz0vx63wvw Dnqo9ehQ73QBmo5+D3mzYvDSynwHDt73WcDnYPfRA5nPCN/UcmwPTEv3xWpYkF8IxE TYqBlBlz0kxv0rS3ngvi/H82QKF/O5AgkY4mT0s1BymmfzzdNfIULW/0s0WUxsKRBx 4ZDRtsVOmFwew4K+d4mszj7tdppxCYOd81nwr+tBl6KsR1BuVJWvIYAmBSelSkxdNr CnCUkiFuj6PQSAffzCi1B5d+r+RHuD7uA7DQtxXxg8QFV0yOhn/ From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 08/26] show-index: switch hard-coded constants to the_hash_algo Date: Sun, 18 Aug 2019 20:04:09 +0000 Message-Id: <20190818200427.870753-9-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP show-index uses a variety of hard-coded constants to enumerate the values in pack indices. Switch these hard-coded constants to use the_hash_algo or GIT_MAX_RAWSZ, as appropriate, and convert one instance of an unsigned char array to struct object_id. Signed-off-by: brian m. carlson --- builtin/show-index.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/show-index.c b/builtin/show-index.c index a6e678809e..e95b84e8eb 100644 --- a/builtin/show-index.c +++ b/builtin/show-index.c @@ -11,6 +11,7 @@ int cmd_show_index(int argc, const char **argv, const char *prefix) unsigned nr; unsigned int version; static unsigned int top_index[256]; + const unsigned hashsz = the_hash_algo->rawsz; if (argc != 1) usage(show_index_usage); @@ -36,9 +37,9 @@ int cmd_show_index(int argc, const char **argv, const char *prefix) } if (version == 1) { for (i = 0; i < nr; i++) { - unsigned int offset, entry[6]; + unsigned int offset, entry[(GIT_MAX_RAWSZ + 4) / sizeof(unsigned int)]; - if (fread(entry, 4 + 20, 1, stdin) != 1) + if (fread(entry, 4 + hashsz, 1, stdin) != 1) die("unable to read entry %u/%u", i, nr); offset = ntohl(entry[0]); printf("%u %s\n", offset, sha1_to_hex((void *)(entry+1))); @@ -46,13 +47,13 @@ int cmd_show_index(int argc, const char **argv, const char *prefix) } else { unsigned off64_nr = 0; struct { - unsigned char sha1[20]; + struct object_id oid; uint32_t crc; uint32_t off; } *entries; ALLOC_ARRAY(entries, nr); for (i = 0; i < nr; i++) - if (fread(entries[i].sha1, 20, 1, stdin) != 1) + if (fread(entries[i].oid.hash, hashsz, 1, stdin) != 1) die("unable to read sha1 %u/%u", i, nr); for (i = 0; i < nr; i++) if (fread(&entries[i].crc, 4, 1, stdin) != 1) @@ -77,7 +78,7 @@ int cmd_show_index(int argc, const char **argv, const char *prefix) } printf("%" PRIuMAX " %s (%08"PRIx32")\n", (uintmax_t) offset, - sha1_to_hex(entries[i].sha1), + oid_to_hex(&entries[i].oid), ntohl(entries[i].crc)); } free(entries); From patchwork Sun Aug 18 20:04:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 575F117E2 for ; Sun, 18 Aug 2019 20:05:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4985E28382 for ; Sun, 18 Aug 2019 20:05:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E3BC285C7; Sun, 18 Aug 2019 20:05:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF4CB284DB for ; Sun, 18 Aug 2019 20:05:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727218AbfHRUFn (ORCPT ); Sun, 18 Aug 2019 16:05:43 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57932 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727193AbfHRUFh (ORCPT ); Sun, 18 Aug 2019 16:05:37 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 940AE6074A; Sun, 18 Aug 2019 20:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158736; bh=wb6TebVtJICo//QuG0F7rBrVfSsdL9kAs81QJQZpYIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=XwMHczYefHG2NYY2tAha6Z+vGjvuy4q+v0AENWsCkA84nSern44OvfNAm/y3RNWSg 9E/B0FqHu+hZNGZ0X6TCZRqvGAoKx30FcRW7fIHgriSQzCfG+gwbl5EUm35UKfehBt j55ioKd3B7L4Zv4oxxx1dV6PfDYG8k390pQHboiKft03SnayfJiCO7rmfGP7BqfGxn diI/tbDfPUbJ56P6UhVgHDsClyPTUB8Sud0SO8jXaAP+B0a5NzUQVyYbicRqhQP2EK IFq/PDKaysCmCCyNQI3qyhXjjmYQg0ER1D/NNLLcNyIo4K7S2KJ+kd9BhUgwfgxqM0 5xSOMNWUbyRHeHBJFu9DkMzqpzOHMqMcuaMbq/0asc6ELpQIyQNEdz9Vwe0VeniFzj qTiKSABMhv8LG4Y07hmhI1ATtYul8gkzJKAejpl1HFl7z39Yfv5VydMpT5/fJszl8M 3iEqNpGAt689Vt4OZNhKInw2j2/H76MagP6pvQlHsTIE+5D1d4r From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 09/26] connected: switch GIT_SHA1_HEXSZ to the_hash_algo Date: Sun, 18 Aug 2019 20:04:10 +0000 Message-Id: <20190818200427.870753-10-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch various uses of GIT_SHA1_HEXSZ to reference the_hash_algo instead. Signed-off-by: brian m. carlson --- connected.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/connected.c b/connected.c index cd9b324afa..7cd3bc9979 100644 --- a/connected.c +++ b/connected.c @@ -28,6 +28,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data, struct packed_git *new_pack = NULL; struct transport *transport; size_t base_len; + const unsigned hexsz = the_hash_algo->hexsz; if (!opt) opt = &defaults; @@ -99,7 +100,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data, sigchain_push(SIGPIPE, SIG_IGN); - commit[GIT_SHA1_HEXSZ] = '\n'; + commit[hexsz] = '\n'; do { /* * If index-pack already checked that: @@ -112,8 +113,8 @@ int check_connected(oid_iterate_fn fn, void *cb_data, if (new_pack && find_pack_entry_one(oid.hash, new_pack)) continue; - memcpy(commit, oid_to_hex(&oid), GIT_SHA1_HEXSZ); - if (write_in_full(rev_list.in, commit, GIT_SHA1_HEXSZ + 1) < 0) { + memcpy(commit, oid_to_hex(&oid), hexsz); + if (write_in_full(rev_list.in, commit, hexsz + 1) < 0) { if (errno != EPIPE && errno != EINVAL) error_errno(_("failed write to rev-list")); err = -1; From patchwork Sun Aug 18 20:04:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2FAE13A0 for ; Sun, 18 Aug 2019 20:05:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D56BE28382 for ; Sun, 18 Aug 2019 20:05:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA058285C7; Sun, 18 Aug 2019 20:05:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72DA0284DB for ; Sun, 18 Aug 2019 20:05:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727215AbfHRUFl (ORCPT ); Sun, 18 Aug 2019 16:05:41 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57968 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727199AbfHRUFi (ORCPT ); Sun, 18 Aug 2019 16:05:38 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 3BEFB6075B; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158737; bh=6F5x8SuAlKA42m1Akf2Iqxsl2men4kZfjmMEVU/UwgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=dVgTTrlwlsGZkRPoagf4aUrsVJI7zQuSFkDa7IefmANcND/KTIPxNwFAzlWAzqFRh OL1Fg493sFWGpn6VNmaiGgYwA0xGizSUPV3YjC5u9Zzr0rxGpSATaM5+vltGxGeDtt BfZRkAxNxPnIDUauqZnKu5wXdfZnzbduEtNDx0TnVBkQEx4QIQnqS2/npY5z8W4gXi GPO7PnVOqYwdsS9w536cpAyxApOlgu5L0626LJLyIRgs6COTymbnJr/uaaEc8IAeNZ XN40dLEFp3/omwxG/Vwsv2P3KF5VBWkoL2Ps9Y5/nwtfXsg2EhYO7N/+1CNSbrzyOC nqQs2KB6p17dH8XMCc9lKyTWgeoll5c2EkqT8VV4FB/d3bddOHJUT18P7TgaFXH81Z W5A+tmd2XXI+iV/DeyDUqJ13AscpCJthZIlI/HeJ0LSSXbPB21kmn4g0n0iWyR2gTn U42IRzmrWH2OTmsxZwANBg4eLlmFPK1Rs2RR6e1ANi8yrQeTiqf From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 10/26] bundle: switch to use the_hash_algo Date: Sun, 18 Aug 2019 20:04:11 +0000 Message-Id: <20190818200427.870753-11-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch a use of the constant 40 and a use of GIT_SHA1_HEXSZ to use the_hash_algo instead. Signed-off-by: brian m. carlson --- bundle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle.c b/bundle.c index b5d21cd80f..a85ed3f7bc 100644 --- a/bundle.c +++ b/bundle.c @@ -282,7 +282,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs) struct object *object = revs->pending.objects[i].item; if (object->flags & UNINTERESTING) write_or_die(pack_objects.in, "^", 1); - write_or_die(pack_objects.in, oid_to_hex(&object->oid), GIT_SHA1_HEXSZ); + write_or_die(pack_objects.in, oid_to_hex(&object->oid), the_hash_algo->hexsz); write_or_die(pack_objects.in, "\n", 1); } close(pack_objects.in); @@ -414,7 +414,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs) } ref_count++; - write_or_die(bundle_fd, oid_to_hex(&e->item->oid), 40); + write_or_die(bundle_fd, oid_to_hex(&e->item->oid), the_hash_algo->hexsz); write_or_die(bundle_fd, " ", 1); write_or_die(bundle_fd, display_ref, strlen(display_ref)); write_or_die(bundle_fd, "\n", 1); From patchwork Sun Aug 18 20:04:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4697F13A0 for ; Sun, 18 Aug 2019 20:05:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38ABB27C2D for ; Sun, 18 Aug 2019 20:05:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CBF1284DB; Sun, 18 Aug 2019 20:05:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D849A27C2D for ; Sun, 18 Aug 2019 20:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727208AbfHRUFk (ORCPT ); Sun, 18 Aug 2019 16:05:40 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57972 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727127AbfHRUFj (ORCPT ); Sun, 18 Aug 2019 16:05:39 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id E4E166075D; Sun, 18 Aug 2019 20:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158738; bh=bgbXKTiJM2m/x6P3P/dWn8KaL5uLExsrWPeawxx3dzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=hIibQfkSMqUsD2HdraGMGVMH3oXA6SrarQ13wd6KpDhEvBRyRSJ0eGoJUZvKan1ZZ vJNc4qZf496g75ogDNLXmUVHCt55vP9eeF0DYUjZo9NjCEpDoMT6UHL2u0GpttaX9r /hNRDcwsVONU6a3FJ+VQJMUnGDavivrdPTExyGPhmAI5R5PSkHENTcyaiEBCwiaqLG OXlnndV/ez9S6a+tqyzWJuAEHG0CKNq6U+A6pP7gt5oPHDZUcrIOwoP+5Og9RyrTwC L5AXzmJh6ljz0fkGnxMGhXlEqtTpd639mufPNk1R41JcI/ILLIHJPVxIMm9g4ziXaZ eFokh00Krkd/fGDErQMBb0/7cxkypanojpIFRPFTtcws3syC1ABj5B/pw0cUt3xCsR yrZlE+yNrNB05ylflkqswGrGLR5WFHTQ/M8Fc4Kzl5Qew81bNqVJrdRo2pw2DGoEem q/YyYf4yINnwX2Wo9LusVFRlMtiA5ZtUmP9eDvs9V5Zmng+r6Pl From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 11/26] combine-diff: replace GIT_SHA1_HEXSZ with the_hash_algo Date: Sun, 18 Aug 2019 20:04:12 +0000 Message-Id: <20190818200427.870753-12-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: brian m. carlson --- combine-diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/combine-diff.c b/combine-diff.c index 3e49f3bda8..d5c4d839dc 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -930,7 +930,7 @@ static void show_combined_header(struct combine_diff_path *elem, int show_file_header) { struct diff_options *opt = &rev->diffopt; - int abbrev = opt->flags.full_index ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV; + int abbrev = opt->flags.full_index ? the_hash_algo->hexsz : DEFAULT_ABBREV; const char *a_prefix = opt->a_prefix ? opt->a_prefix : "a/"; const char *b_prefix = opt->b_prefix ? opt->b_prefix : "b/"; const char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO); From patchwork Sun Aug 18 20:04:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACBF713A0 for ; Sun, 18 Aug 2019 20:05:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EFE127C2D for ; Sun, 18 Aug 2019 20:05:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93B0728382; Sun, 18 Aug 2019 20:05:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B193285C9 for ; Sun, 18 Aug 2019 20:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727229AbfHRUFp (ORCPT ); Sun, 18 Aug 2019 16:05:45 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57980 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbfHRUFk (ORCPT ); Sun, 18 Aug 2019 16:05:40 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id BD09860779; Sun, 18 Aug 2019 20:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158739; bh=7S/PkHZPrbgdRJuayj4IuVWHdhu73n6pBjf3qBu2fwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=Vip71UHAX+fT0y70ucfHz7K9ZuhRHy6Q6vakWBajCtRsWzSMXTzzb2T2baj7pJEii 76XH0mv0Bh8kNZu8aQzPM9bT/N/c1D/pQk2cl8xOf/W/Srjr64pPRbsmf0i7eIw1IM ZuizQm1ZRlJQfuDjmyCNUbQy3C1NxddwhtRGUddbZ8yInHBbPR0V2bnM0lW28AFtac Ezfv5HP7O70AfX6jP6+2xSzhl8m4qHWjfdLLACwKE/RPq+5uZlUAr7m6jFAi9Vu8qU YdbRz8dFPDq1sddEfK80YKHHwq/7Rsn9RtEdTJvxz8SfgQ11ZJHnK1IwKtAoe8ovOD kjA+cTjf8MuKIDgkBV1Mm9w2UjplIb7bb5+ZcIXIjYjgkrsKdLqqdp2itv7qhwLqU2 MtQCdLwJ2NxBgXNRgXIX2zdgp4t+lM0g87DyCn9gM9prTD1NPhCSjyWNM2lQMcAbGY mkM+oXzIgapgo7IrjN6/UNm5336aUi2klbYjobmMi18UQ+TescR From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 12/26] config: use the_hash_algo in abbrev comparison Date: Sun, 18 Aug 2019 20:04:13 +0000 Message-Id: <20190818200427.870753-13-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch one use of a hard-coded 40 constant to use the_hash_algo. Signed-off-by: brian m. carlson --- config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.c b/config.c index 3900e4947b..b0f79aab21 100644 --- a/config.c +++ b/config.c @@ -1204,7 +1204,7 @@ static int git_default_core_config(const char *var, const char *value, void *cb) default_abbrev = -1; else { int abbrev = git_config_int(var, value); - if (abbrev < minimum_abbrev || abbrev > 40) + if (abbrev < minimum_abbrev || abbrev > the_hash_algo->hexsz) return error(_("abbrev length out of range: %d"), abbrev); default_abbrev = abbrev; } From patchwork Sun Aug 18 20:04:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53AEF1399 for ; Sun, 18 Aug 2019 20:06:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E7A284DB for ; Sun, 18 Aug 2019 20:06:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 391F1285C8; Sun, 18 Aug 2019 20:06:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE0C9284DB for ; Sun, 18 Aug 2019 20:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727294AbfHRUGF (ORCPT ); Sun, 18 Aug 2019 16:06:05 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57982 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727216AbfHRUFn (ORCPT ); Sun, 18 Aug 2019 16:05:43 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id EDA1A6077D; Sun, 18 Aug 2019 20:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158740; bh=wfl+I7qThgqbD3cdDOYFbXiHvwN9eVb9CLY3GSwWeYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=YEed2LbeoAVCHUuTR5lC4XDkRjkc7odccLKQLnfzrZUn8V842IGlEhjfsfy+JswsW 3XlQtH56hyD1Fz0I8qedSVUQaGs8GZWIc1/towE8fabbTntQVfwx/9JKpDF8Jta9tv yWQJbEJ57Gs5zqVyVDtXezXH1o37V2m3n2uabLqKmyIwADPH6EqPyPk6Smv88f27EV fY33zEp6LdVWSe9bbjaac8p/37X5xhNctOXYCXVLTfRj+iPbIog4uCte1EKMe/a+ic NVQDtYzOSBaiW2lnbRAGffOz2vTCD/ajqCTHRmO1qKagiD+uf+BDKpQbQZDMDbFGqP FYT6sTrqqolC3kfUXAbaM1CwxQHzJ1phVE9xzj1FMqCbf/alZPjO4zZdFzSPLP6+Mf CSbqi0SOCeUJ6s/8oHPqoLz9QrJo/vqSQ3n9VOxYgZV0oFf1CV7mDGhWEv4y11gw+8 nKnU87u0sfBDiMJ7ol0WcZU21GoP4U1MUSpu7m1SuE/dAk8C+3X From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 13/26] sha1-lookup: switch hard-coded constants to the_hash_algo Date: Sun, 18 Aug 2019 20:04:14 +0000 Message-Id: <20190818200427.870753-14-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch a hard-coded 18 to be a reference to the_hash_algo. Rename the sha1 parameter to be called hash instead. Signed-off-by: brian m. carlson --- sha1-lookup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sha1-lookup.c b/sha1-lookup.c index 796ab68da8..93d9af0805 100644 --- a/sha1-lookup.c +++ b/sha1-lookup.c @@ -50,7 +50,7 @@ static uint32_t take2(const unsigned char *sha1) * The sha1 of element i (between 0 and nr - 1) should be returned * by "fn(i, table)". */ -int sha1_pos(const unsigned char *sha1, void *table, size_t nr, +int sha1_pos(const unsigned char *hash, void *table, size_t nr, sha1_access_fn fn) { size_t hi = nr; @@ -63,10 +63,10 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, if (nr != 1) { size_t lov, hiv, miv, ofs; - for (ofs = 0; ofs < 18; ofs += 2) { + for (ofs = 0; ofs < the_hash_algo->rawsz - 2; ofs += 2) { lov = take2(fn(0, table) + ofs); hiv = take2(fn(nr - 1, table) + ofs); - miv = take2(sha1 + ofs); + miv = take2(hash + ofs); if (miv < lov) return -1; if (hiv < miv) @@ -88,7 +88,7 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, do { int cmp; - cmp = hashcmp(fn(mi, table), sha1); + cmp = hashcmp(fn(mi, table), hash); if (!cmp) return mi; if (cmp > 0) From patchwork Sun Aug 18 20:04:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C50A1399 for ; Sun, 18 Aug 2019 20:05:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F00D827C2D for ; Sun, 18 Aug 2019 20:05:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E409B284DB; Sun, 18 Aug 2019 20:05:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1B7427C2D for ; Sun, 18 Aug 2019 20:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727270AbfHRUF4 (ORCPT ); Sun, 18 Aug 2019 16:05:56 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57988 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727219AbfHRUFo (ORCPT ); Sun, 18 Aug 2019 16:05:44 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id B57E460736; Sun, 18 Aug 2019 20:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158743; bh=yVkNwXKVmBOGMgpOwth8StYIXrSjvFPScWO0MZalSoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=jn9r8IegN7kbWg3vasHli2678Ov05nqX3I4tOVHd9xc2HZgrPD5MVez0ytSNT2hI5 G6p2bCPUOI3QoATwvIJOJ14BWCXMqR+66035XN/mPUHeB8B0WCdwz2pr12CDt2MR+f JJnqlSgZ06cdbju4SqhGbNXuJzaRfr9Dlf8R6twR6a/fTMnuxH3xQRB8sSQX1hkz1l nGOHYSbI9VaD50ZP/chNZEcHvjFbVkc44i8Yp62gaYVl3Ce5MKJbeTgCvfKsBqwUG3 iz2cCJrCGhiOnBMB6GdKWHH2WN13rr5LIdlMPNkoJOD7C5P2DQABVlpiJA2oEkg9kO a2zdRMAxIWKvxMB8SI6oNzzIFraQTIxLwJ4sbAPHnJzBm7gf2/Ezyhm/dRhM3Rtpy7 O/kI31QmlW/LaB9ZrpdIAsSGUSKrCpuBbUWwhImdN0jod9HmBxr1xyr4oD6A6bk/7y SEAuwJedb8uUZgX/My3tuo4xzDrVivmsDKa0GPxulcdpzJFlXmh From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 14/26] bisect: switch to using the_hash_algo Date: Sun, 18 Aug 2019 20:04:15 +0000 Message-Id: <20190818200427.870753-15-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using GIT_SHA1_HEXSZ, use the_hash_algo so that the code is hash size independent. Signed-off-by: brian m. carlson --- bisect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bisect.c b/bisect.c index e87ac29a51..e81c91d02c 100644 --- a/bisect.c +++ b/bisect.c @@ -707,7 +707,7 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout) { char bisect_rev_hex[GIT_MAX_HEXSZ + 1]; - memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1); + memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), the_hash_algo->hexsz + 1); update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR); argv_checkout[2] = bisect_rev_hex; From patchwork Sun Aug 18 20:04:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 472891399 for ; Sun, 18 Aug 2019 20:05:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39E4D27C2D for ; Sun, 18 Aug 2019 20:05:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E747284DB; Sun, 18 Aug 2019 20:05:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7D4F27C2D for ; Sun, 18 Aug 2019 20:05:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727241AbfHRUFs (ORCPT ); Sun, 18 Aug 2019 16:05:48 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:57996 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727227AbfHRUFq (ORCPT ); Sun, 18 Aug 2019 16:05:46 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 75F8C6074A; Sun, 18 Aug 2019 20:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158743; bh=l7uC48UD66dNlxlonpDIl1kNQ6Al5j6b0M03WG4/En4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=Zn4cflYI944pksAFiLQeLMokxNPTUWSoSAwIiPWfsiIm2igAngTQ90iMlxbqfbpSi 8EBqNxslc+171XvJUsfq5XnrsbvS9+IXnB58OBDLBTuaTAglUbw/2kkeF/IDfg7c+q K/OF5PIHwZl7qlX3hNB03DJOiketscfpesEPBZGnSm+Al0w3prDv9qXHDYW2J0dR5h kjjXOKrso4/ZkyLc7gvV7v6EfKqNeaMnbe+fw4gj8aGJDh8+sLIUdlQc6eHXbP0ToP tXQluQ1YysVbdqAfc6MbBYyIgzCmd8vtIPlEhCN8aoB7gbqPMwHJLzJs880wxfOBhS zWbIjfw14kOPYokUwA7H1ii++vhNsTmxKtY2oBA+rQnv+fZpb58Rj+ZTH1GLnA4H0I 9Dk2bu3TpJDA2ZtK7Vh4+dOQ0+wz/DE9XnoImtS7wwJN64xNVDuRdJNQkvZ9W4BuvR L1yJrEXtQrxFSZ8TDj8ANtWEcr3RY+kWXv/svzUZmiu2QKIbi96 From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 15/26] sequencer: convert to use the_hash_algo Date: Sun, 18 Aug 2019 20:04:16 +0000 Message-Id: <20190818200427.870753-16-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert several uses of GIT_SHA1_HEXSZ constants to be references to the_hash_algo. Signed-off-by: brian m. carlson --- sequencer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sequencer.c b/sequencer.c index 34ebf8ed94..4d25e79137 100644 --- a/sequencer.c +++ b/sequencer.c @@ -3568,7 +3568,7 @@ static int do_merge(struct repository *r, goto leave_merge; } - write_message(oid_to_hex(&merge_commit->object.oid), GIT_SHA1_HEXSZ, + write_message(oid_to_hex(&merge_commit->object.oid), the_hash_algo->hexsz, git_path_merge_head(r), 0); write_message("no-ff", 5, git_path_merge_mode(r), 0); @@ -4487,7 +4487,7 @@ static const char *label_oid(struct object_id *oid, const char *label, char *p; strbuf_reset(&state->buf); - strbuf_grow(&state->buf, GIT_SHA1_HEXSZ); + strbuf_grow(&state->buf, GIT_MAX_HEXSZ); label = p = state->buf.buf; find_unique_abbrev_r(p, oid, default_abbrev); @@ -4500,7 +4500,7 @@ static const char *label_oid(struct object_id *oid, const char *label, size_t i = strlen(p) + 1; oid_to_hex_r(p, oid); - for (; i < GIT_SHA1_HEXSZ; i++) { + for (; i < the_hash_algo->hexsz; i++) { char save = p[i]; p[i] = '\0'; if (!hashmap_get_from_hash(&state->labels, From patchwork Sun Aug 18 20:04:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 686A713A0 for ; Sun, 18 Aug 2019 20:05:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AA0528382 for ; Sun, 18 Aug 2019 20:05:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F197285C7; Sun, 18 Aug 2019 20:05:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0C9828382 for ; Sun, 18 Aug 2019 20:05:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727237AbfHRUFq (ORCPT ); Sun, 18 Aug 2019 16:05:46 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58004 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbfHRUFq (ORCPT ); Sun, 18 Aug 2019 16:05:46 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 2138D6075B; Sun, 18 Aug 2019 20:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158745; bh=KK1MUfkkD78W5dM0cgtz3R+3erf0K2oce/76uSCAzuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=hPJkqWDQ6VKkosb++dW0102/betR7qEUbP5fpS/KTUYQ/KZbvzpxljW/jFwYtPY6c 5+wXQBIaJsPzTYqUf0sDToGpUzmdIwmBrwVuhea69gNbRYR6g5w8dCrFWtsADPZTHs CQkE63BBRwWSOn1Kl7RVgVVbPKakijb4MtG9Qlbt5nGH5QejeVM1FDuC2ziz4E6e01 HvT07XPD77LSjhr8hhpWSx5d4Nq1wI1ECAC53kg3GVHqu7V8aouEQjXaEzdVXeq7Aq boJiddoe4LY8TO2UEZIpmjzpuepsg90g5imCZ+SeiAEshyPsn4aEmTV+dmd5nAIEIl U3etk1SCbp5S4/lWH0TZhfONF/lQyMTQ8vOgxrLcU51mTpUhAbH4ITL7Ug1GRog1dv 6jVuQXRzY8Ds4+3HgTK1njVe0PCzlZNRWm7/RS0HZVPlIbFL9StfEWnEL7RmfoBUDr rYYaBvR/8bPIoITc87ovmq8nSR3wsSqgXPqBzheiL/KTzSpN6JF From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 16/26] pack-write: use hash_to_hex when writing checksums Date: Sun, 18 Aug 2019 20:04:17 +0000 Message-Id: <20190818200427.870753-17-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Pack checksums always use the current hash algorithm in use, so switch from sha1_to_hex to hash_to_hex. Signed-off-by: brian m. carlson --- pack-write.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pack-write.c b/pack-write.c index 29d17a9bec..f0017beb9d 100644 --- a/pack-write.c +++ b/pack-write.c @@ -349,7 +349,7 @@ void finish_tmp_packfile(struct strbuf *name_buffer, struct pack_idx_entry **written_list, uint32_t nr_written, struct pack_idx_option *pack_idx_opts, - unsigned char sha1[]) + unsigned char hash[]) { const char *idx_tmp_name; int basename_len = name_buffer->len; @@ -358,18 +358,18 @@ void finish_tmp_packfile(struct strbuf *name_buffer, die_errno("unable to make temporary pack file readable"); idx_tmp_name = write_idx_file(NULL, written_list, nr_written, - pack_idx_opts, sha1); + pack_idx_opts, hash); if (adjust_shared_perm(idx_tmp_name)) die_errno("unable to make temporary index file readable"); - strbuf_addf(name_buffer, "%s.pack", sha1_to_hex(sha1)); + strbuf_addf(name_buffer, "%s.pack", hash_to_hex(hash)); if (rename(pack_tmp_name, name_buffer->buf)) die_errno("unable to rename temporary pack file"); strbuf_setlen(name_buffer, basename_len); - strbuf_addf(name_buffer, "%s.idx", sha1_to_hex(sha1)); + strbuf_addf(name_buffer, "%s.idx", hash_to_hex(hash)); if (rename(idx_tmp_name, name_buffer->buf)) die_errno("unable to rename temporary index file"); From patchwork Sun Aug 18 20:04:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099927 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74FAF1399 for ; Sun, 18 Aug 2019 20:05:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6751227C2D for ; Sun, 18 Aug 2019 20:05:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BCF8284DB; Sun, 18 Aug 2019 20:05:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B40727C2D for ; Sun, 18 Aug 2019 20:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727247AbfHRUFt (ORCPT ); Sun, 18 Aug 2019 16:05:49 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58006 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727238AbfHRUFr (ORCPT ); Sun, 18 Aug 2019 16:05:47 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id C065F6075D; Sun, 18 Aug 2019 20:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158746; bh=qN/7ECw+72Orb66ukmrchlssQkO9KrF1FPFx3xGnVw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=jxjHg73WbjVIvHWXF3D8P03jpIoqZXNAb5mF4nxxIU/Omdm4chQn6jj4CWtqOEd6a 3uyMBrMBmtWIBQo7ciFopP2pSBR7G9kXpgE8UZZlpYnpXNf8B/uWl1jlKm8GCA9/k+ cTsyDFTmst6kSMhSFe9Uixh5xKP/D49+OJwnE8RB9yutPWOdSau8qjPGxd2+SsPIoA dIA1wq1V2iugG8Fw+3SyJ8uFLMNee89P1JQl0SlG+SjZOLtQATyBQ12lHN6bXYDM4V epEGLrIQ/LLIkLQDSBVUUX4WB8aeVk1zbGz1f1vsQaf+3B5CsJiA+D1LHXMVfb7smt JOcLKBUpI9Ugeo86FBR31mnPXSv/nJcfwqmdBLF/fveTmIwxeNK9thNp+FYxZzfXk5 CQOX5mdHBU8w71l2MvkXePEaW5sb300zjIc1iOR7EagfRhKPFFqW29T2OGgusjEJr7 WTMKT2pva0hmKDZ6Eg0H0DQu0jaU3hNyCpVsKkk2QPZbWMZC3+q From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 17/26] builtin/repack: write object IDs of the proper length Date: Sun, 18 Aug 2019 20:04:18 +0000 Message-Id: <20190818200427.870753-18-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the_hash_algo when calling xwrite with a hex object ID so that the proper amount of data is written. Signed-off-by: brian m. carlson --- builtin/repack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/repack.c b/builtin/repack.c index 632c0c0a79..5830f796e0 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -190,7 +190,7 @@ static int write_oid(const struct object_id *oid, struct packed_git *pack, die(_("could not start pack-objects to repack promisor objects")); } - xwrite(cmd->in, oid_to_hex(oid), GIT_SHA1_HEXSZ); + xwrite(cmd->in, oid_to_hex(oid), the_hash_algo->hexsz); xwrite(cmd->in, "\n", 1); return 0; } From patchwork Sun Aug 18 20:04:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE0DE1399 for ; Sun, 18 Aug 2019 20:05:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B04D727C2D for ; Sun, 18 Aug 2019 20:05:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4BF8284DB; Sun, 18 Aug 2019 20:05:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BAFF27C2D for ; Sun, 18 Aug 2019 20:05:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbfHRUFu (ORCPT ); Sun, 18 Aug 2019 16:05:50 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58014 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727240AbfHRUFt (ORCPT ); Sun, 18 Aug 2019 16:05:49 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 07BA760736; Sun, 18 Aug 2019 20:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158747; bh=Cvhh0ce9G/l6AYaO6kqaExnwR+Ald1DPK7Qv8aiDHYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=1cN224hdtXIk6u/BF0qHIMfPoh1MJuKfaz8fkRDWRHdu1feUCGuDbFAKsd1iZ8fAT FHtyuaFQgU6aY6LalN4bs2QU0B/qylQcHnZ6rZIXno/Cl7NFq7NcFa6MR9aBX5vI8N g7J1iC7hpSn+vfknz34eePhLl5N58/ivUiliG7ivgLVfThdWH9dZhqOXQr2k3fVhyX WZjIoSt7Upm5akkcUNp4qbO51hhJRIkVBlThJT3PhVsJYqcgliX+bIEjzOhaimUw1A pwpysZqH95AQ3TjR75Fg5ykkjFxYnWMl2vX0RJ67ay6PAqMJDEVV0XtX+J+N2G4E12 K/GEOkOtwspuG+AT5KdJVH5je70c2AnBMJzAC7SUPYX3RylRkd3Ce+d1IkaSKw1xQL B1xqmsIEUpHRFBH3iYNk6wFwixND2aWi5FNzNCIhdF/Wp5GiOB1HvUIxQcYchped2W Vzl/68Qn76mR8j+UFo9hxdbg1ka/aufnz8p0vALbaArbnSHtCON From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 18/26] builtin/worktree: switch null_sha1 to null_oid Date: Sun, 18 Aug 2019 20:04:19 +0000 Message-Id: <20190818200427.870753-19-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch the remaining use of null_sha1 to null_oid. Signed-off-by: brian m. carlson --- builtin/worktree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index a5bb02b207..0c0df3b0b8 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -350,7 +350,7 @@ static int add_worktree(const char *path, const char *refname, */ strbuf_reset(&sb); strbuf_addf(&sb, "%s/HEAD", sb_repo.buf); - write_file(sb.buf, "%s", sha1_to_hex(null_sha1)); + write_file(sb.buf, "%s", oid_to_hex(&null_oid)); strbuf_reset(&sb); strbuf_addf(&sb, "%s/commondir", sb_repo.buf); write_file(sb.buf, "../.."); From patchwork Sun Aug 18 20:04:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1A0B13A0 for ; Sun, 18 Aug 2019 20:05:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B477C27C2D for ; Sun, 18 Aug 2019 20:05:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8BE8284DB; Sun, 18 Aug 2019 20:05:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C27AF28382 for ; Sun, 18 Aug 2019 20:05:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727252AbfHRUFv (ORCPT ); Sun, 18 Aug 2019 16:05:51 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58022 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727243AbfHRUFt (ORCPT ); Sun, 18 Aug 2019 16:05:49 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id BA62F6075F; Sun, 18 Aug 2019 20:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158748; bh=W8Uto2ygpHuu0OXbhG8L/QQCmGsZz63EWPkH0b5f+og=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=IbV/Kdhqb80yl5Uz2Q18xjSromm8JWL2KNoNroDcKjtD0NioHBFeGKDxAwcZS7SIj dTraDCRUpZXGnR/+CW8YKWOqRw7Dt8Sr/2kb/sjW/whM87O0C0MAm53/3qvC2nSKky NJ3xNlXCisI48HJfUcXf3PrMVtJhca64eKPLS9IcBR06Ec0wpQKp6WjDD7LOh89AxP 2fA6fmLaN44IUiEM9UPL2J03sT4ScmrHLhamJ/TqkSdi6GQqUjgIMxl3R3ohh03Ds6 Ze5Mw+tNJfoB1IMfxxbr9BzbeE35k/YHrxxLooofPEYs7OKr3L3slKmjrSr2nvpdEN 5eZ6dAGGuH9cCoEEIJBzjpiurPhFbDzvcCoI4zDFkpG7E4yW6ngY6lWo8ekwZwpRQ3 sQfCeGSU5fLFc4RBE1/AC3bO8iYhRHkJpa/OlPMBdMpocd7HSNghI/QOjHBxb6d3gh JNralCS4nrzrnbUQIJ2VgcQcWeDwUs0POz9QkByRNd/SWN4Gx2m From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 19/26] cache: remove null_sha1 Date: Sun, 18 Aug 2019 20:04:20 +0000 Message-Id: <20190818200427.870753-20-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All of the existing uses of null_sha1 can be converted into uses of null_oid, so do so. Remove null_sha1 and is_null_sha1, and define is_null_oid in terms of null_oid. This also has the additional benefit of removing several uses of sha1_to_hex. Signed-off-by: brian m. carlson --- builtin/clone.c | 2 +- builtin/submodule--helper.c | 2 +- cache.h | 8 +------- sha1-file.c | 1 - 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index f665b28ccc..eabd02846a 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -785,7 +785,7 @@ static int checkout(int submodule_progress) if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) die(_("unable to write new index file")); - err |= run_hook_le(NULL, "post-checkout", sha1_to_hex(null_sha1), + err |= run_hook_le(NULL, "post-checkout", oid_to_hex(&null_oid), oid_to_hex(&oid), "1", NULL); if (!err && (option_recurse_submodules.nr > 0)) { diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 909e77e802..8a6f2abce4 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -424,7 +424,7 @@ static int module_list(int argc, const char **argv, const char *prefix) const struct cache_entry *ce = list.entries[i]; if (ce_stage(ce)) - printf("%06o %s U\t", ce->ce_mode, sha1_to_hex(null_sha1)); + printf("%06o %s U\t", ce->ce_mode, oid_to_hex(&null_oid)); else printf("%06o %s %d\t", ce->ce_mode, oid_to_hex(&ce->oid), ce_stage(ce)); diff --git a/cache.h b/cache.h index b1da1ab08f..79efd2168f 100644 --- a/cache.h +++ b/cache.h @@ -1029,7 +1029,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len); #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len) -extern const unsigned char null_sha1[GIT_MAX_RAWSZ]; extern const struct object_id null_oid; static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2) @@ -1064,14 +1063,9 @@ static inline int oideq(const struct object_id *oid1, const struct object_id *oi return hasheq(oid1->hash, oid2->hash); } -static inline int is_null_sha1(const unsigned char *sha1) -{ - return hasheq(sha1, null_sha1); -} - static inline int is_null_oid(const struct object_id *oid) { - return hasheq(oid->hash, null_sha1); + return oideq(oid, &null_oid); } static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src) diff --git a/sha1-file.c b/sha1-file.c index 487ea35d2d..0ea28f7da3 100644 --- a/sha1-file.c +++ b/sha1-file.c @@ -55,7 +55,6 @@ "\x6f\xe1\x41\xf7\x74\x91\x20\xa3\x03\x72" \ "\x18\x13" -const unsigned char null_sha1[GIT_MAX_RAWSZ]; const struct object_id null_oid; static const struct object_id empty_tree_oid = { EMPTY_TREE_SHA1_BIN_LITERAL From patchwork Sun Aug 18 20:04:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8907813A0 for ; Sun, 18 Aug 2019 20:05:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BD2027C2D for ; Sun, 18 Aug 2019 20:05:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70541284DB; Sun, 18 Aug 2019 20:05:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B48727C2D for ; Sun, 18 Aug 2019 20:05:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbfHRUFw (ORCPT ); Sun, 18 Aug 2019 16:05:52 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58026 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727250AbfHRUFu (ORCPT ); Sun, 18 Aug 2019 16:05:50 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 175086074A; Sun, 18 Aug 2019 20:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158749; bh=xOWEmVnpXGXnmnuIuekjcTh784iE81edYoOkwRZfUVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=Joa4bKQL4hWFjhvSjVnsLxLAILaKI8Iqo1S0bFk2gqSYmJEDYXR5WmljaxiSo4+Fp 5AO6cmRVkexXkEjLTxZ79gmGmTgbhVkD7+5jj7+yFo6c7cAA73vs5nwBihxmDPFeU6 0BiW1u3Da98sxk/3MNC+7qSKHI2Kj3DbFtjCYx5FHHjjbU0+qCkxnBs07jtFhT3r/I iTWCLvbCrvVIX+49UGoNpKv6szD8PXXKsAH5B4MJRMtWG8PgAMfqR66pGhcqJgMBph ocjSokZOSnRBPQeAGol98bUZrtJmCv9lXU86eOfobjT9GGEljX1Z4HQGOsubqPIsnF QpTkye+QvUg4YaN6M96jP9iLpQ68lL3ahTc8jaQ+cB4oKCpslPwadgUQ1fcrLshd1y qSIi8tQ4Ly6WmGp6hU0ijV0+8GVPf0/plPAN1XeTH1FPcwPGGFh3e3i/CVbpR1ZhGQ OpHd4kIZzNKzk/q5S7yXrZwqSA6LWUFNUKANEMBIDoT6q0Cj1zy From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 20/26] wt-status: convert struct wt_status to object_id Date: Sun, 18 Aug 2019 20:04:21 +0000 Message-Id: <20190818200427.870753-21-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change struct wt_status to use struct object_id instead of an array of unsigned char. Signed-off-by: brian m. carlson --- builtin/commit.c | 4 ++-- wt-status.c | 2 +- wt-status.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index ae7aaf6dc6..e588bc6ad3 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -510,7 +510,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int s->nowarn = nowarn; s->is_initial = get_oid(s->reference, &oid) ? 1 : 0; if (!s->is_initial) - hashcpy(s->sha1_commit, oid.hash); + oidcpy(&s->oid_commit, &oid); s->status_format = status_format; s->ignore_submodule_arg = ignore_submodule_arg; @@ -1406,7 +1406,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) s.is_initial = get_oid(s.reference, &oid) ? 1 : 0; if (!s.is_initial) - hashcpy(s.sha1_commit, oid.hash); + oidcpy(&s.oid_commit, &oid); s.ignore_submodule_arg = ignore_submodule_arg; s.status_format = status_format; diff --git a/wt-status.c b/wt-status.c index 9f6c65a580..7cf220fed4 100644 --- a/wt-status.c +++ b/wt-status.c @@ -2025,7 +2025,7 @@ static void wt_porcelain_v2_print_tracking(struct wt_status *s) char eol = s->null_termination ? '\0' : '\n'; fprintf(s->fp, "# branch.oid %s%c", - (s->is_initial ? "(initial)" : sha1_to_hex(s->sha1_commit)), + (s->is_initial ? "(initial)" : oid_to_hex(&s->oid_commit)), eol); if (!s->branch) diff --git a/wt-status.h b/wt-status.h index 77dad5b920..71c3f25f43 100644 --- a/wt-status.h +++ b/wt-status.h @@ -116,7 +116,7 @@ struct wt_status { int rename_limit; enum wt_status_format status_format; struct wt_status_state state; - unsigned char sha1_commit[GIT_MAX_RAWSZ]; /* when not Initial */ + struct object_id oid_commit; /* when not Initial */ /* These are computed during processing of the individual sections */ int committable; From patchwork Sun Aug 18 20:04:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3B9C1399 for ; Sun, 18 Aug 2019 20:05:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B543727C2D for ; Sun, 18 Aug 2019 20:05:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8F67284DB; Sun, 18 Aug 2019 20:05:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5789027C2D for ; Sun, 18 Aug 2019 20:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727267AbfHRUFz (ORCPT ); Sun, 18 Aug 2019 16:05:55 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58032 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727243AbfHRUFw (ORCPT ); Sun, 18 Aug 2019 16:05:52 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 4D9D46075F; Sun, 18 Aug 2019 20:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158750; bh=Bv2j+DhOrV8jMrhKQZSvE4DWm519x+ybfy54s++TBu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=AswC3TdERwF9uD9+UZZ38KkeKzEHAsOwJLBvexpLBkz+2g2VKxeRrhrhLEG71O/qo nyUUac/WkguGeyeSHFp4KhimiNkuHVwxl3C4gM1ilgwvRXEUf2nuBY5DV81H5k+xWh absPRUrfX0a5WjCIjtbRSvADXKH9UyVUDLZQxFvj4v3WNE2qO0he/PECTBsrPvbRwk LHBLlNXJ6YNCMYrNZgStaxarvMn0LRHVKRtRNYZvun71Viioo3rNxjZMKggSMNh6CG Dazv077xyueLKdOs7EkOvMWUQp/BzYB47tzncSSoSg10cQZFAR2TLu+A3BizS1f/xo MyMdGfzRcPg8VTUWfmXRvacNkUXm00zau/95CrjNsDBzUHhqyp8O6USIQeTEHwSFB4 KkFDCYuTtNvw/z7q+3IoGRsaNXeomcgI9Qd4FFwI9xkz4guqmLnWW4DFNnSOUsuAlU o/BL0M9ccgYvG9IzRl+Mw2E+iA+6oBpqvBedcDLrjS5C8YCW42O From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 21/26] packfile: replace sha1_to_hex Date: Sun, 18 Aug 2019 20:04:22 +0000 Message-Id: <20190818200427.870753-22-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace a use of sha1_to_hex with hash_to_hex so that this code works with a hash algorithm other than SHA-1. Signed-off-by: brian m. carlson --- packfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packfile.c b/packfile.c index fc43a6c52c..52dea88997 100644 --- a/packfile.c +++ b/packfile.c @@ -19,12 +19,12 @@ #include "commit-graph.h" char *odb_pack_name(struct strbuf *buf, - const unsigned char *sha1, + const unsigned char *hash, const char *ext) { strbuf_reset(buf); strbuf_addf(buf, "%s/pack/pack-%s.%s", get_object_directory(), - sha1_to_hex(sha1), ext); + hash_to_hex(hash), ext); return buf->buf; } From patchwork Sun Aug 18 20:04:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099943 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 735A313A0 for ; Sun, 18 Aug 2019 20:05:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6615427C2D for ; Sun, 18 Aug 2019 20:05:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD09284DB; Sun, 18 Aug 2019 20:05:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140AC27C2D for ; Sun, 18 Aug 2019 20:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727262AbfHRUFz (ORCPT ); Sun, 18 Aug 2019 16:05:55 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58038 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727254AbfHRUFx (ORCPT ); Sun, 18 Aug 2019 16:05:53 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 86FD86074A; Sun, 18 Aug 2019 20:05:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158751; bh=zgkmA4/Tx4lCIa/TrgtfzOsoeqLEKUBzzbJKm9L5UWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=f/hgJzJttfr3Ezw9WgUX7T6zncEshNYDgSSnRkRsg9lDS3M31OvTk8BkHgDuBxkst qN40uYNvyf4uxwDap9ZFUzdoiLMYuCrPfo/3DvupJg4vcAkTT5aLIUOXYsA4lcq1nn NzaYx5sC7TmwhPCbEfTMdcBShVIe64No7U1WmWO6XD1mjjtT0n8bdhWhDrpmHJXgTy jwOR5RMxwnGq8RIpBQ8jyJ4aBEtnFbWvjWjHn25iMQRF1ZfI+IglpgKS2FUpPeGEtm mIOsVxfksnqvkkxl5fmDRrE8fKaV+4qupeZXPSL5CooidO2sVFlrG/FPt/RIWXma2y 1LD644dtoT3aBSGWVyg4ZJePOLIzPVB3/7vgCrbn1FVoOsiDHl0JNaleGb6Ja4rKI3 0y0xhnj6SR4bOJQ8Wp4IgY41eium8B+ToTDVJGEkLnH9NBIVuiyWAadxJ3wWtz8GHV zefOP0uYHAjYiLOTbuq8YLdoL/gbyWNMiKknUQA0g2x1p6NiPvx From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 22/26] builtin/index-pack: replace sha1_to_hex Date: Sun, 18 Aug 2019 20:04:23 +0000 Message-Id: <20190818200427.870753-23-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since sha1_to_hex is limited to SHA-1, replace it with hash_to_hex so this code works with other algorithms. Signed-off-by: brian m. carlson --- builtin/index-pack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 0d55f73b0b..2abd550ce2 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1490,11 +1490,11 @@ static void final(const char *final_pack_name, const char *curr_pack_name, } if (!from_stdin) { - printf("%s\n", sha1_to_hex(hash)); + printf("%s\n", hash_to_hex(hash)); } else { struct strbuf buf = STRBUF_INIT; - strbuf_addf(&buf, "%s\t%s\n", report, sha1_to_hex(hash)); + strbuf_addf(&buf, "%s\t%s\n", report, hash_to_hex(hash)); write_or_die(1, buf.buf, buf.len); strbuf_release(&buf); From patchwork Sun Aug 18 20:04:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099951 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72F1713A0 for ; Sun, 18 Aug 2019 20:06:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 648FD285C7 for ; Sun, 18 Aug 2019 20:06:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57251285C9; Sun, 18 Aug 2019 20:06:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06E4C28382 for ; Sun, 18 Aug 2019 20:06:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727286AbfHRUGB (ORCPT ); Sun, 18 Aug 2019 16:06:01 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58046 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727258AbfHRUFy (ORCPT ); Sun, 18 Aug 2019 16:05:54 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 2E97C6077E; Sun, 18 Aug 2019 20:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158752; bh=QImHxEB2qHPakytzU74quFT+j/P1s5yJ9AZ9Vj2CCEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=lGcBjNwj7BbXk/s2L/uaKo6O79xzwXRu06Dc+WhIjTLEovQZtNSOaJxp8VARMLWlN lzxyVrFjKm42TWSIOZl6TMP7j6kDwqTK8StpqVFizh2He342DtgJwDujDU2osLIahK ysv+oKtgmE78iv6Zb/8ffD4eqFmriTDlVyzPj9iiHdmrwxqm8woIPT7h6zWmvuUCoG dfE5CJcT9QmfAwsrQixlavdMojmtQA81faXMA4+28lyk3DK8XlGV5ddJteHf9jLxav Mzv3CEG6tWqDpFMK/sdfshOEgFF97aAyPauU9lJHJGgdXnQMpvCssd20xMn3zhBTq4 r8iKjcBzOD0UwqLaJcejAxdOQxhb9TaN2Wo6+DvRtlzQ89e0YNGsB3vIgIkmNCyYGK m8jlvyHi/zrFxYqXFVPnCM6Gu/G/YqsQW60A7dfK9Te1uTIsph72ticAjOneYbge45 bCTrOit9Luz+R6ifdzzRdrz2IIyfHnNXut4JWO4S4d8jg5iV/ie From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 23/26] builtin/receive-pack: replace sha1_to_hex Date: Sun, 18 Aug 2019 20:04:24 +0000 Message-Id: <20190818200427.870753-24-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since sha1_to_hex is limited to SHA-1, replace it with hash_to_hex. Rename several variables to indicate that they can contain any hash. Signed-off-by: brian m. carlson --- builtin/receive-pack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 402edf34d8..411e0b4d99 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -466,7 +466,7 @@ static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp) strbuf_release(&buf); /* RFC 2104 5. HMAC-SHA1-80 */ - strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, (int)the_hash_algo->hexsz, sha1_to_hex(hash)); + strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, (int)the_hash_algo->hexsz, hash_to_hex(hash)); return strbuf_detach(&buf, NULL); } @@ -968,7 +968,7 @@ static const char *push_to_deploy(unsigned char *sha1, if (run_command(&child)) return "Working directory has staged changes"; - read_tree[3] = sha1_to_hex(sha1); + read_tree[3] = hash_to_hex(sha1); child_process_init(&child); child.argv = read_tree; child.env = env->argv; @@ -985,13 +985,13 @@ static const char *push_to_deploy(unsigned char *sha1, static const char *push_to_checkout_hook = "push-to-checkout"; -static const char *push_to_checkout(unsigned char *sha1, +static const char *push_to_checkout(unsigned char *hash, struct argv_array *env, const char *work_tree) { argv_array_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree)); if (run_hook_le(env->argv, push_to_checkout_hook, - sha1_to_hex(sha1), NULL)) + hash_to_hex(hash), NULL)) return "push-to-checkout hook declined"; else return NULL; From patchwork Sun Aug 18 20:04:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E7071399 for ; Sun, 18 Aug 2019 20:06:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61A8528382 for ; Sun, 18 Aug 2019 20:06:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5666B284DB; Sun, 18 Aug 2019 20:06:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A10127C2D for ; Sun, 18 Aug 2019 20:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727282AbfHRUF7 (ORCPT ); Sun, 18 Aug 2019 16:05:59 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58050 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727259AbfHRUFz (ORCPT ); Sun, 18 Aug 2019 16:05:55 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 5F6D36077F; Sun, 18 Aug 2019 20:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158753; bh=7PrtDxSwYxieVOiScyuB0DhFy4WJXixaEjwM8oLJjec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=cgsbZQZtXKqu9xdhrdfSer9WOdp3e+Bh9C2Dgg7AzT4CmTFFhxX5KYGrkxs1/FoDi MsKDqkWGEwoOMviEsTxQAl6J7ppfAVAp846mCHrJad/Y/2/cohNeltBkv6eoZ5lxfd +LrfDKzp7wnMkcBNoTEKCg8IhR3nMTz3jDfm4WLgJDUg1+Q+sU8MY4KrpPJ4pUdaru vz/B7N5aIPE1xUL8lXzALQBlPXawycxilPHKEYFiQIsYQVM+fHqZq8n1sZIZSXzsG5 8mNoKPHuYoSCZraZ0KbBzPiDN8pZm52LgKIuRwJi9oCJgR0woradtSxbt6uS5DhCEw NircOOWyWBufvfPoK/3zmK4M9245PPZ34KGHdmHAsj3wdikPYp3kEUj8XQUJ++k2ZL GO0vdyQC0wT2wTt8wML6q4TP2S+VVxJex8pEQQPWZXx9cTnJLtM8lr5kEWxTWtZ2Jg fJX/ALd+drevJg1V3NM8LhUHMA4w/dagfXtSpWA6DIOJU/PAj+5 From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 24/26] rerere: replace sha1_to_hex Date: Sun, 18 Aug 2019 20:04:25 +0000 Message-Id: <20190818200427.870753-25-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace the uses of sha1_to_hex in this function with hash_to_hex to allow the use of SHA-256 as well. Rename a variable since it is no longer limited to SHA-1. Signed-off-by: brian m. carlson --- rerere.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rerere.c b/rerere.c index 17abb47321..3e51fdfe58 100644 --- a/rerere.c +++ b/rerere.c @@ -52,7 +52,7 @@ static void free_rerere_id(struct string_list_item *item) static const char *rerere_id_hex(const struct rerere_id *id) { - return sha1_to_hex(id->collection->hash); + return hash_to_hex(id->collection->hash); } static void fit_variant(struct rerere_dir *rr_dir, int variant) @@ -115,7 +115,7 @@ static int is_rr_file(const char *name, const char *filename, int *variant) static void scan_rerere_dir(struct rerere_dir *rr_dir) { struct dirent *de; - DIR *dir = opendir(git_path("rr-cache/%s", sha1_to_hex(rr_dir->hash))); + DIR *dir = opendir(git_path("rr-cache/%s", hash_to_hex(rr_dir->hash))); if (!dir) return; @@ -186,9 +186,9 @@ static struct rerere_id *new_rerere_id_hex(char *hex) return id; } -static struct rerere_id *new_rerere_id(unsigned char *sha1) +static struct rerere_id *new_rerere_id(unsigned char *hash) { - return new_rerere_id_hex(sha1_to_hex(sha1)); + return new_rerere_id_hex(hash_to_hex(hash)); } /* From patchwork Sun Aug 18 20:04:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099945 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BF011399 for ; Sun, 18 Aug 2019 20:06:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC5827C2D for ; Sun, 18 Aug 2019 20:06:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31017284DB; Sun, 18 Aug 2019 20:06:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD32D27C2D for ; Sun, 18 Aug 2019 20:05:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727277AbfHRUF6 (ORCPT ); Sun, 18 Aug 2019 16:05:58 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58054 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727254AbfHRUF4 (ORCPT ); Sun, 18 Aug 2019 16:05:56 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 05BD76075F; Sun, 18 Aug 2019 20:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158754; bh=UBPSEZIMddvV+aKB5l4VQIoEKh5xQWPR86YldcRf2kY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=CAf0a8jq51JDfnXWtbZrYlboR4LQemm1wJ9kJ1q0h8iN5DlSKr48sTH3jIXrhdtbL kOAiulsmkf9vbkjTr20wxzcUCQyLarp0s2cxpuqG/C9Ldu/qJdkvET7wQ91/BiGhp7 4fhnJN8YJuk6GBImPCs0e2ILnashvVTRZN4ypwjW6d1v85fAmoMDBLpvhcdlyqa5E/ XkVk0bOG5uhY9zkkGCcC3XOzDwsnITkrcU9qs1LtwNFHSvqFGDSAFH+gDk98+R2tTO Dhxf0nNN1QVpei1WUTdUu3lVp4Y8ABIUZcJ0uzVPyW5OS+SdwMSOufGo4WwpSbHg3u 6tBH5Y8iI/AOj6yuKlYR/rn3CBS9sK+wwCHqKREHAloR8nKOSGNSQ4HxAKH+4EGUmr xpzB/rssRjJtKaHL5Bit5BVfjDQS143mvCIH6nxqP1R1Ti95MbaiPDqpSP3sl+o9a9 n6uHgrUdst7OR1dmG12GKbiKWP9Q9P4LlJP91nVyQfT+QmEOULC From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 25/26] builtin/show-index: replace sha1_to_hex Date: Sun, 18 Aug 2019 20:04:26 +0000 Message-Id: <20190818200427.870753-26-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In this code path, we use sha1_to_hex to display the contents of a v1 pack index. While we plan to switch to v3 indices for SHA-256, the v1 pack indices still function, so to support both algorithms, switch sha1_to_hex to hash_to_hex. Signed-off-by: brian m. carlson --- builtin/show-index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/show-index.c b/builtin/show-index.c index e95b84e8eb..0826f6a5a2 100644 --- a/builtin/show-index.c +++ b/builtin/show-index.c @@ -42,7 +42,7 @@ int cmd_show_index(int argc, const char **argv, const char *prefix) if (fread(entry, 4 + hashsz, 1, stdin) != 1) die("unable to read entry %u/%u", i, nr); offset = ntohl(entry[0]); - printf("%u %s\n", offset, sha1_to_hex((void *)(entry+1))); + printf("%u %s\n", offset, hash_to_hex((void *)(entry+1))); } } else { unsigned off64_nr = 0; From patchwork Sun Aug 18 20:04:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brian m. carlson" X-Patchwork-Id: 11099953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE35C13A0 for ; Sun, 18 Aug 2019 20:06:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB2B284DB for ; Sun, 18 Aug 2019 20:06:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4262285C8; Sun, 18 Aug 2019 20:06:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C192284DB for ; Sun, 18 Aug 2019 20:06:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727289AbfHRUGC (ORCPT ); Sun, 18 Aug 2019 16:06:02 -0400 Received: from injection.crustytoothpaste.net ([192.241.140.119]:58064 "EHLO injection.crustytoothpaste.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbfHRUF5 (ORCPT ); Sun, 18 Aug 2019 16:05:57 -0400 Received: from genre.crustytoothpaste.net (unknown [IPv6:2001:470:b978:101:81dd:eb9b:e758:604b]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by injection.crustytoothpaste.net (Postfix) with ESMTPSA id 3A4C860781; Sun, 18 Aug 2019 20:05:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crustytoothpaste.net; s=default; t=1566158755; bh=WzigPSVVN4u10GU1kmnt9CH5axRxxANaRXi5LDeFA+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Reply-To: Subject:Date:To:CC:Resent-Date:Resent-From:Resent-To:Resent-Cc: In-Reply-To:References:Content-Type:Content-Disposition; b=decMw4qFvM4iks+QYRIvV6RJkYCgRP2nVhq7nbY7IFMNBBRQJKFsPwgEpnZWZoRzr zZ7YIzxFjdEQ0TTZhh7FsJQyrxZNLsufkYEt6e7GdHvVsXyocBXU0UWAftjBW3ywvv PFEus1LR4tPA8wp3oybzmZZ02SjIYYn9eTz8DRFCQAOix8ldSysQ4WOd/sNSyKogyU f+4qTcojEdG2lgnLoNOewA2TG0LPOxhDu4saIEdRcR6PeYZTnuDvkVZc6+vygn+UGH 3C1hcdw3HemwzJ1MtH0fJXzlVwOl3OtgxODWgbTkGf6Yz6X9hWksQ90R3FSK7lwPkq 6+q92VuDhjV+5oVjEhNKf/AhMa5yY8jt4FWouVlF5WkB1UL8dKhMOmAAL2YaYLGKqA IAKBlRM+pH/mE8Cj7bnPvP/vwwwWtkW2p/mjzoJutf2UlL1viZpt/71M4cYWRO5y75 qjyN5U9uELkDAZ1JZkFNdzyOm7H8uyleMGtT++y57D1Bej5KqWu From: "brian m. carlson" To: Cc: Taylor Blau , Derrick Stolee Subject: [PATCH 26/26] midx: switch to using the_hash_algo Date: Sun, 18 Aug 2019 20:04:27 +0000 Message-Id: <20190818200427.870753-27-sandals@crustytoothpaste.net> X-Mailer: git-send-email 2.23.0.rc1.170.gbd704faa3e In-Reply-To: <20190818200427.870753-1-sandals@crustytoothpaste.net> References: <20190818200427.870753-1-sandals@crustytoothpaste.net> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of hard-coding the hash size, use the_hash_algo to look up the hash size at runtime. Remove the #define constant which was used to hold the hash length, since writing the expression with the_hash_algo provide enough documentary value on its own. Signed-off-by: brian m. carlson --- midx.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/midx.c b/midx.c index d649644420..f29afc0d2d 100644 --- a/midx.c +++ b/midx.c @@ -19,8 +19,7 @@ #define MIDX_BYTE_NUM_PACKS 8 #define MIDX_HASH_VERSION 1 #define MIDX_HEADER_SIZE 12 -#define MIDX_HASH_LEN 20 -#define MIDX_MIN_SIZE (MIDX_HEADER_SIZE + MIDX_HASH_LEN) +#define MIDX_MIN_SIZE (MIDX_HEADER_SIZE + the_hash_algo->rawsz) #define MIDX_MAX_CHUNKS 5 #define MIDX_CHUNK_ALIGNMENT 4 @@ -93,7 +92,7 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local hash_version = m->data[MIDX_BYTE_HASH_VERSION]; if (hash_version != MIDX_HASH_VERSION) die(_("hash version %u does not match"), hash_version); - m->hash_len = MIDX_HASH_LEN; + m->hash_len = the_hash_algo->rawsz; m->num_chunks = m->data[MIDX_BYTE_NUM_CHUNKS]; @@ -234,7 +233,7 @@ int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result) { return bsearch_hash(oid->hash, m->chunk_oid_fanout, m->chunk_oid_lookup, - MIDX_HASH_LEN, result); + the_hash_algo->rawsz, result); } struct object_id *nth_midxed_object_oid(struct object_id *oid, @@ -928,7 +927,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index * cur_chunk++; chunk_ids[cur_chunk] = MIDX_CHUNKID_OBJECTOFFSETS; - chunk_offsets[cur_chunk] = chunk_offsets[cur_chunk - 1] + nr_entries * MIDX_HASH_LEN; + chunk_offsets[cur_chunk] = chunk_offsets[cur_chunk - 1] + nr_entries * the_hash_algo->rawsz; cur_chunk++; chunk_offsets[cur_chunk] = chunk_offsets[cur_chunk - 1] + nr_entries * MIDX_CHUNK_OFFSET_WIDTH; @@ -976,7 +975,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index * break; case MIDX_CHUNKID_OIDLOOKUP: - written += write_midx_oid_lookup(f, MIDX_HASH_LEN, entries, nr_entries); + written += write_midx_oid_lookup(f, the_hash_algo->rawsz, entries, nr_entries); break; case MIDX_CHUNKID_OBJECTOFFSETS: