{"thread":{"id":"48842","subject":"[PATCH 00/17] object_id part 14","startedAt":"2018-07-08T23:36:53Z","lastAt":"2018-07-16T21:06:30Z","messageCount":37,"participants":["brian m. carlson","Jacob Keller","Eric Sunshine","Derrick Stolee","Stefan Beller","Brandon Williams","Junio C Hamano","Ben Peart","Michael Haggerty"],"isPatch":true,"patchVersion":1,"patchTotal":17},"messages":[{"id":"351901","messageId":"20180708233638.520172-1-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":null,"subject":"[PATCH 00/17] object_id part 14","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:21Z","receivedAt":"2018-07-08T23:36:53Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This is the fourteenth series of patches to switch to using struct\nobject_id and the_hash_algo.  This series converts several core pieces\nto use struct object_id, including the oid* and hex functions.\n\nAll of these patches have been tested with both SHA-1 and a 256-bit\nhash.\n\nbrian m. carlson (17):\n  cache: update object ID functions for the_hash_algo\n  tree-walk: replace hard-coded constants with the_hash_algo\n  hex: switch to using the_hash_algo\n  commit: express tree entry constants in terms of the_hash_algo\n  strbuf: allocate space with GIT_MAX_HEXSZ\n  sha1-name: use the_hash_algo when parsing object names\n  commit: increase commit message buffer size\n  refs/files-backend: use the_hash_algo for writing refs\n  builtin/update-index: convert to using the_hash_algo\n  builtin/update-index: simplify parsing of cacheinfo\n  builtin/fmt-merge-msg: make hash independent\n  builtin/merge: switch to use the_hash_algo\n  builtin/merge-recursive: make hash independent\n  diff: switch GIT_SHA1_HEXSZ to use the_hash_algo\n  log-tree: switch GIT_SHA1_HEXSZ to the_hash_algo->hexsz\n  sha1-file: convert constants to uses of the_hash_algo\n  pretty: switch hard-coded constants to the_hash_algo\n\n builtin/fmt-merge-msg.c   | 19 ++++++++++---------\n builtin/merge-recursive.c |  4 ++--\n builtin/merge.c           | 11 ++++++-----\n builtin/update-index.c    | 14 ++++++++------\n cache.h                   |  6 +++---\n commit.c                  |  4 ++--\n diff.c                    |  6 +++---\n hex.c                     |  6 +++---\n log-tree.c                |  2 +-\n pretty.c                  |  4 ++--\n refs/files-backend.c      |  6 +++---\n sha1-file.c               |  8 ++++----\n sha1-name.c               | 12 +++++++-----\n strbuf.c                  |  2 +-\n tree-walk.c               |  3 ++-\n 15 files changed, 57 insertions(+), 50 deletions(-)\n\n"},{"id":"351902","messageId":"20180708233638.520172-2-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 01/17] cache: update object ID functions for the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:22Z","receivedAt":"2018-07-08T23:36:55Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Update the hashcpy and hashclr functions to use the_hash_algo, since\nthey are used in a variety of places to copy and manipulate buffers that\nneed to move data into or out of struct object_id.  Update oidcmp so\nthat it is implemented on its own and similarly uses the_hash_algo.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n cache.h | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex d49092d94d..c4a64278a1 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -977,7 +977,7 @@ static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)\n \n static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)\n {\n-\treturn hashcmp(oid1->hash, oid2->hash);\n+\treturn memcmp(oid1->hash, oid2->hash, the_hash_algo->rawsz);\n }\n \n static inline int is_null_sha1(const unsigned char *sha1)\n@@ -992,7 +992,7 @@ static inline int is_null_oid(const struct object_id *oid)\n \n static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)\n {\n-\tmemcpy(sha_dst, sha_src, GIT_SHA1_RAWSZ);\n+\tmemcpy(sha_dst, sha_src, the_hash_algo->rawsz);\n }\n \n static inline void oidcpy(struct object_id *dst, const struct object_id *src)\n@@ -1009,7 +1009,7 @@ static inline struct object_id *oiddup(const struct object_id *src)\n \n static inline void hashclr(unsigned char *hash)\n {\n-\tmemset(hash, 0, GIT_SHA1_RAWSZ);\n+\tmemset(hash, 0, the_hash_algo->rawsz);\n }\n \n static inline void oidclr(struct object_id *oid)\n"},{"id":"351903","messageId":"20180708233638.520172-5-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 04/17] commit: express tree entry constants in terms of the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:25Z","receivedAt":"2018-07-08T23:36:57Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Specify these constants in terms of the size of the hash algorithm\ncurrently in use.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n commit.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 0c3b75aeff..ff05d04570 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -364,8 +364,8 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s\n \tstruct object_id parent;\n \tstruct commit_list **pptr;\n \tstruct commit_graft *graft;\n-\tconst int tree_entry_len = GIT_SHA1_HEXSZ + 5;\n-\tconst int parent_entry_len = GIT_SHA1_HEXSZ + 7;\n+\tconst int tree_entry_len = the_hash_algo->hexsz + 5;\n+\tconst int parent_entry_len = the_hash_algo->hexsz + 7;\n \n \tif (item->object.parsed)\n \t\treturn 0;\n"},{"id":"351904","messageId":"20180708233638.520172-7-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 06/17] sha1-name: use the_hash_algo when parsing object names","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:27Z","receivedAt":"2018-07-08T23:37:00Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n sha1-name.c | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/sha1-name.c b/sha1-name.c\nindex 60d9ef3c7e..ba6a5a689f 100644\n--- a/sha1-name.c\n+++ b/sha1-name.c\n@@ -310,7 +310,7 @@ static int init_object_disambiguation(const char *name, int len,\n {\n \tint i;\n \n-\tif (len < MINIMUM_ABBREV || len > GIT_SHA1_HEXSZ)\n+\tif (len < MINIMUM_ABBREV || len > the_hash_algo->hexsz)\n \t\treturn -1;\n \n \tmemset(ds, 0, sizeof(*ds));\n@@ -576,6 +576,8 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)\n \tstruct disambiguate_state ds;\n \tstruct min_abbrev_data mad;\n \tstruct object_id oid_ret;\n+\tconst unsigned hexsz = the_hash_algo->hexsz;\n+\n \tif (len < 0) {\n \t\tunsigned long count = approximate_object_count();\n \t\t/*\n@@ -599,8 +601,8 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)\n \t}\n \n \toid_to_hex_r(hex, oid);\n-\tif (len == GIT_SHA1_HEXSZ || !len)\n-\t\treturn GIT_SHA1_HEXSZ;\n+\tif (len == hexsz || !len)\n+\t\treturn hexsz;\n \n \tmad.init_len = len;\n \tmad.cur_len = len;\n@@ -706,7 +708,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,\n \tint refs_found = 0;\n \tint at, reflog_len, nth_prior = 0;\n \n-\tif (len == GIT_SHA1_HEXSZ && !get_oid_hex(str, oid)) {\n+\tif (len == the_hash_algo->hexsz && !get_oid_hex(str, oid)) {\n \t\tif (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {\n \t\t\trefs_found = dwim_ref(str, len, &tmp_oid, &real_ref);\n \t\t\tif (refs_found > 0) {\n@@ -750,7 +752,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,\n \t\tint detached;\n \n \t\tif (interpret_nth_prior_checkout(str, len, &buf) > 0) {\n-\t\t\tdetached = (buf.len == GIT_SHA1_HEXSZ && !get_oid_hex(buf.buf, oid));\n+\t\t\tdetached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid));\n \t\t\tstrbuf_release(&buf);\n \t\t\tif (detached)\n \t\t\t\treturn 0;\n"},{"id":"351905","messageId":"20180708233638.520172-6-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 05/17] strbuf: allocate space with GIT_MAX_HEXSZ","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:26Z","receivedAt":"2018-07-08T23:37:02Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"In order to be sure we have enough space to use with any hash algorithm,\nuse GIT_MAX_HEXSZ to allocate space.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n strbuf.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/strbuf.c b/strbuf.c\nindex b0716ac585..030556111d 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -921,7 +921,7 @@ void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,\n \t\t\t      int abbrev_len)\n {\n \tint r;\n-\tstrbuf_grow(sb, GIT_SHA1_HEXSZ + 1);\n+\tstrbuf_grow(sb, GIT_MAX_HEXSZ + 1);\n \tr = find_unique_abbrev_r(sb->buf + sb->len, oid, abbrev_len);\n \tstrbuf_setlen(sb, sb->len + r);\n }\n"},{"id":"351906","messageId":"20180708233638.520172-11-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 10/17] builtin/update-index: simplify parsing of cacheinfo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:31Z","receivedAt":"2018-07-08T23:37:04Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Switch from using get_oid_hex to parse_oid_hex to simplify pointer\noperations and avoid the need for a hash-related constant.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/update-index.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 031cef5229..3206c5ad45 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -827,6 +827,7 @@ static int parse_new_style_cacheinfo(const char *arg,\n {\n \tunsigned long ul;\n \tchar *endp;\n+\tconst char *p;\n \n \tif (!arg)\n \t\treturn -1;\n@@ -837,9 +838,9 @@ static int parse_new_style_cacheinfo(const char *arg,\n \t\treturn -1; /* not a new-style cacheinfo */\n \t*mode = ul;\n \tendp++;\n-\tif (get_oid_hex(endp, oid) || endp[GIT_SHA1_HEXSZ] != ',')\n+\tif (parse_oid_hex(endp, oid, &p) || *p != ',')\n \t\treturn -1;\n-\t*path = endp + GIT_SHA1_HEXSZ + 1;\n+\t*path = p + 1;\n \treturn 0;\n }\n \n"},{"id":"351907","messageId":"20180708233638.520172-12-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 11/17] builtin/fmt-merge-msg: make hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:32Z","receivedAt":"2018-07-08T23:37:06Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert several uses of GIT_SHA1_HEXSZ into references to the_hash_algo.\nSwitch other uses into a use of parse_oid_hex and uses of its computed\npointer.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/fmt-merge-msg.c | 19 ++++++++++---------\n 1 file changed, 10 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex bd680be687..e8c13a2c03 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -108,14 +108,15 @@ static int handle_line(char *line, struct merge_parents *merge_parents)\n \tstruct string_list_item *item;\n \tint pulling_head = 0;\n \tstruct object_id oid;\n+\tconst unsigned hexsz = the_hash_algo->hexsz;\n \n-\tif (len < GIT_SHA1_HEXSZ + 3 || line[GIT_SHA1_HEXSZ] != '\\t')\n+\tif (len < hexsz + 3 || line[hexsz] != '\\t')\n \t\treturn 1;\n \n-\tif (starts_with(line + GIT_SHA1_HEXSZ + 1, \"not-for-merge\"))\n+\tif (starts_with(line + hexsz + 1, \"not-for-merge\"))\n \t\treturn 0;\n \n-\tif (line[GIT_SHA1_HEXSZ + 1] != '\\t')\n+\tif (line[hexsz + 1] != '\\t')\n \t\treturn 2;\n \n \ti = get_oid_hex(line, &oid);\n@@ -130,7 +131,7 @@ static int handle_line(char *line, struct merge_parents *merge_parents)\n \n \tif (line[len - 1] == '\\n')\n \t\tline[len - 1] = 0;\n-\tline += GIT_SHA1_HEXSZ + 2;\n+\tline += hexsz + 2;\n \n \t/*\n \t * At this point, line points at the beginning of comment e.g.\n@@ -342,7 +343,7 @@ static void shortlog(const char *name,\n \tconst struct object_id *oid = &origin_data->oid;\n \tint limit = opts->shortlog_len;\n \n-\tbranch = deref_tag(parse_object(oid), oid_to_hex(oid), GIT_SHA1_HEXSZ);\n+\tbranch = deref_tag(parse_object(oid), oid_to_hex(oid), the_hash_algo->hexsz);\n \tif (!branch || branch->type != OBJ_COMMIT)\n \t\treturn;\n \n@@ -545,6 +546,7 @@ static void find_merge_parents(struct merge_parents *result,\n \t\tint len;\n \t\tchar *p = in->buf + pos;\n \t\tchar *newline = strchr(p, '\\n');\n+\t\tconst char *q;\n \t\tstruct object_id oid;\n \t\tstruct commit *parent;\n \t\tstruct object *obj;\n@@ -552,10 +554,9 @@ static void find_merge_parents(struct merge_parents *result,\n \t\tlen = newline ? newline - p : strlen(p);\n \t\tpos += len + !!newline;\n \n-\t\tif (len < GIT_SHA1_HEXSZ + 3 ||\n-\t\t    get_oid_hex(p, &oid) ||\n-\t\t    p[GIT_SHA1_HEXSZ] != '\\t' ||\n-\t\t    p[GIT_SHA1_HEXSZ + 1] != '\\t')\n+\t\tif (parse_oid_hex(p, &oid, &q) ||\n+\t\t    q[0] != '\\t' ||\n+\t\t    q[1] != '\\t')\n \t\t\tcontinue; /* skip not-for-merge */\n \t\t/*\n \t\t * Do not use get_merge_parent() here; we do not have\n"},{"id":"351908","messageId":"20180708233638.520172-15-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 14/17] diff: switch GIT_SHA1_HEXSZ to use the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:35Z","receivedAt":"2018-07-08T23:37:08Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n diff.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 639eb646b9..485ff6c264 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3832,7 +3832,7 @@ static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)\n \t\tchar *hex = oid_to_hex(oid);\n \t\tif (abbrev < 0)\n \t\t\tabbrev = FALLBACK_DEFAULT_ABBREV;\n-\t\tif (abbrev > GIT_SHA1_HEXSZ)\n+\t\tif (abbrev > the_hash_algo->hexsz)\n \t\t\tBUG(\"oid abbreviation out of range: %d\", abbrev);\n \t\tif (abbrev)\n \t\t\thex[abbrev] = '\\0';\n@@ -4947,7 +4947,7 @@ const char *diff_aligned_abbrev(const struct object_id *oid, int len)\n \tconst char *abbrev;\n \n \t/* Do we want all 40 hex characters? */\n-\tif (len == GIT_SHA1_HEXSZ)\n+\tif (len == the_hash_algo->hexsz)\n \t\treturn oid_to_hex(oid);\n \n \t/* An abbreviated value is fine, possibly followed by an ellipsis. */\n@@ -4977,7 +4977,7 @@ const char *diff_aligned_abbrev(const struct object_id *oid, int len)\n \t * the automatic sizing is supposed to give abblen that ensures\n \t * uniqueness across all objects (statistically speaking).\n \t */\n-\tif (abblen < GIT_SHA1_HEXSZ - 3) {\n+\tif (abblen < the_hash_algo->hexsz - 3) {\n \t\tstatic char hex[GIT_MAX_HEXSZ + 1];\n \t\tif (len < abblen && abblen <= len + 2)\n \t\t\txsnprintf(hex, sizeof(hex), \"%s%.*s\", abbrev, len+3-abblen, \"..\");\n"},{"id":"351909","messageId":"20180708233638.520172-14-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 13/17] builtin/merge-recursive: make hash independent","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:34Z","receivedAt":"2018-07-08T23:37:11Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Use GIT_MAX_HEXSZ instead of GIT_SHA1_HEXSZ for an allocation so that it\nis sufficiently large.  Switch a comparison to use the_hash_algo to\ndetermine the length of a hex object ID.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/merge-recursive.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c\nindex 0dd9021958..9b2f707c29 100644\n--- a/builtin/merge-recursive.c\n+++ b/builtin/merge-recursive.c\n@@ -9,10 +9,10 @@ static const char builtin_merge_recursive_usage[] =\n \n static const char *better_branch_name(const char *branch)\n {\n-\tstatic char githead_env[8 + GIT_SHA1_HEXSZ + 1];\n+\tstatic char githead_env[8 + GIT_MAX_HEXSZ + 1];\n \tchar *name;\n \n-\tif (strlen(branch) != GIT_SHA1_HEXSZ)\n+\tif (strlen(branch) != the_hash_algo->hexsz)\n \t\treturn branch;\n \txsnprintf(githead_env, sizeof(githead_env), \"GITHEAD_%s\", branch);\n \tname = getenv(githead_env);\n"},{"id":"351910","messageId":"20180708233638.520172-18-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 17/17] pretty: switch hard-coded constants to the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:38Z","receivedAt":"2018-07-08T23:37:12Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Switch several hard-coded constants into expressions based either on\nGIT_MAX_HEXSZ or the_hash_algo.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n pretty.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 703fa6ff7b..b0e653ff25 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1575,7 +1575,7 @@ static void pp_header(struct pretty_print_context *pp,\n \t\t}\n \n \t\tif (starts_with(line, \"parent \")) {\n-\t\t\tif (linelen != 48)\n+\t\t\tif (linelen != the_hash_algo->hexsz + 8)\n \t\t\t\tdie(\"bad parent line in commit\");\n \t\t\tcontinue;\n \t\t}\n@@ -1583,7 +1583,7 @@ static void pp_header(struct pretty_print_context *pp,\n \t\tif (!parents_shown) {\n \t\t\tunsigned num = commit_list_count(commit->parents);\n \t\t\t/* with enough slop */\n-\t\t\tstrbuf_grow(sb, num * 50 + 20);\n+\t\t\tstrbuf_grow(sb, num * (GIT_MAX_HEXSZ + 10) + 20);\n \t\t\tadd_merge_info(pp, sb, commit);\n \t\t\tparents_shown = 1;\n \t\t}\n"},{"id":"351911","messageId":"20180708233638.520172-16-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 15/17] log-tree: switch GIT_SHA1_HEXSZ to the_hash_algo->hexsz","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:36Z","receivedAt":"2018-07-08T23:37:13Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n log-tree.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex d3a43e29cd..9655de8ad7 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -545,7 +545,7 @@ void show_log(struct rev_info *opt)\n \tstruct strbuf msgbuf = STRBUF_INIT;\n \tstruct log_info *log = opt->loginfo;\n \tstruct commit *commit = log->commit, *parent = log->parent;\n-\tint abbrev_commit = opt->abbrev_commit ? opt->abbrev : GIT_SHA1_HEXSZ;\n+\tint abbrev_commit = opt->abbrev_commit ? opt->abbrev : the_hash_algo->hexsz;\n \tconst char *extra_headers = opt->extra_headers;\n \tstruct pretty_print_context ctx = {0};\n \n"},{"id":"351912","messageId":"20180708233638.520172-17-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 16/17] sha1-file: convert constants to uses of the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:37Z","receivedAt":"2018-07-08T23:37:15Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Convert one use of 20 and several uses of GIT_SHA1_HEXSZ into references\nto the_hash_algo.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n sha1-file.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/sha1-file.c b/sha1-file.c\nindex de4839e634..1f66b9594f 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -336,7 +336,7 @@ int raceproof_create_file(const char *path, create_file_fn fn, void *cb)\n static void fill_sha1_path(struct strbuf *buf, const unsigned char *sha1)\n {\n \tint i;\n-\tfor (i = 0; i < 20; i++) {\n+\tfor (i = 0; i < the_hash_algo->rawsz; i++) {\n \t\tstatic char hex[] = \"0123456789abcdef\";\n \t\tunsigned int val = sha1[i];\n \t\tstrbuf_addch(buf, hex[val >> 4]);\n@@ -1473,7 +1473,7 @@ void *read_object_with_reference(const struct object_id *oid,\n \t\t}\n \t\tref_length = strlen(ref_type);\n \n-\t\tif (ref_length + GIT_SHA1_HEXSZ > isize ||\n+\t\tif (ref_length + the_hash_algo->hexsz > isize ||\n \t\t    memcmp(buffer, ref_type, ref_length) ||\n \t\t    get_oid_hex((char *) buffer + ref_length, &actual_oid)) {\n \t\t\tfree(buffer);\n@@ -2062,9 +2062,9 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,\n \t\tnamelen = strlen(de->d_name);\n \t\tstrbuf_setlen(path, baselen);\n \t\tstrbuf_add(path, de->d_name, namelen);\n-\t\tif (namelen == GIT_SHA1_HEXSZ - 2 &&\n+\t\tif (namelen == the_hash_algo->hexsz - 2 &&\n \t\t    !hex_to_bytes(oid.hash + 1, de->d_name,\n-\t\t\t\t  GIT_SHA1_RAWSZ - 1)) {\n+\t\t\t\t  the_hash_algo->rawsz - 1)) {\n \t\t\tif (obj_cb) {\n \t\t\t\tr = obj_cb(&oid, path->buf, data);\n \t\t\t\tif (r)\n"},{"id":"351913","messageId":"20180708233638.520172-13-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 12/17] builtin/merge: switch to use the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:33Z","receivedAt":"2018-07-08T23:37:21Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Switch uses of GIT_SHA1_HEXSZ to use the_hash_algo instead.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/merge.c | 11 ++++++-----\n 1 file changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex 4a4c09496c..916c9f0569 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -1034,6 +1034,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge\n \tconst char *filename;\n \tint fd, pos, npos;\n \tstruct strbuf fetch_head_file = STRBUF_INIT;\n+\tconst unsigned hexsz = the_hash_algo->hexsz;\n \n \tif (!merge_names)\n \t\tmerge_names = &fetch_head_file;\n@@ -1059,16 +1060,16 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge\n \t\telse\n \t\t\tnpos = merge_names->len;\n \n-\t\tif (npos - pos < GIT_SHA1_HEXSZ + 2 ||\n+\t\tif (npos - pos < hexsz + 2 ||\n \t\t    get_oid_hex(merge_names->buf + pos, &oid))\n \t\t\tcommit = NULL; /* bad */\n-\t\telse if (memcmp(merge_names->buf + pos + GIT_SHA1_HEXSZ, \"\\t\\t\", 2))\n+\t\telse if (memcmp(merge_names->buf + pos + hexsz, \"\\t\\t\", 2))\n \t\t\tcontinue; /* not-for-merge */\n \t\telse {\n-\t\t\tchar saved = merge_names->buf[pos + GIT_SHA1_HEXSZ];\n-\t\t\tmerge_names->buf[pos + GIT_SHA1_HEXSZ] = '\\0';\n+\t\t\tchar saved = merge_names->buf[pos + hexsz];\n+\t\t\tmerge_names->buf[pos + hexsz] = '\\0';\n \t\t\tcommit = get_merge_parent(merge_names->buf + pos);\n-\t\t\tmerge_names->buf[pos + GIT_SHA1_HEXSZ] = saved;\n+\t\t\tmerge_names->buf[pos + hexsz] = saved;\n \t\t}\n \t\tif (!commit) {\n \t\t\tif (ptr)\n"},{"id":"351914","messageId":"20180708233638.520172-10-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 09/17] builtin/update-index: convert to using the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:30Z","receivedAt":"2018-07-08T23:37:27Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Switch from using GIT_SHA1_HEXSZ to the_hash_algo to make the parsing of\nthe index information hash independent.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n builtin/update-index.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex a8709a26ec..031cef5229 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -492,6 +492,7 @@ static void update_one(const char *path)\n \n static void read_index_info(int nul_term_line)\n {\n+\tconst int hexsz = the_hash_algo->hexsz;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct strbuf uq = STRBUF_INIT;\n \tstrbuf_getline_fn getline_fn;\n@@ -529,7 +530,7 @@ static void read_index_info(int nul_term_line)\n \t\tmode = ul;\n \n \t\ttab = strchr(ptr, '\\t');\n-\t\tif (!tab || tab - ptr < GIT_SHA1_HEXSZ + 1)\n+\t\tif (!tab || tab - ptr < hexsz + 1)\n \t\t\tgoto bad_line;\n \n \t\tif (tab[-2] == ' ' && '0' <= tab[-1] && tab[-1] <= '3') {\n@@ -542,8 +543,8 @@ static void read_index_info(int nul_term_line)\n \t\t\tptr = tab + 1; /* point at the head of path */\n \t\t}\n \n-\t\tif (get_oid_hex(tab - GIT_SHA1_HEXSZ, &oid) ||\n-\t\t\ttab[-(GIT_SHA1_HEXSZ + 1)] != ' ')\n+\t\tif (get_oid_hex(tab - hexsz, &oid) ||\n+\t\t\ttab[-(hexsz + 1)] != ' ')\n \t\t\tgoto bad_line;\n \n \t\tpath_name = ptr;\n@@ -571,7 +572,7 @@ static void read_index_info(int nul_term_line)\n \t\t\t * ptr[-1] points at tab,\n \t\t\t * ptr[-41] is at the beginning of sha1\n \t\t\t */\n-\t\t\tptr[-(GIT_SHA1_HEXSZ + 2)] = ptr[-1] = 0;\n+\t\t\tptr[-(hexsz + 2)] = ptr[-1] = 0;\n \t\t\tif (add_cacheinfo(mode, &oid, path_name, stage))\n \t\t\t\tdie(\"git update-index: unable to update %s\",\n \t\t\t\t    path_name);\n"},{"id":"351915","messageId":"20180708233638.520172-8-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 07/17] commit: increase commit message buffer size","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:28Z","receivedAt":"2018-07-08T23:37:28Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"100 bytes is not sufficient to ensure we can write a commit message\nbuffer when using a 32-byte hash algorithm.  Increase the buffer size to\nensure we have sufficient space.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n refs/files-backend.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex a9a066dcfb..252f835bae 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n \tchar *logrec;\n \n \tmsglen = msg ? strlen(msg) : 0;\n-\tmaxlen = strlen(committer) + msglen + 100;\n+\tmaxlen = strlen(committer) + msglen + 200;\n \tlogrec = xmalloc(maxlen);\n \tlen = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n \t\t\toid_to_hex(old_oid),\n"},{"id":"351916","messageId":"20180708233638.520172-9-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 08/17] refs/files-backend: use the_hash_algo for writing refs","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:29Z","receivedAt":"2018-07-08T23:37:30Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"In order to ensure we write the correct amount, use the_hash_algo to\nfind the correct number of bytes for the current hash.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n refs/files-backend.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 252f835bae..4a724f20a9 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -1676,7 +1676,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,\n \t\treturn -1;\n \t}\n \tfd = get_lock_file_fd(&lock->lk);\n-\tif (write_in_full(fd, oid_to_hex(oid), GIT_SHA1_HEXSZ) < 0 ||\n+\tif (write_in_full(fd, oid_to_hex(oid), the_hash_algo->hexsz) < 0 ||\n \t    write_in_full(fd, &term, 1) < 0 ||\n \t    close_ref_gently(lock) < 0) {\n \t\tstrbuf_addf(err,\n@@ -3070,7 +3070,7 @@ static int files_reflog_expire(struct ref_store *ref_store,\n \t\t\trollback_lock_file(&reflog_lock);\n \t\t} else if (update &&\n \t\t\t   (write_in_full(get_lock_file_fd(&lock->lk),\n-\t\t\t\toid_to_hex(&cb.last_kept_oid), GIT_SHA1_HEXSZ) < 0 ||\n+\t\t\t\toid_to_hex(&cb.last_kept_oid), the_hash_algo->hexsz) < 0 ||\n \t\t\t    write_str_in_full(get_lock_file_fd(&lock->lk), \"\\n\") < 0 ||\n \t\t\t    close_ref_gently(lock) < 0)) {\n \t\t\tstatus |= error(\"couldn't write %s\",\n"},{"id":"351917","messageId":"20180708233638.520172-3-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 02/17] tree-walk: replace hard-coded constants with the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:23Z","receivedAt":"2018-07-08T23:37:36Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Remove the hard-coded 20-based values and replace them with uses of\nthe_hash_algo.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n tree-walk.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 8f5090862b..c1f27086a9 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -26,8 +26,9 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned l\n {\n \tconst char *path;\n \tunsigned int mode, len;\n+\tconst unsigned hashsz = the_hash_algo->rawsz;\n \n-\tif (size < 23 || buf[size - 21]) {\n+\tif (size < hashsz + 3 || buf[size - (hashsz + 1)]) {\n \t\tstrbuf_addstr(err, _(\"too-short tree object\"));\n \t\treturn -1;\n \t}\n"},{"id":"351918","messageId":"20180708233638.520172-4-sandals@crustytoothpaste.net","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"[PATCH 03/17] hex: switch to using the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T23:36:24Z","receivedAt":"2018-07-08T23:37:37Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"Instead of using the GIT_SHA1_* constants, switch to using the_hash_algo\nto convert object IDs to and from hex format.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n hex.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/hex.c b/hex.c\nindex 8df2d63728..10af1a29e8 100644\n--- a/hex.c\n+++ b/hex.c\n@@ -50,7 +50,7 @@ int hex_to_bytes(unsigned char *binary, const char *hex, size_t len)\n int get_sha1_hex(const char *hex, unsigned char *sha1)\n {\n \tint i;\n-\tfor (i = 0; i < GIT_SHA1_RAWSZ; i++) {\n+\tfor (i = 0; i < the_hash_algo->rawsz; i++) {\n \t\tint val = hex2chr(hex);\n \t\tif (val < 0)\n \t\t\treturn -1;\n@@ -69,7 +69,7 @@ int parse_oid_hex(const char *hex, struct object_id *oid, const char **end)\n {\n \tint ret = get_oid_hex(hex, oid);\n \tif (!ret)\n-\t\t*end = hex + GIT_SHA1_HEXSZ;\n+\t\t*end = hex + the_hash_algo->hexsz;\n \treturn ret;\n }\n \n@@ -79,7 +79,7 @@ char *sha1_to_hex_r(char *buffer, const unsigned char *sha1)\n \tchar *buf = buffer;\n \tint i;\n \n-\tfor (i = 0; i < GIT_SHA1_RAWSZ; i++) {\n+\tfor (i = 0; i < the_hash_algo->rawsz; i++) {\n \t\tunsigned int val = *sha1++;\n \t\t*buf++ = hex[val >> 4];\n \t\t*buf++ = hex[val & 0xf];\n"},{"id":"351919","messageId":"CA+P7+xq900ikNR3uBEo28rjrTh5iYJm-R8jcAjhq-7G2jh3iVA@mail.gmail.com","threadId":"48842","inReplyTo":"20180708233638.520172-2-sandals@crustytoothpaste.net","subject":"Re: [PATCH 01/17] cache: update object ID functions for the_hash_algo","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2018-07-09T02:38:21Z","receivedAt":"2018-07-09T02:38:39Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Sun, Jul 8, 2018 at 4:39 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>  static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)\n>  {\n> -       return hashcmp(oid1->hash, oid2->hash);\n> +       return memcmp(oid1->hash, oid2->hash, the_hash_algo->rawsz);\n>  }\n>\n\nJust curious, what's the reasoning for not using the hashcmp anymore?\n\nThanks,\nJake\n"},{"id":"351920","messageId":"CA+P7+xq9SeoZjYYWhM14-u4kGgwmNVPs6c+wFR2EbwK+_hVetg@mail.gmail.com","threadId":"48842","inReplyTo":"20180708233638.520172-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 00/17] object_id part 14","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2018-07-09T03:12:54Z","receivedAt":"2018-07-09T03:13:14Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Sun, Jul 8, 2018 at 4:39 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> This is the fourteenth series of patches to switch to using struct\n> object_id and the_hash_algo.  This series converts several core pieces\n> to use struct object_id, including the oid* and hex functions.\n>\n> All of these patches have been tested with both SHA-1 and a 256-bit\n> hash.\n>\n\nI read through the series, and didn't spot anything odd, except for\nthe question about reasoning for why we use memcmp directly over using\nhashcmp. I don't think that's any sort of blocker, it just seemed an\nodd decision to me.\n\nThanks,\nJake\n"},{"id":"351922","messageId":"CAPig+cRznUKdriPhHMt5ocb_pXbByY5a40A8ZOiqF=_0hm7avw@mail.gmail.com","threadId":"48842","inReplyTo":"CA+P7+xq900ikNR3uBEo28rjrTh5iYJm-R8jcAjhq-7G2jh3iVA@mail.gmail.com","subject":"Re: [PATCH 01/17] cache: update object ID functions for the_hash_algo","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-07-09T04:05:30Z","receivedAt":"2018-07-09T04:05:47Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jul 8, 2018 at 10:38 PM Jacob Keller <jacob.keller@gmail.com> wrote:\n> On Sun, Jul 8, 2018 at 4:39 PM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n> >  static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)\n> >  {\n> > -       return hashcmp(oid1->hash, oid2->hash);\n> > +       return memcmp(oid1->hash, oid2->hash, the_hash_algo->rawsz);\n> >  }\n>\n> Just curious, what's the reasoning for not using the hashcmp anymore?\n\nhashcmp() is specific to SHA-1 (for instance, it hardocdes\nGIT_SHA1_RAWSZ). oidcmp() is meant as the hash-agnostic replacement\nfor hashcmp(), so it doesn't make sense to continue implementing\noidcmp() in terms of hashcmp() (the latter of which will eventually be\nretired, presumably).\n"},{"id":"351923","messageId":"CA+P7+xoMSWfV1ZqokGDvoZVRP65puiiwhTKHbuaiUPS2suA3oQ@mail.gmail.com","threadId":"48842","inReplyTo":"CAPig+cRznUKdriPhHMt5ocb_pXbByY5a40A8ZOiqF=_0hm7avw@mail.gmail.com","subject":"Re: [PATCH 01/17] cache: update object ID functions for the_hash_algo","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2018-07-09T04:31:42Z","receivedAt":"2018-07-09T04:32:00Z","isPatch":true,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Sun, Jul 8, 2018 at 9:05 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> On Sun, Jul 8, 2018 at 10:38 PM Jacob Keller <jacob.keller@gmail.com> wrote:\n> > On Sun, Jul 8, 2018 at 4:39 PM brian m. carlson\n> > <sandals@crustytoothpaste.net> wrote:\n> > >  static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)\n> > >  {\n> > > -       return hashcmp(oid1->hash, oid2->hash);\n> > > +       return memcmp(oid1->hash, oid2->hash, the_hash_algo->rawsz);\n> > >  }\n> >\n> > Just curious, what's the reasoning for not using the hashcmp anymore?\n>\n> hashcmp() is specific to SHA-1 (for instance, it hardocdes\n> GIT_SHA1_RAWSZ). oidcmp() is meant as the hash-agnostic replacement\n> for hashcmp(), so it doesn't make sense to continue implementing\n> oidcmp() in terms of hashcmp() (the latter of which will eventually be\n> retired, presumably).\n\nFair. I just saw that hashcmp was also updated to use the_hash_algo,\nbut if we're going to drop it eventually, then there's zero reason to\nkeep implementing oidcmp in terms of it, so... makes sense to me!\n\nThanks,\nJake\n"},{"id":"351939","messageId":"4eb44f33-ac9c-7ce2-0e53-ec6fcb4560fd@gmail.com","threadId":"48842","inReplyTo":"20180708233638.520172-8-sandals@crustytoothpaste.net","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-07-09T13:09:00Z","receivedAt":"2018-07-09T13:09:07Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 7/8/2018 7:36 PM, brian m. carlson wrote:\n> 100 bytes is not sufficient to ensure we can write a commit message\n> buffer when using a 32-byte hash algorithm.  Increase the buffer size to\n> ensure we have sufficient space.\n>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n>   refs/files-backend.c | 2 +-\n>   1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/refs/files-backend.c b/refs/files-backend.c\n> index a9a066dcfb..252f835bae 100644\n> --- a/refs/files-backend.c\n> +++ b/refs/files-backend.c\n> @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n>   \tchar *logrec;\n>   \n>   \tmsglen = msg ? strlen(msg) : 0;\n> -\tmaxlen = strlen(committer) + msglen + 100;\n> +\tmaxlen = strlen(committer) + msglen + 200;\n>   \tlogrec = xmalloc(maxlen);\n>   \tlen = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n>   \t\t\toid_to_hex(old_oid),\n\nnit: 100 is not enough anymore, but wasn't a very descriptive value. 200 \nmay be enough now, but I'm not sure why.\n\nThanks,\n-Stolee\n"},{"id":"351940","messageId":"1438bdfd-cb13-8da4-2dd2-16362b242ff3@gmail.com","threadId":"48842","inReplyTo":"CA+P7+xq9SeoZjYYWhM14-u4kGgwmNVPs6c+wFR2EbwK+_hVetg@mail.gmail.com","subject":"Re: [PATCH 00/17] object_id part 14","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2018-07-09T13:12:03Z","receivedAt":"2018-07-09T13:12:08Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 7/8/2018 11:12 PM, Jacob Keller wrote:\n> On Sun, Jul 8, 2018 at 4:39 PM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n>> This is the fourteenth series of patches to switch to using struct\n>> object_id and the_hash_algo.  This series converts several core pieces\n>> to use struct object_id, including the oid* and hex functions.\n>>\n>> All of these patches have been tested with both SHA-1 and a 256-bit\n>> hash.\n>>\n> I read through the series, and didn't spot anything odd, except for\n> the question about reasoning for why we use memcmp directly over using\n> hashcmp. I don't think that's any sort of blocker, it just seemed an\n> odd decision to me.\n\nI also read through the series and only found the 100/200 constants \nconfusing. Not worth blocking on, but I'm CC'ing Michael Haggerty to \ncomment if he knows how the magic 100 was computed.\n\nThanks,\n-Stolee\n"},{"id":"351961","messageId":"CAGZ79kaJKjWj9SY-cZYYcKShuooh3nuRqf26CzhCsusTXX42NA@mail.gmail.com","threadId":"48842","inReplyTo":"4eb44f33-ac9c-7ce2-0e53-ec6fcb4560fd@gmail.com","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-07-09T17:24:24Z","receivedAt":"2018-07-09T17:24:39Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, Jul 9, 2018 at 6:09 AM Derrick Stolee <stolee@gmail.com> wrote:\n>\n> On 7/8/2018 7:36 PM, brian m. carlson wrote:\n> > 100 bytes is not sufficient to ensure we can write a commit message\n> > buffer when using a 32-byte hash algorithm.  Increase the buffer size to\n> > ensure we have sufficient space.\n> >\n> > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> > ---\n> >   refs/files-backend.c | 2 +-\n> >   1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/refs/files-backend.c b/refs/files-backend.c\n> > index a9a066dcfb..252f835bae 100644\n> > --- a/refs/files-backend.c\n> > +++ b/refs/files-backend.c\n> > @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n> >       char *logrec;\n> >\n> >       msglen = msg ? strlen(msg) : 0;\n> > -     maxlen = strlen(committer) + msglen + 100;\n> > +     maxlen = strlen(committer) + msglen + 200;\n> >       logrec = xmalloc(maxlen);\n> >       len = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n> >                       oid_to_hex(old_oid),\n>\n> nit: 100 is not enough anymore, but wasn't a very descriptive value. 200\n> may be enough now, but I'm not sure why.\n\nThat line was touched in by Michael in 7bd9bcf372d (refs: split filesystem-based\nrefs code into a new file, 2015-11-09) and before that by Ronnie in 2c6207abbd6\n(refs.c: add a function to append a reflog entry to a fd, 2014-12-12)\nand introduced\nby Junio in 8ac65937d03 (Make sure we do not write bogus reflog\nentries., 2007-01-26)\nand it appears to me that 2*40 + 5 ought to be sufficient, but no\ncomments or commit\nmessages are found as to why we rather choose 100.\n"},{"id":"351962","messageId":"20180709172716.GA81741@google.com","threadId":"48842","inReplyTo":"CAGZ79kaJKjWj9SY-cZYYcKShuooh3nuRqf26CzhCsusTXX42NA@mail.gmail.com","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-07-09T17:27:16Z","receivedAt":"2018-07-09T17:27:23Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 07/09, Stefan Beller wrote:\n> On Mon, Jul 9, 2018 at 6:09 AM Derrick Stolee <stolee@gmail.com> wrote:\n> >\n> > On 7/8/2018 7:36 PM, brian m. carlson wrote:\n> > > 100 bytes is not sufficient to ensure we can write a commit message\n> > > buffer when using a 32-byte hash algorithm.  Increase the buffer size to\n> > > ensure we have sufficient space.\n> > >\n> > > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> > > ---\n> > >   refs/files-backend.c | 2 +-\n> > >   1 file changed, 1 insertion(+), 1 deletion(-)\n> > >\n> > > diff --git a/refs/files-backend.c b/refs/files-backend.c\n> > > index a9a066dcfb..252f835bae 100644\n> > > --- a/refs/files-backend.c\n> > > +++ b/refs/files-backend.c\n> > > @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n> > >       char *logrec;\n> > >\n> > >       msglen = msg ? strlen(msg) : 0;\n> > > -     maxlen = strlen(committer) + msglen + 100;\n> > > +     maxlen = strlen(committer) + msglen + 200;\n> > >       logrec = xmalloc(maxlen);\n> > >       len = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n> > >                       oid_to_hex(old_oid),\n> >\n> > nit: 100 is not enough anymore, but wasn't a very descriptive value. 200\n> > may be enough now, but I'm not sure why.\n> \n> That line was touched in by Michael in 7bd9bcf372d (refs: split filesystem-based\n> refs code into a new file, 2015-11-09) and before that by Ronnie in 2c6207abbd6\n> (refs.c: add a function to append a reflog entry to a fd, 2014-12-12)\n> and introduced\n> by Junio in 8ac65937d03 (Make sure we do not write bogus reflog\n> entries., 2007-01-26)\n> and it appears to me that 2*40 + 5 ought to be sufficient, but no\n> comments or commit\n> messages are found as to why we rather choose 100.\n\nWhats the reason for not using a strbuf here so that we don't have to\nplay with magic numbers?\n\n-- \nBrandon Williams\n"},{"id":"351964","messageId":"xmqqzhz0e2k1.fsf@gitster-ct.c.googlers.com","threadId":"48842","inReplyTo":"20180709172716.GA81741@google.com","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-09T17:34:06Z","receivedAt":"2018-07-09T17:34:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n>> > > diff --git a/refs/files-backend.c b/refs/files-backend.c\n>> > > index a9a066dcfb..252f835bae 100644\n>> > > --- a/refs/files-backend.c\n>> > > +++ b/refs/files-backend.c\n>> > > @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n>> > >       char *logrec;\n>> > >\n>> > >       msglen = msg ? strlen(msg) : 0;\n>> > > -     maxlen = strlen(committer) + msglen + 100;\n>> > > +     maxlen = strlen(committer) + msglen + 200;\n>> > >       logrec = xmalloc(maxlen);\n>> > >       len = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n>> > >                       oid_to_hex(old_oid),\n>> >\n>> > nit: 100 is not enough anymore, but wasn't a very descriptive value. 200\n>> > may be enough now, but I'm not sure why.\n>> \n>> That line was touched in by Michael in 7bd9bcf372d (refs: split filesystem-based\n>> refs code into a new file, 2015-11-09) and before that by Ronnie in 2c6207abbd6\n>> (refs.c: add a function to append a reflog entry to a fd, 2014-12-12)\n>> and introduced\n>> by Junio in 8ac65937d03 (Make sure we do not write bogus reflog\n>> entries., 2007-01-26)\n>> and it appears to me that 2*40 + 5 ought to be sufficient, but no\n>> comments or commit\n>> messages are found as to why we rather choose 100.\n>\n> Whats the reason for not using a strbuf here so that we don't have to\n> play with magic numbers?\n\nQuite a legitimate question.  \n\nI suspect that the reason is because the code (even though it now\nsits in a file that was relatively recently creted) predates either\nthe introduction or wide adoption of strbuf.\n\nBack when 6de08ae6 (\"Log ref updates to logs/refs/<ref>\",\n2006-05-17) was done, we already had strbuf.c, but it only had\nread_line() and nothing else back then, so it wouldn't have been\npossible to use a strbuf there.\n\n\n"},{"id":"351965","messageId":"20180709173642.GB81741@google.com","threadId":"48842","inReplyTo":"xmqqzhz0e2k1.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-07-09T17:36:42Z","receivedAt":"2018-07-09T17:36:48Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 07/09, Junio C Hamano wrote:\n> Brandon Williams <bmwill@google.com> writes:\n> \n> >> > > diff --git a/refs/files-backend.c b/refs/files-backend.c\n> >> > > index a9a066dcfb..252f835bae 100644\n> >> > > --- a/refs/files-backend.c\n> >> > > +++ b/refs/files-backend.c\n> >> > > @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n> >> > >       char *logrec;\n> >> > >\n> >> > >       msglen = msg ? strlen(msg) : 0;\n> >> > > -     maxlen = strlen(committer) + msglen + 100;\n> >> > > +     maxlen = strlen(committer) + msglen + 200;\n> >> > >       logrec = xmalloc(maxlen);\n> >> > >       len = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n> >> > >                       oid_to_hex(old_oid),\n> >> >\n> >> > nit: 100 is not enough anymore, but wasn't a very descriptive value. 200\n> >> > may be enough now, but I'm not sure why.\n> >> \n> >> That line was touched in by Michael in 7bd9bcf372d (refs: split filesystem-based\n> >> refs code into a new file, 2015-11-09) and before that by Ronnie in 2c6207abbd6\n> >> (refs.c: add a function to append a reflog entry to a fd, 2014-12-12)\n> >> and introduced\n> >> by Junio in 8ac65937d03 (Make sure we do not write bogus reflog\n> >> entries., 2007-01-26)\n> >> and it appears to me that 2*40 + 5 ought to be sufficient, but no\n> >> comments or commit\n> >> messages are found as to why we rather choose 100.\n> >\n> > Whats the reason for not using a strbuf here so that we don't have to\n> > play with magic numbers?\n> \n> Quite a legitimate question.  \n> \n> I suspect that the reason is because the code (even though it now\n> sits in a file that was relatively recently creted) predates either\n> the introduction or wide adoption of strbuf.\n> \n> Back when 6de08ae6 (\"Log ref updates to logs/refs/<ref>\",\n> 2006-05-17) was done, we already had strbuf.c, but it only had\n> read_line() and nothing else back then, so it wouldn't have been\n> possible to use a strbuf there.\n\nFair enough, having never working in the code back then I don't know\nwhat life was like without strbuf.\n\n-- \nBrandon Williams\n"},{"id":"351967","messageId":"xmqqva9oe20y.fsf@gitster-ct.c.googlers.com","threadId":"48842","inReplyTo":"4eb44f33-ac9c-7ce2-0e53-ec6fcb4560fd@gmail.com","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-09T17:45:33Z","receivedAt":"2018-07-09T17:45:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n> On 7/8/2018 7:36 PM, brian m. carlson wrote:\n>> 100 bytes is not sufficient to ensure we can write a commit message\n>> buffer when using a 32-byte hash algorithm.  Increase the buffer size to\n>> ensure we have sufficient space.\n>>\n>> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n>> ---\n>>   refs/files-backend.c | 2 +-\n>>   1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/refs/files-backend.c b/refs/files-backend.c\n>> index a9a066dcfb..252f835bae 100644\n>> --- a/refs/files-backend.c\n>> +++ b/refs/files-backend.c\n>> @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n>>   \tchar *logrec;\n>>     \tmsglen = msg ? strlen(msg) : 0;\n>> -\tmaxlen = strlen(committer) + msglen + 100;\n>> +\tmaxlen = strlen(committer) + msglen + 200;\n>>   \tlogrec = xmalloc(maxlen);\n>>   \tlen = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n>>   \t\t\toid_to_hex(old_oid),\n>\n> nit: 100 is not enough anymore, but wasn't a very descriptive\n> value. 200 may be enough now, but I'm not sure why.\n\nAs Brandon alludes to downthread, we probably should use strbuf for\nthings like this these days, so a preliminary clean-up to do so is\nprobably a welcome change to sneak in and rebase this series on top\nof.\n\n\"%s %s %s\\n\" with old and new commit object name and the message\nwill be \"2 * len(hash_in_hex) + 4\" bytes long (counting the three\nwhitespaces and the terminating NUL), and Shawn's original in\n6de08ae6 (\"Log ref updates to logs/refs/<ref>\", 2006-05-17) actually\ncomputed this one as \"strlen(...) + 2*40+4\".\n\n100 was merely me being sloppier than Shawn at 8ac65937 (\"Make sure\nwe do not write bogus reflog entries.\", 2007-01-26), preferring\nbeing sufficient over not wasting even a single byte.\n"},{"id":"352048","messageId":"20180709232656.GA535220@genre.crustytoothpaste.net","threadId":"48842","inReplyTo":"CA+P7+xoMSWfV1ZqokGDvoZVRP65puiiwhTKHbuaiUPS2suA3oQ@mail.gmail.com","subject":"Re: [PATCH 01/17] cache: update object ID functions for the_hash_algo","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-09T23:26:57Z","receivedAt":"2018-07-09T23:27:08Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sun, Jul 08, 2018 at 09:31:42PM -0700, Jacob Keller wrote:\n> On Sun, Jul 8, 2018 at 9:05 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n> >\n> > On Sun, Jul 8, 2018 at 10:38 PM Jacob Keller <jacob.keller@gmail.com> wrote:\n> > > On Sun, Jul 8, 2018 at 4:39 PM brian m. carlson\n> > > <sandals@crustytoothpaste.net> wrote:\n> > > >  static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)\n> > > >  {\n> > > > -       return hashcmp(oid1->hash, oid2->hash);\n> > > > +       return memcmp(oid1->hash, oid2->hash, the_hash_algo->rawsz);\n> > > >  }\n> > >\n> > > Just curious, what's the reasoning for not using the hashcmp anymore?\n> >\n> > hashcmp() is specific to SHA-1 (for instance, it hardocdes\n> > GIT_SHA1_RAWSZ). oidcmp() is meant as the hash-agnostic replacement\n> > for hashcmp(), so it doesn't make sense to continue implementing\n> > oidcmp() in terms of hashcmp() (the latter of which will eventually be\n> > retired, presumably).\n> \n> Fair. I just saw that hashcmp was also updated to use the_hash_algo,\n> but if we're going to drop it eventually, then there's zero reason to\n> keep implementing oidcmp in terms of it, so... makes sense to me!\n\nActually, this reminded me that I have a patch that I had forgotten\nabout in my next series that updates hashcmp.  I'll squash that in in my\nreroll, and undo this change.\n\nAs a bonus, it also has a nicer commit message which I will include\nexplaining why this is necessary.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"352049","messageId":"20180709233952.GB535220@genre.crustytoothpaste.net","threadId":"48842","inReplyTo":"xmqqva9oe20y.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-09T23:39:52Z","receivedAt":"2018-07-09T23:40:02Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Mon, Jul 09, 2018 at 10:45:33AM -0700, Junio C Hamano wrote:\n> Derrick Stolee <stolee@gmail.com> writes:\n> \n> > On 7/8/2018 7:36 PM, brian m. carlson wrote:\n> >> diff --git a/refs/files-backend.c b/refs/files-backend.c\n> >> index a9a066dcfb..252f835bae 100644\n> >> --- a/refs/files-backend.c\n> >> +++ b/refs/files-backend.c\n> >> @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n> >>   \tchar *logrec;\n> >>     \tmsglen = msg ? strlen(msg) : 0;\n> >> -\tmaxlen = strlen(committer) + msglen + 100;\n> >> +\tmaxlen = strlen(committer) + msglen + 200;\n> >>   \tlogrec = xmalloc(maxlen);\n> >>   \tlen = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n> >>   \t\t\toid_to_hex(old_oid),\n> >\n> > nit: 100 is not enough anymore, but wasn't a very descriptive\n> > value. 200 may be enough now, but I'm not sure why.\n\n200 is definitely enough.  Suppose we had a message consisting entirely\nof SHA-1 hashes (5, at 20 bytes a piece).  If our new hash is 32 bytes\nlong, then it would require at most 160 bytes.\n\nI only noticed this because the old code segfaulted.  My approach to\nusing a 32-byte hash was to set it up, do some basic tests, find out\nwhat crashed, and fix it.  Most of this series is the basics necessary\nto get the most rudimentary functionality out of a 32-byte Git,\nexcluding the index pieces, which are necessarily inelegant.\n\nI didn't include them because there are other ways to implement the\nchanges which are more elegant in some ways and less elegant in other\nways, and I want to think more about it before I send them in.\n\n> As Brandon alludes to downthread, we probably should use strbuf for\n> things like this these days, so a preliminary clean-up to do so is\n> probably a welcome change to sneak in and rebase this series on top\n> of.\n\nSure, I agree that would be a better change, and I'm happy to reroll\nwith that.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"352131","messageId":"xmqq1scb9hg6.fsf@gitster-ct.c.googlers.com","threadId":"48842","inReplyTo":"20180709233952.GB535220@genre.crustytoothpaste.net","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-10T16:35:53Z","receivedAt":"2018-07-10T16:35:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n>> As Brandon alludes to downthread, we probably should use strbuf for\n>> things like this these days, so a preliminary clean-up to do so is\n>> probably a welcome change to sneak in and rebase this series on top\n>> of.\n>\n> Sure, I agree that would be a better change, and I'm happy to reroll\n> with that.\n\nOr we can do the clean-up after this 17-patch series settles, which\nprobably is a better order to do things.  It is usually better to\nmake a longer but more mechanical topic like this pass through the\nsystem rather quickly, which tends to minimize disruption on other\ntopics.\n"},{"id":"352156","messageId":"02c0682a-8cc9-be49-b646-00cbdb5783f3@gmail.com","threadId":"48842","inReplyTo":"20180709233952.GB535220@genre.crustytoothpaste.net","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Ben Peart","fromEmail":"peartben@gmail.com","sentAt":"2018-07-10T18:08:28Z","receivedAt":"2018-07-10T18:39:38Z","isPatch":true,"sender":{"key":"benpeart@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/15252029?v=4"},"body":"\n\nOn 7/9/2018 7:39 PM, brian m. carlson wrote:\n> On Mon, Jul 09, 2018 at 10:45:33AM -0700, Junio C Hamano wrote:\n>> Derrick Stolee <stolee@gmail.com> writes:\n>>\n>>> On 7/8/2018 7:36 PM, brian m. carlson wrote:\n>>>> diff --git a/refs/files-backend.c b/refs/files-backend.c\n>>>> index a9a066dcfb..252f835bae 100644\n>>>> --- a/refs/files-backend.c\n>>>> +++ b/refs/files-backend.c\n>>>> @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,\n>>>>    \tchar *logrec;\n>>>>      \tmsglen = msg ? strlen(msg) : 0;\n>>>> -\tmaxlen = strlen(committer) + msglen + 100;\n>>>> +\tmaxlen = strlen(committer) + msglen + 200;\n>>>>    \tlogrec = xmalloc(maxlen);\n>>>>    \tlen = xsnprintf(logrec, maxlen, \"%s %s %s\\n\",\n>>>>    \t\t\toid_to_hex(old_oid),\n>>>\n>>> nit: 100 is not enough anymore, but wasn't a very descriptive\n>>> value. 200 may be enough now, but I'm not sure why.\n> \n> 200 is definitely enough.  Suppose we had a message consisting entirely\n> of SHA-1 hashes (5, at 20 bytes a piece).  If our new hash is 32 bytes\n> long, then it would require at most 160 bytes.\n> \n> I only noticed this because the old code segfaulted.  My approach to\n> using a 32-byte hash was to set it up, do some basic tests, find out\n> what crashed, and fix it.  Most of this series is the basics necessary\n> to get the most rudimentary functionality out of a 32-byte Git,\n> excluding the index pieces, which are necessarily inelegant.\n> \n> I didn't include them because there are other ways to implement the\n> changes which are more elegant in some ways and less elegant in other\n> ways, and I want to think more about it before I send them in.\n> \n>> As Brandon alludes to downthread, we probably should use strbuf for\n>> things like this these days, so a preliminary clean-up to do so is\n>> probably a welcome change to sneak in and rebase this series on top\n>> of.\n> \n> Sure, I agree that would be a better change, and I'm happy to reroll\n> with that.\n> \n\nI've put together a patch to update log_ref_write_fd() to use strbuf and \nwill submit it shortly.\n"},{"id":"352191","messageId":"20180711014346.GA888464@genre.crustytoothpaste.net","threadId":"48842","inReplyTo":"02c0682a-8cc9-be49-b646-00cbdb5783f3@gmail.com","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-11T01:43:46Z","receivedAt":"2018-07-11T01:43:59Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Tue, Jul 10, 2018 at 02:08:28PM -0400, Ben Peart wrote:\n> \n> \n> On 7/9/2018 7:39 PM, brian m. carlson wrote:\n> > On Mon, Jul 09, 2018 at 10:45:33AM -0700, Junio C Hamano wrote:\n> > > As Brandon alludes to downthread, we probably should use strbuf for\n> > > things like this these days, so a preliminary clean-up to do so is\n> > > probably a welcome change to sneak in and rebase this series on top\n> > > of.\n> > \n> > Sure, I agree that would be a better change, and I'm happy to reroll\n> > with that.\n> > \n> \n> I've put together a patch to update log_ref_write_fd() to use strbuf and\n> will submit it shortly.\n\nExcellent.  I'll drop this patch in that case.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"352257","messageId":"xmqqva9l4wer.fsf@gitster-ct.c.googlers.com","threadId":"48842","inReplyTo":"20180711014346.GA888464@genre.crustytoothpaste.net","subject":"Re: [PATCH 07/17] commit: increase commit message buffer size","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-11T15:36:12Z","receivedAt":"2018-07-11T15:36:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> On Tue, Jul 10, 2018 at 02:08:28PM -0400, Ben Peart wrote:\n>> \n>> \n>> On 7/9/2018 7:39 PM, brian m. carlson wrote:\n>> > On Mon, Jul 09, 2018 at 10:45:33AM -0700, Junio C Hamano wrote:\n>> > > As Brandon alludes to downthread, we probably should use strbuf for\n>> > > things like this these days, so a preliminary clean-up to do so is\n>> > > probably a welcome change to sneak in and rebase this series on top\n>> > > of.\n>> > \n>> > Sure, I agree that would be a better change, and I'm happy to reroll\n>> > with that.\n>> > \n>> \n>> I've put together a patch to update log_ref_write_fd() to use strbuf and\n>> will submit it shortly.\n>\n> Excellent.  I'll drop this patch in that case.\n\nOK, thanks for working well together.  In the integration run I did\nyesterday evening, this part was resolved by taking what Ben did,\ndropping the s/100/200/ change from this series, and the result\nlooked reasonable, of course.\n"},{"id":"352576","messageId":"CAMy9T_HuO1a1_R+avedw-dmV4uWjOU9f0Hkrfo=gk8HTXcA7AQ@mail.gmail.com","threadId":"48842","inReplyTo":"1438bdfd-cb13-8da4-2dd2-16362b242ff3@gmail.com","subject":"Re: [PATCH 00/17] object_id part 14","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2018-07-14T23:38:54Z","receivedAt":"2018-07-14T23:39:11Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On Mon, Jul 9, 2018 at 6:15 AM Derrick Stolee <stolee@gmail.com> wrote:\n> On 7/8/2018 11:12 PM, Jacob Keller wrote:\n> > On Sun, Jul 8, 2018 at 4:39 PM brian m. carlson\n> > <sandals@crustytoothpaste.net> wrote:\n> >> This is the fourteenth series of patches to switch to using struct\n> >> object_id and the_hash_algo.  This series converts several core pieces\n> >> to use struct object_id, including the oid* and hex functions.\n> >>\n> >> All of these patches have been tested with both SHA-1 and a 256-bit\n> >> hash.\n> >>\n> > I read through the series, and didn't spot anything odd, except for\n> > the question about reasoning for why we use memcmp directly over using\n> > hashcmp. I don't think that's any sort of blocker, it just seemed an\n> > odd decision to me.\n>\n> I also read through the series and only found the 100/200 constants\n> confusing. Not worth blocking on, but I'm CC'ing Michael Haggerty to\n> comment if he knows how the magic 100 was computed.\n\nThe magic 100 blames back to our chief magician, Junio:\n\n    8ac65937d0 Make sure we do not write bogus reflog entries. (2007-01-26)\n\nSince then, as far as I can tell, it's just been copy-pasted forward.\nIt would be easy to compute it precisely based on the length of the\ntwo OIDs, represented as hex strings, plus the few extra characters in\nthe format string.\n\nMichael\n"},{"id":"352679","messageId":"xmqqmuuqsxf2.fsf@gitster-ct.c.googlers.com","threadId":"48842","inReplyTo":"CAMy9T_HuO1a1_R+avedw-dmV4uWjOU9f0Hkrfo=gk8HTXcA7AQ@mail.gmail.com","subject":"Re: [PATCH 00/17] object_id part 14","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-07-16T21:06:25Z","receivedAt":"2018-07-16T21:06:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> The magic 100 blames back to our chief magician, Junio:\n>\n>     8ac65937d0 Make sure we do not write bogus reflog entries. (2007-01-26)\n\nYup, guilty as charged.\n\ncf. <xmqqva9oe20y.fsf@gitster-ct.c.googlers.com>\n\n    \"%s %s %s\\n\" with old and new commit object name and the message\n    will be \"2 * len(hash_in_hex) + 4\" bytes long (counting the three\n    whitespaces and the terminating NUL), and Shawn's original in\n    6de08ae6 (\"Log ref updates to logs/refs/<ref>\", 2006-05-17) actually\n    computed this one as \"strlen(...) + 2*40+4\".\n\n    100 was merely me being sloppier than Shawn at 8ac65937 (\"Make sure\n    we do not write bogus reflog entries.\", 2007-01-26), preferring\n    being sufficient over not wasting even a single byte.\n"}]}