{"thread":{"id":"46073","subject":"[PATCH 00/33] object id conversion (grep and diff)","startedAt":"2017-05-30T17:31:21Z","lastAt":"2017-07-17T17:49:34Z","messageCount":66,"participants":["Brandon Williams","Stefan Beller","Jeff King","brian m. carlson","Junio C Hamano","René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":33},"messages":[{"id":"321035","messageId":"20170530173109.54904-1-bmwill@google.com","threadId":"46073","inReplyTo":null,"subject":"[PATCH 00/33] object id conversion (grep and diff)","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:36Z","receivedAt":"2017-05-30T17:31:21Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"A month or so ago I thought I would lend a hand to Brian and do a round of\nconversions from sha1 -> struct object_id.  Now that Brian's latest series has\nhit master I can finally send these patches out.\n\nThe first couple patches are from Brian which convert some of the notes logic\nto using 'struct object_id'.  The remaining patches are to convert the grep and\ndiff machinery to using 'struct object_id'.\n\nBrandon Williams (26):\n  grep: convert to struct object_id\n  diff: convert get_stat_data to struct object_id\n  diff: convert diff_index_show_file to struct object_id\n  diff: convert diff_addremove to struct object_id\n  diff: convert run_diff_files to struct object_id\n  diff: convert diff_change to struct object_id\n  diff: convert fill_filespec to struct object_id\n  diff: convert reuse_worktree_file to struct object_id\n  diff: finish conversion for prepare_temp_file to struct object_id\n  patch-ids: convert to struct object_id\n  diff: convert diff_flush_patch_id to struct object_id\n  combine-diff: convert diff_tree_combined to struct object_id\n  combine-diff: convert find_paths_* to struct object_id\n  tree-diff: convert diff_root_tree_sha1 to struct object_id\n  notes-merge: convert notes_merge* to struct object_id\n  notes-merge: convert merge_from_diffs to struct object_id\n  notes-merge: convert find_notes_merge_pair_ps to struct object_id\n  notes-merge: convert verify_notes_filepair to struct object_id\n  notes-merge: convert write_note_to_worktree to struct object_id\n  diff-tree: convert diff_tree_sha1 to struct object_id\n  builtin/diff-tree: cleanup references to sha1\n  tree-diff: convert try_to_follow_renames to struct object_id\n  tree-diff: convert diff_tree_paths to struct object_id\n  tree-diff: convert path_appendnew to object_id\n  diffcore-rename: use is_empty_blob_oid\n  diff: rename diff_fill_sha1_info to diff_fill_oid_info\n\nbrian m. carlson (7):\n  notes: convert internal structures to struct object_id\n  notes: convert internal parts to struct object_id\n  notes: convert for_each_note to struct object_id\n  notes: make get_note return pointer to struct object_id\n  notes: convert format_display_notes to struct object_id\n  builtin/notes: convert to struct object_id\n  notes: convert some accessor functions to struct object_id\n\n builtin/am.c          |   2 +-\n builtin/blame.c       |  22 +++---\n builtin/commit.c      |   2 +-\n builtin/diff-tree.c   |  16 ++--\n builtin/diff.c        |   8 +-\n builtin/fast-export.c |   8 +-\n builtin/grep.c        |  22 +++---\n builtin/log.c         |   8 +-\n builtin/merge.c       |   2 +-\n builtin/notes.c       | 136 ++++++++++++++++-----------------\n cache.h               |   7 ++\n combine-diff.c        |  30 ++++----\n diff-lib.c            |  52 ++++++-------\n diff-no-index.c       |   2 +-\n diff.c                |  74 +++++++++---------\n diff.h                |  38 +++++-----\n diffcore-rename.c     |   6 +-\n diffcore.h            |   2 +-\n grep.c                |  19 +++--\n grep.h                |   2 +-\n line-log.c            |  10 +--\n log-tree.c            |  12 +--\n merge-recursive.c     |   2 +-\n notes-cache.c         |  10 +--\n notes-merge.c         | 165 +++++++++++++++++++++--------------------\n notes-merge.h         |  12 +--\n notes-utils.c         |   2 +-\n notes-utils.h         |   2 +-\n notes.c               | 202 ++++++++++++++++++++++++++------------------------\n notes.h               |  16 ++--\n patch-ids.c           |  26 +++----\n patch-ids.h           |   4 +-\n remote-testsvn.c      |  22 +++---\n revision.c            |  16 ++--\n sequencer.c           |   4 +-\n tree-diff.c           |  93 ++++++++++++-----------\n 36 files changed, 535 insertions(+), 521 deletions(-)\n\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321036","messageId":"20170530173109.54904-2-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 01/33] notes: convert internal structures to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:37Z","receivedAt":"2017-05-30T17:31:23Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"From: \"brian m. carlson\" <sandals@crustytoothpaste.net>\n\nConvert the internal structures using unsigned char [20] to take\nstruct object_id using the following semantic patch and the standard\nobject_id transforms:\n\n@@\nstruct leaf_node E1;\n@@\n- E1.key_sha1\n+ E1.key_oid.hash\n\n@@\nstruct leaf_node *E1;\n@@\n- E1->key_sha1\n+ E1->key_oid.hash\n\n@@\nstruct leaf_node E1;\n@@\n- E1.key_sha1\n+ E1.key_oid.hash\n\n@@\nstruct leaf_node *E1;\n@@\n- E1->key_sha1\n+ E1->key_oid.hash\n\n@@\nstruct non_note E1;\n@@\n- E1.sha1\n+ E1.oid.hash\n\n@@\nstruct non_note *E1;\n@@\n- E1->sha1\n+ E1->oid.hash\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n notes.c | 98 ++++++++++++++++++++++++++++++++++-------------------------------\n 1 file changed, 51 insertions(+), 47 deletions(-)\n\ndiff --git a/notes.c b/notes.c\nindex 542563b28..251cf11c9 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -35,8 +35,8 @@ struct int_node {\n  * subtree.\n  */\n struct leaf_node {\n-\tunsigned char key_sha1[20];\n-\tunsigned char val_sha1[20];\n+\tstruct object_id key_oid;\n+\tstruct object_id val_oid;\n };\n \n /*\n@@ -51,7 +51,7 @@ struct non_note {\n \tstruct non_note *next; /* grounded (last->next == NULL) */\n \tchar *path;\n \tunsigned int mode;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n };\n \n #define PTR_TYPE_NULL     0\n@@ -100,7 +100,7 @@ static void **note_tree_search(struct notes_tree *t, struct int_node **tree,\n \n \tif (GET_PTR_TYPE(p) == PTR_TYPE_SUBTREE) {\n \t\tl = (struct leaf_node *) CLR_PTR_TYPE(p);\n-\t\tif (!SUBTREE_SHA1_PREFIXCMP(key_sha1, l->key_sha1)) {\n+\t\tif (!SUBTREE_SHA1_PREFIXCMP(key_sha1, l->key_oid.hash)) {\n \t\t\t/* unpack tree and resume search */\n \t\t\t(*tree)->a[0] = NULL;\n \t\t\tload_subtree(t, l, *tree, *n);\n@@ -118,7 +118,7 @@ static void **note_tree_search(struct notes_tree *t, struct int_node **tree,\n \t\treturn note_tree_search(t, tree, n, key_sha1);\n \tcase PTR_TYPE_SUBTREE:\n \t\tl = (struct leaf_node *) CLR_PTR_TYPE(p);\n-\t\tif (!SUBTREE_SHA1_PREFIXCMP(key_sha1, l->key_sha1)) {\n+\t\tif (!SUBTREE_SHA1_PREFIXCMP(key_sha1, l->key_oid.hash)) {\n \t\t\t/* unpack tree and resume search */\n \t\t\t(*tree)->a[i] = NULL;\n \t\t\tload_subtree(t, l, *tree, *n);\n@@ -143,7 +143,7 @@ static struct leaf_node *note_tree_find(struct notes_tree *t,\n \tvoid **p = note_tree_search(t, &tree, &n, key_sha1);\n \tif (GET_PTR_TYPE(*p) == PTR_TYPE_NOTE) {\n \t\tstruct leaf_node *l = (struct leaf_node *) CLR_PTR_TYPE(*p);\n-\t\tif (!hashcmp(key_sha1, l->key_sha1))\n+\t\tif (!hashcmp(key_sha1, l->key_oid.hash))\n \t\t\treturn l;\n \t}\n \treturn NULL;\n@@ -196,17 +196,17 @@ static void note_tree_remove(struct notes_tree *t,\n \tstruct leaf_node *l;\n \tstruct int_node *parent_stack[20];\n \tunsigned char i, j;\n-\tvoid **p = note_tree_search(t, &tree, &n, entry->key_sha1);\n+\tvoid **p = note_tree_search(t, &tree, &n, entry->key_oid.hash);\n \n \tassert(GET_PTR_TYPE(entry) == 0); /* no type bits set */\n \tif (GET_PTR_TYPE(*p) != PTR_TYPE_NOTE)\n \t\treturn; /* type mismatch, nothing to remove */\n \tl = (struct leaf_node *) CLR_PTR_TYPE(*p);\n-\tif (hashcmp(l->key_sha1, entry->key_sha1))\n+\tif (oidcmp(&l->key_oid, &entry->key_oid))\n \t\treturn; /* key mismatch, nothing to remove */\n \n \t/* we have found a matching entry */\n-\thashcpy(entry->val_sha1, l->val_sha1);\n+\toidcpy(&entry->val_oid, &l->val_oid);\n \tfree(l);\n \t*p = SET_PTR_TYPE(NULL, PTR_TYPE_NULL);\n \n@@ -216,14 +216,14 @@ static void note_tree_remove(struct notes_tree *t,\n \t/* first, build stack of ancestors between root and current node */\n \tparent_stack[0] = t->root;\n \tfor (i = 0; i < n; i++) {\n-\t\tj = GET_NIBBLE(i, entry->key_sha1);\n+\t\tj = GET_NIBBLE(i, entry->key_oid.hash);\n \t\tparent_stack[i + 1] = CLR_PTR_TYPE(parent_stack[i]->a[j]);\n \t}\n \tassert(i == n && parent_stack[i] == tree);\n \t/* next, unwind stack until note_tree_consolidate() is done */\n \twhile (i > 0 &&\n \t       !note_tree_consolidate(parent_stack[i], parent_stack[i - 1],\n-\t\t\t\t      GET_NIBBLE(i - 1, entry->key_sha1)))\n+\t\t\t\t      GET_NIBBLE(i - 1, entry->key_oid.hash)))\n \t\ti--;\n }\n \n@@ -246,7 +246,7 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,\n {\n \tstruct int_node *new_node;\n \tstruct leaf_node *l;\n-\tvoid **p = note_tree_search(t, &tree, &n, entry->key_sha1);\n+\tvoid **p = note_tree_search(t, &tree, &n, entry->key_oid.hash);\n \tint ret = 0;\n \n \tassert(GET_PTR_TYPE(entry) == 0); /* no type bits set */\n@@ -254,7 +254,7 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,\n \tswitch (GET_PTR_TYPE(*p)) {\n \tcase PTR_TYPE_NULL:\n \t\tassert(!*p);\n-\t\tif (is_null_sha1(entry->val_sha1))\n+\t\tif (is_null_oid(&entry->val_oid))\n \t\t\tfree(entry);\n \t\telse\n \t\t\t*p = SET_PTR_TYPE(entry, type);\n@@ -262,22 +262,22 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,\n \tcase PTR_TYPE_NOTE:\n \t\tswitch (type) {\n \t\tcase PTR_TYPE_NOTE:\n-\t\t\tif (!hashcmp(l->key_sha1, entry->key_sha1)) {\n+\t\t\tif (!oidcmp(&l->key_oid, &entry->key_oid)) {\n \t\t\t\t/* skip concatenation if l == entry */\n-\t\t\t\tif (!hashcmp(l->val_sha1, entry->val_sha1))\n+\t\t\t\tif (!oidcmp(&l->val_oid, &entry->val_oid))\n \t\t\t\t\treturn 0;\n \n-\t\t\t\tret = combine_notes(l->val_sha1,\n-\t\t\t\t\t\t    entry->val_sha1);\n-\t\t\t\tif (!ret && is_null_sha1(l->val_sha1))\n+\t\t\t\tret = combine_notes(l->val_oid.hash,\n+\t\t\t\t\t\t    entry->val_oid.hash);\n+\t\t\t\tif (!ret && is_null_oid(&l->val_oid))\n \t\t\t\t\tnote_tree_remove(t, tree, n, entry);\n \t\t\t\tfree(entry);\n \t\t\t\treturn ret;\n \t\t\t}\n \t\t\tbreak;\n \t\tcase PTR_TYPE_SUBTREE:\n-\t\t\tif (!SUBTREE_SHA1_PREFIXCMP(l->key_sha1,\n-\t\t\t\t\t\t    entry->key_sha1)) {\n+\t\t\tif (!SUBTREE_SHA1_PREFIXCMP(l->key_oid.hash,\n+\t\t\t\t\t\t    entry->key_oid.hash)) {\n \t\t\t\t/* unpack 'entry' */\n \t\t\t\tload_subtree(t, entry, tree, n);\n \t\t\t\tfree(entry);\n@@ -287,7 +287,7 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,\n \t\t}\n \t\tbreak;\n \tcase PTR_TYPE_SUBTREE:\n-\t\tif (!SUBTREE_SHA1_PREFIXCMP(entry->key_sha1, l->key_sha1)) {\n+\t\tif (!SUBTREE_SHA1_PREFIXCMP(entry->key_oid.hash, l->key_oid.hash)) {\n \t\t\t/* unpack 'l' and restart insert */\n \t\t\t*p = NULL;\n \t\t\tload_subtree(t, l, tree, n);\n@@ -301,7 +301,7 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,\n \t/* non-matching leaf_node */\n \tassert(GET_PTR_TYPE(*p) == PTR_TYPE_NOTE ||\n \t       GET_PTR_TYPE(*p) == PTR_TYPE_SUBTREE);\n-\tif (is_null_sha1(entry->val_sha1)) { /* skip insertion of empty note */\n+\tif (is_null_oid(&entry->val_oid)) { /* skip insertion of empty note */\n \t\tfree(entry);\n \t\treturn 0;\n \t}\n@@ -373,7 +373,7 @@ static void add_non_note(struct notes_tree *t, char *path,\n \tn->next = NULL;\n \tn->path = path;\n \tn->mode = mode;\n-\thashcpy(n->sha1, sha1);\n+\thashcpy(n->oid.hash, sha1);\n \tt->prev_non_note = n;\n \n \tif (!t->first_non_note) {\n@@ -399,7 +399,7 @@ static void add_non_note(struct notes_tree *t, char *path,\n \tif (non_note_cmp(p, n) == 0) { /* n ~= p; overwrite p with n */\n \t\tassert(strcmp(p->path, n->path) == 0);\n \t\tp->mode = n->mode;\n-\t\thashcpy(p->sha1, n->sha1);\n+\t\toidcpy(&p->oid, &n->oid);\n \t\tfree(n);\n \t\tt->prev_non_note = p;\n \t\treturn;\n@@ -422,14 +422,14 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,\n \tunsigned char type;\n \tstruct leaf_node *l;\n \n-\tbuf = fill_tree_descriptor(&desc, subtree->val_sha1);\n+\tbuf = fill_tree_descriptor(&desc, subtree->val_oid.hash);\n \tif (!buf)\n \t\tdie(\"Could not read %s for notes-index\",\n-\t\t     sha1_to_hex(subtree->val_sha1));\n+\t\t     oid_to_hex(&subtree->val_oid));\n \n-\tprefix_len = subtree->key_sha1[19];\n+\tprefix_len = subtree->key_oid.hash[19];\n \tassert(prefix_len * 2 >= n);\n-\tmemcpy(object_sha1, subtree->key_sha1, prefix_len);\n+\tmemcpy(object_sha1, subtree->key_oid.hash, prefix_len);\n \twhile (tree_entry(&desc, &entry)) {\n \t\tpath_len = strlen(entry.path);\n \t\tlen = get_sha1_hex_segment(entry.path, path_len,\n@@ -447,12 +447,12 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,\n \t\t\ttype = PTR_TYPE_NOTE;\n \t\t\tl = (struct leaf_node *)\n \t\t\t\txcalloc(1, sizeof(struct leaf_node));\n-\t\t\thashcpy(l->key_sha1, object_sha1);\n-\t\t\thashcpy(l->val_sha1, entry.oid->hash);\n+\t\t\thashcpy(l->key_oid.hash, object_sha1);\n+\t\t\toidcpy(&l->val_oid, entry.oid);\n \t\t\tif (len < 20) {\n \t\t\t\tif (!S_ISDIR(entry.mode) || path_len != 2)\n \t\t\t\t\tgoto handle_non_note; /* not subtree */\n-\t\t\t\tl->key_sha1[19] = (unsigned char) len;\n+\t\t\t\tl->key_oid.hash[19] = (unsigned char) len;\n \t\t\t\ttype = PTR_TYPE_SUBTREE;\n \t\t\t}\n \t\t\tif (note_tree_insert(t, node, n, l, type,\n@@ -460,7 +460,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,\n \t\t\t\tdie(\"Failed to load %s %s into notes tree \"\n \t\t\t\t    \"from %s\",\n \t\t\t\t    type == PTR_TYPE_NOTE ? \"note\" : \"subtree\",\n-\t\t\t\t    sha1_to_hex(l->key_sha1), t->ref);\n+\t\t\t\t    oid_to_hex(&l->key_oid), t->ref);\n \t\t}\n \t\tcontinue;\n \n@@ -486,7 +486,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,\n \t\t */\n \t\t{\n \t\t\tstruct strbuf non_note_path = STRBUF_INIT;\n-\t\t\tconst char *q = sha1_to_hex(subtree->key_sha1);\n+\t\t\tconst char *q = oid_to_hex(&subtree->key_oid);\n \t\t\tint i;\n \t\t\tfor (i = 0; i < prefix_len; i++) {\n \t\t\t\tstrbuf_addch(&non_note_path, *q++);\n@@ -599,15 +599,17 @@ static int for_each_note_helper(struct notes_tree *t, struct int_node *tree,\n \t\t\t    flags & FOR_EACH_NOTE_YIELD_SUBTREES) {\n \t\t\t\t/* invoke callback with subtree */\n \t\t\t\tunsigned int path_len =\n-\t\t\t\t\tl->key_sha1[19] * 2 + fanout;\n+\t\t\t\t\tl->key_oid.hash[19] * 2 + fanout;\n \t\t\t\tassert(path_len < FANOUT_PATH_MAX - 1);\n-\t\t\t\tconstruct_path_with_fanout(l->key_sha1, fanout,\n+\t\t\t\tconstruct_path_with_fanout(l->key_oid.hash,\n+\t\t\t\t\t\t\t   fanout,\n \t\t\t\t\t\t\t   path);\n \t\t\t\t/* Create trailing slash, if needed */\n \t\t\t\tif (path[path_len - 1] != '/')\n \t\t\t\t\tpath[path_len++] = '/';\n \t\t\t\tpath[path_len] = '\\0';\n-\t\t\t\tret = fn(l->key_sha1, l->val_sha1, path,\n+\t\t\t\tret = fn(l->key_oid.hash, l->val_oid.hash,\n+\t\t\t\t\t path,\n \t\t\t\t\t cb_data);\n \t\t\t}\n \t\t\tif (n > fanout * 2 ||\n@@ -621,8 +623,10 @@ static int for_each_note_helper(struct notes_tree *t, struct int_node *tree,\n \t\t\tbreak;\n \t\tcase PTR_TYPE_NOTE:\n \t\t\tl = (struct leaf_node *) CLR_PTR_TYPE(p);\n-\t\t\tconstruct_path_with_fanout(l->key_sha1, fanout, path);\n-\t\t\tret = fn(l->key_sha1, l->val_sha1, path, cb_data);\n+\t\t\tconstruct_path_with_fanout(l->key_oid.hash, fanout,\n+\t\t\t\t\t\t   path);\n+\t\t\tret = fn(l->key_oid.hash, l->val_oid.hash, path,\n+\t\t\t\t cb_data);\n \t\t\tbreak;\n \t\t}\n \t\tif (ret)\n@@ -742,7 +746,7 @@ static int write_each_non_note_until(const char *note_path,\n \t\t\t; /* do nothing, prefer note to non-note */\n \t\telse {\n \t\t\tret = write_each_note_helper(d->root, n->path, n->mode,\n-\t\t\t\t\t\t     n->sha1);\n+\t\t\t\t\t\t     n->oid.hash);\n \t\t\tif (ret)\n \t\t\t\treturn ret;\n \t\t}\n@@ -1027,8 +1031,8 @@ void init_notes(struct notes_tree *t, const char *notes_ref,\n \t\tdie(\"Failed to read notes tree referenced by %s (%s)\",\n \t\t    notes_ref, oid_to_hex(&object_oid));\n \n-\thashclr(root_tree.key_sha1);\n-\thashcpy(root_tree.val_sha1, oid.hash);\n+\toidclr(&root_tree.key_oid);\n+\toidcpy(&root_tree.val_oid, &oid);\n \tload_subtree(t, &root_tree, t->root, 0);\n }\n \n@@ -1092,8 +1096,8 @@ int add_note(struct notes_tree *t, const unsigned char *object_sha1,\n \tif (!combine_notes)\n \t\tcombine_notes = t->combine_notes;\n \tl = (struct leaf_node *) xmalloc(sizeof(struct leaf_node));\n-\thashcpy(l->key_sha1, object_sha1);\n-\thashcpy(l->val_sha1, note_sha1);\n+\thashcpy(l->key_oid.hash, object_sha1);\n+\thashcpy(l->val_oid.hash, note_sha1);\n \treturn note_tree_insert(t, t->root, 0, l, PTR_TYPE_NOTE, combine_notes);\n }\n \n@@ -1104,10 +1108,10 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1)\n \tif (!t)\n \t\tt = &default_notes_tree;\n \tassert(t->initialized);\n-\thashcpy(l.key_sha1, object_sha1);\n-\thashclr(l.val_sha1);\n+\thashcpy(l.key_oid.hash, object_sha1);\n+\toidclr(&l.val_oid);\n \tnote_tree_remove(t, t->root, 0, &l);\n-\tif (is_null_sha1(l.val_sha1)) /* no note was removed */\n+\tif (is_null_oid(&l.val_oid)) /* no note was removed */\n \t\treturn 1;\n \tt->dirty = 1;\n \treturn 0;\n@@ -1122,7 +1126,7 @@ const unsigned char *get_note(struct notes_tree *t,\n \t\tt = &default_notes_tree;\n \tassert(t->initialized);\n \tfound = note_tree_find(t, t->root, 0, object_sha1);\n-\treturn found ? found->val_sha1 : NULL;\n+\treturn found ? found->val_oid.hash : NULL;\n }\n \n int for_each_note(struct notes_tree *t, int flags, each_note_fn fn,\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321037","messageId":"20170530173109.54904-4-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 03/33] notes: convert for_each_note to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:39Z","receivedAt":"2017-05-30T17:31:26Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"From: \"brian m. carlson\" <sandals@crustytoothpaste.net>\n\nConvert for_each_note and each of the callbacks to use struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/notes.c  |  6 +++---\n notes.c          | 24 ++++++++++++------------\n notes.h          |  4 ++--\n remote-testsvn.c |  8 ++++----\n 4 files changed, 21 insertions(+), 21 deletions(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex f2847c41e..53fe6d34d 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -109,11 +109,11 @@ static void free_note_data(struct note_data *d)\n \tstrbuf_release(&d->buf);\n }\n \n-static int list_each_note(const unsigned char *object_sha1,\n-\t\tconst unsigned char *note_sha1, char *note_path,\n+static int list_each_note(const struct object_id *object_oid,\n+\t\tconst struct object_id *note_oid, char *note_path,\n \t\tvoid *cb_data)\n {\n-\tprintf(\"%s %s\\n\", sha1_to_hex(note_sha1), sha1_to_hex(object_sha1));\n+\tprintf(\"%s %s\\n\", oid_to_hex(note_oid), oid_to_hex(object_oid));\n \treturn 0;\n }\n \ndiff --git a/notes.c b/notes.c\nindex babe0c0eb..e881c10ee 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -610,7 +610,7 @@ static int for_each_note_helper(struct notes_tree *t, struct int_node *tree,\n \t\t\t\tif (path[path_len - 1] != '/')\n \t\t\t\t\tpath[path_len++] = '/';\n \t\t\t\tpath[path_len] = '\\0';\n-\t\t\t\tret = fn(l->key_oid.hash, l->val_oid.hash,\n+\t\t\t\tret = fn(&l->key_oid, &l->val_oid,\n \t\t\t\t\t path,\n \t\t\t\t\t cb_data);\n \t\t\t}\n@@ -627,7 +627,7 @@ static int for_each_note_helper(struct notes_tree *t, struct int_node *tree,\n \t\t\tl = (struct leaf_node *) CLR_PTR_TYPE(p);\n \t\t\tconstruct_path_with_fanout(l->key_oid.hash, fanout,\n \t\t\t\t\t\t   path);\n-\t\t\tret = fn(l->key_oid.hash, l->val_oid.hash, path,\n+\t\t\tret = fn(&l->key_oid, &l->val_oid, path,\n \t\t\t\t cb_data);\n \t\t\tbreak;\n \t\t}\n@@ -698,7 +698,7 @@ static int tree_write_stack_finish_subtree(struct tree_write_stack *tws)\n \n static int write_each_note_helper(struct tree_write_stack *tws,\n \t\tconst char *path, unsigned int mode,\n-\t\tconst unsigned char *sha1)\n+\t\tconst struct object_id *oid)\n {\n \tsize_t path_len = strlen(path);\n \tunsigned int n = 0;\n@@ -728,7 +728,7 @@ static int write_each_note_helper(struct tree_write_stack *tws,\n \n \t/* Finally add given entry to the current tree object */\n \twrite_tree_entry(&tws->buf, mode, path + 3 * n, path_len - (3 * n),\n-\t\t\t sha1);\n+\t\t\t oid->hash);\n \n \treturn 0;\n }\n@@ -748,7 +748,7 @@ static int write_each_non_note_until(const char *note_path,\n \t\t\t; /* do nothing, prefer note to non-note */\n \t\telse {\n \t\t\tret = write_each_note_helper(d->root, n->path, n->mode,\n-\t\t\t\t\t\t     n->oid.hash);\n+\t\t\t\t\t\t     &n->oid);\n \t\t\tif (ret)\n \t\t\t\treturn ret;\n \t\t}\n@@ -758,8 +758,8 @@ static int write_each_non_note_until(const char *note_path,\n \treturn 0;\n }\n \n-static int write_each_note(const unsigned char *object_sha1,\n-\t\tconst unsigned char *note_sha1, char *note_path,\n+static int write_each_note(const struct object_id *object_oid,\n+\t\tconst struct object_id *note_oid, char *note_path,\n \t\tvoid *cb_data)\n {\n \tstruct write_each_note_data *d =\n@@ -777,7 +777,7 @@ static int write_each_note(const unsigned char *object_sha1,\n \n \t/* Weave non-note entries into note entries */\n \treturn  write_each_non_note_until(note_path, d) ||\n-\t\twrite_each_note_helper(d->root, note_path, mode, note_sha1);\n+\t\twrite_each_note_helper(d->root, note_path, mode, note_oid);\n }\n \n struct note_delete_list {\n@@ -785,20 +785,20 @@ struct note_delete_list {\n \tconst unsigned char *sha1;\n };\n \n-static int prune_notes_helper(const unsigned char *object_sha1,\n-\t\tconst unsigned char *note_sha1, char *note_path,\n+static int prune_notes_helper(const struct object_id *object_oid,\n+\t\tconst struct object_id *note_oid, char *note_path,\n \t\tvoid *cb_data)\n {\n \tstruct note_delete_list **l = (struct note_delete_list **) cb_data;\n \tstruct note_delete_list *n;\n \n-\tif (has_sha1_file(object_sha1))\n+\tif (has_object_file(object_oid))\n \t\treturn 0; /* nothing to do for this note */\n \n \t/* failed to find object => prune this note */\n \tn = (struct note_delete_list *) xmalloc(sizeof(*n));\n \tn->next = *l;\n-\tn->sha1 = object_sha1;\n+\tn->sha1 = object_oid->hash;\n \t*l = n;\n \treturn 0;\n }\ndiff --git a/notes.h b/notes.h\nindex 5345642cf..6651673ae 100644\n--- a/notes.h\n+++ b/notes.h\n@@ -202,8 +202,8 @@ int copy_note(struct notes_tree *t,\n  * - copy_note()\n  * - free_notes()\n  */\n-typedef int each_note_fn(const unsigned char *object_sha1,\n-\t\tconst unsigned char *note_sha1, char *note_path,\n+typedef int each_note_fn(const struct object_id *object_oid,\n+\t\tconst struct object_id *note_oid, char *note_path,\n \t\tvoid *cb_data);\n int for_each_note(struct notes_tree *t, int flags, each_note_fn fn,\n \t\tvoid *cb_data);\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex f87bf851b..793c4ad1d 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -99,8 +99,8 @@ static int parse_rev_note(const char *msg, struct rev_note *res)\n \treturn -1;\n }\n \n-static int note2mark_cb(const unsigned char *object_sha1,\n-\t\tconst unsigned char *note_sha1, char *note_path,\n+static int note2mark_cb(const struct object_id *object_oid,\n+\t\tconst struct object_id *note_oid, char *note_path,\n \t\tvoid *cb_data)\n {\n \tFILE *file = (FILE *)cb_data;\n@@ -109,14 +109,14 @@ static int note2mark_cb(const unsigned char *object_sha1,\n \tenum object_type type;\n \tstruct rev_note note;\n \n-\tif (!(msg = read_sha1_file(note_sha1, &type, &msglen)) ||\n+\tif (!(msg = read_sha1_file(note_oid->hash, &type, &msglen)) ||\n \t\t\t!msglen || type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn 1;\n \t}\n \tif (parse_rev_note(msg, &note))\n \t\treturn 2;\n-\tif (fprintf(file, \":%d %s\\n\", note.rev_nr, sha1_to_hex(object_sha1)) < 1)\n+\tif (fprintf(file, \":%d %s\\n\", note.rev_nr, oid_to_hex(object_oid)) < 1)\n \t\treturn 3;\n \treturn 0;\n }\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321038","messageId":"20170530173109.54904-6-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 05/33] notes: convert format_display_notes to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:41Z","receivedAt":"2017-05-30T17:31:28Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"From: \"brian m. carlson\" <sandals@crustytoothpaste.net>\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n log-tree.c | 2 +-\n notes.c    | 8 ++++----\n notes.h    | 2 +-\n revision.c | 2 +-\n 4 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex a4ec11c2b..9c0c64a2d 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -655,7 +655,7 @@ void show_log(struct rev_info *opt)\n \t\tstruct strbuf notebuf = STRBUF_INIT;\n \n \t\traw = (opt->commit_format == CMIT_FMT_USERFORMAT);\n-\t\tformat_display_notes(commit->object.oid.hash, &notebuf,\n+\t\tformat_display_notes(&commit->object.oid, &notebuf,\n \t\t\t\t     get_log_output_encoding(), raw);\n \t\tctx.notes_message = notebuf.len\n \t\t\t? strbuf_detach(&notebuf, NULL)\ndiff --git a/notes.c b/notes.c\nindex fe4db2c1e..b5cabafde 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1215,7 +1215,7 @@ void free_notes(struct notes_tree *t)\n  * (raw != 0) gives the %N userformat; otherwise, the note message is given\n  * for human consumption.\n  */\n-static void format_note(struct notes_tree *t, const unsigned char *object_sha1,\n+static void format_note(struct notes_tree *t, const struct object_id *object_oid,\n \t\t\tstruct strbuf *sb, const char *output_encoding, int raw)\n {\n \tstatic const char utf8[] = \"utf-8\";\n@@ -1229,7 +1229,7 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,\n \tif (!t->initialized)\n \t\tinit_notes(t, NULL, NULL, 0);\n \n-\toid = get_note(t, object_sha1);\n+\toid = get_note(t, object_oid->hash);\n \tif (!oid)\n \t\treturn;\n \n@@ -1277,13 +1277,13 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,\n \tfree(msg);\n }\n \n-void format_display_notes(const unsigned char *object_sha1,\n+void format_display_notes(const struct object_id *object_oid,\n \t\t\t  struct strbuf *sb, const char *output_encoding, int raw)\n {\n \tint i;\n \tassert(display_notes_trees);\n \tfor (i = 0; display_notes_trees[i]; i++)\n-\t\tformat_note(display_notes_trees[i], object_sha1, sb,\n+\t\tformat_note(display_notes_trees[i], object_oid, sb,\n \t\t\t    output_encoding, raw);\n }\n \ndiff --git a/notes.h b/notes.h\nindex c72bb9710..a66532103 100644\n--- a/notes.h\n+++ b/notes.h\n@@ -277,7 +277,7 @@ void init_display_notes(struct display_notes_opt *opt);\n  *\n  * You *must* call init_display_notes() before using this function.\n  */\n-void format_display_notes(const unsigned char *object_sha1,\n+void format_display_notes(const struct object_id *object_oid,\n \t\t\t  struct strbuf *sb, const char *output_encoding, int raw);\n \n /*\ndiff --git a/revision.c b/revision.c\nindex b02394530..475d5b2dc 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -2908,7 +2908,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)\n \tif (opt->show_notes) {\n \t\tif (!buf.len)\n \t\t\tstrbuf_addstr(&buf, message);\n-\t\tformat_display_notes(commit->object.oid.hash, &buf, encoding, 1);\n+\t\tformat_display_notes(&commit->object.oid, &buf, encoding, 1);\n \t}\n \n \t/*\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321039","messageId":"20170530173109.54904-7-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 06/33] builtin/notes: convert to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:42Z","receivedAt":"2017-05-30T17:31:31Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"From: \"brian m. carlson\" <sandals@crustytoothpaste.net>\n\nConvert most of the static functions to use struct object_id.  In\naddition, convert copy_notes_for_rewrite and its callers.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/am.c     |   2 +-\n builtin/commit.c |   2 +-\n builtin/notes.c  | 110 +++++++++++++++++++++++++++----------------------------\n notes-utils.c    |   4 +-\n notes-utils.h    |   2 +-\n 5 files changed, 60 insertions(+), 60 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 0f63dcab1..d9fdddac4 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -563,7 +563,7 @@ static int copy_notes_for_rebase(const struct am_state *state)\n \t\t\tgoto finish;\n \t\t}\n \n-\t\tif (copy_note_for_rewrite(c, from_obj.hash, to_obj.hash))\n+\t\tif (copy_note_for_rewrite(c, &from_obj, &to_obj))\n \t\t\tret = error(_(\"Failed to copy notes from '%s' to '%s'\"),\n \t\t\t\t\toid_to_hex(&from_obj), oid_to_hex(&to_obj));\n \t}\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex da1ba4c86..758781004 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1809,7 +1809,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t\tcfg = init_copy_notes_for_rewrite(\"amend\");\n \t\tif (cfg) {\n \t\t\t/* we are amending, so current_head is not NULL */\n-\t\t\tcopy_note_for_rewrite(cfg, current_head->object.oid.hash, oid.hash);\n+\t\t\tcopy_note_for_rewrite(cfg, &current_head->object.oid, &oid);\n \t\t\tfinish_copy_notes_for_rewrite(cfg, \"Notes added by 'git commit --amend'\");\n \t\t}\n \t\trun_rewrite_hook(&current_head->object.oid, &oid);\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 3d9005b8f..7947a16ed 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -129,10 +129,10 @@ static void copy_obj_to_fd(int fd, const unsigned char *sha1)\n \t}\n }\n \n-static void write_commented_object(int fd, const unsigned char *object)\n+static void write_commented_object(int fd, const struct object_id *object)\n {\n \tconst char *show_args[5] =\n-\t\t{\"show\", \"--stat\", \"--no-notes\", sha1_to_hex(object), NULL};\n+\t\t{\"show\", \"--stat\", \"--no-notes\", oid_to_hex(object), NULL};\n \tstruct child_process show = CHILD_PROCESS_INIT;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct strbuf cbuf = STRBUF_INIT;\n@@ -145,7 +145,7 @@ static void write_commented_object(int fd, const unsigned char *object)\n \tshow.git_cmd = 1;\n \tif (start_command(&show))\n \t\tdie(_(\"unable to start 'show' for object '%s'\"),\n-\t\t    sha1_to_hex(object));\n+\t\t    oid_to_hex(object));\n \n \tif (strbuf_read(&buf, show.out, 0) < 0)\n \t\tdie_errno(_(\"could not read 'show' output\"));\n@@ -157,10 +157,10 @@ static void write_commented_object(int fd, const unsigned char *object)\n \n \tif (finish_command(&show))\n \t\tdie(_(\"failed to finish 'show' for object '%s'\"),\n-\t\t    sha1_to_hex(object));\n+\t\t    oid_to_hex(object));\n }\n \n-static void prepare_note_data(const unsigned char *object, struct note_data *d,\n+static void prepare_note_data(const struct object_id *object, struct note_data *d,\n \t\tconst unsigned char *old_note)\n {\n \tif (d->use_editor || !d->given) {\n@@ -243,16 +243,16 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n {\n \tstruct note_data *d = opt->value;\n \tchar *buf;\n-\tunsigned char object[20];\n+\tstruct object_id object;\n \tenum object_type type;\n \tunsigned long len;\n \n \tif (d->buf.len)\n \t\tstrbuf_addch(&d->buf, '\\n');\n \n-\tif (get_sha1(arg, object))\n+\tif (get_oid(arg, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), arg);\n-\tif (!(buf = read_sha1_file(object, &type, &len))) {\n+\tif (!(buf = read_sha1_file(object.hash, &type, &len))) {\n \t\tfree(buf);\n \t\tdie(_(\"failed to read object '%s'.\"), arg);\n \t}\n@@ -292,7 +292,7 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n \t}\n \n \twhile (strbuf_getline_lf(&buf, stdin) != EOF) {\n-\t\tunsigned char from_obj[20], to_obj[20];\n+\t\tstruct object_id from_obj, to_obj;\n \t\tstruct strbuf **split;\n \t\tint err;\n \n@@ -301,15 +301,15 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n \t\t\tdie(_(\"malformed input line: '%s'.\"), buf.buf);\n \t\tstrbuf_rtrim(split[0]);\n \t\tstrbuf_rtrim(split[1]);\n-\t\tif (get_sha1(split[0]->buf, from_obj))\n+\t\tif (get_oid(split[0]->buf, &from_obj))\n \t\t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), split[0]->buf);\n-\t\tif (get_sha1(split[1]->buf, to_obj))\n+\t\tif (get_oid(split[1]->buf, &to_obj))\n \t\t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), split[1]->buf);\n \n \t\tif (rewrite_cmd)\n-\t\t\terr = copy_note_for_rewrite(c, from_obj, to_obj);\n+\t\t\terr = copy_note_for_rewrite(c, &from_obj, &to_obj);\n \t\telse\n-\t\t\terr = copy_note(t, from_obj, to_obj, force,\n+\t\t\terr = copy_note(t, from_obj.hash, to_obj.hash, force,\n \t\t\t\t\tcombine_notes_overwrite);\n \n \t\tif (err) {\n@@ -350,7 +350,7 @@ static struct notes_tree *init_notes_check(const char *subcommand,\n static int list(int argc, const char **argv, const char *prefix)\n {\n \tstruct notes_tree *t;\n-\tunsigned char object[20];\n+\tstruct object_id object;\n \tconst struct object_id *note;\n \tint retval = -1;\n \tstruct option options[] = {\n@@ -368,15 +368,15 @@ static int list(int argc, const char **argv, const char *prefix)\n \n \tt = init_notes_check(\"list\", 0);\n \tif (argc) {\n-\t\tif (get_sha1(argv[0], object))\n+\t\tif (get_oid(argv[0], &object))\n \t\t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), argv[0]);\n-\t\tnote = get_note(t, object);\n+\t\tnote = get_note(t, object.hash);\n \t\tif (note) {\n \t\t\tputs(oid_to_hex(note));\n \t\t\tretval = 0;\n \t\t} else\n \t\t\tretval = error(_(\"no note found for object %s.\"),\n-\t\t\t\t       sha1_to_hex(object));\n+\t\t\t\t       oid_to_hex(&object));\n \t} else\n \t\tretval = for_each_note(t, 0, list_each_note, NULL);\n \n@@ -391,7 +391,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \tint force = 0, allow_empty = 0;\n \tconst char *object_ref;\n \tstruct notes_tree *t;\n-\tunsigned char object[20], new_note[20];\n+\tstruct object_id object, new_note;\n \tconst struct object_id *note;\n \tstruct note_data d = { 0, 0, NULL, STRBUF_INIT };\n \tstruct option options[] = {\n@@ -423,11 +423,11 @@ static int add(int argc, const char **argv, const char *prefix)\n \n \tobject_ref = argc > 1 ? argv[1] : \"HEAD\";\n \n-\tif (get_sha1(object_ref, object))\n+\tif (get_oid(object_ref, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tt = init_notes_check(\"add\", NOTES_INIT_WRITABLE);\n-\tnote = get_note(t, object);\n+\tnote = get_note(t, object.hash);\n \n \tif (note) {\n \t\tif (!force) {\n@@ -437,7 +437,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\t\treturn error(_(\"Cannot add notes. \"\n \t\t\t\t\t\"Found existing notes for object %s. \"\n \t\t\t\t\t\"Use '-f' to overwrite existing notes\"),\n-\t\t\t\t\tsha1_to_hex(object));\n+\t\t\t\t\toid_to_hex(&object));\n \t\t\t}\n \t\t\t/*\n \t\t\t * Redirect to \"edit\" subcommand.\n@@ -450,19 +450,19 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\treturn append_edit(argc, argv, prefix);\n \t\t}\n \t\tfprintf(stderr, _(\"Overwriting existing notes for object %s\\n\"),\n-\t\t\tsha1_to_hex(object));\n+\t\t\toid_to_hex(&object));\n \t}\n \n-\tprepare_note_data(object, &d, note->hash);\n+\tprepare_note_data(&object, &d, note->hash);\n \tif (d.buf.len || allow_empty) {\n-\t\twrite_note_data(&d, new_note);\n-\t\tif (add_note(t, object, new_note, combine_notes_overwrite))\n+\t\twrite_note_data(&d, new_note.hash);\n+\t\tif (add_note(t, object.hash, new_note.hash, combine_notes_overwrite))\n \t\t\tdie(\"BUG: combine_notes_overwrite failed\");\n \t\tcommit_notes(t, \"Notes added by 'git notes add'\");\n \t} else {\n \t\tfprintf(stderr, _(\"Removing note for object %s\\n\"),\n-\t\t\tsha1_to_hex(object));\n-\t\tremove_note(t, object);\n+\t\t\toid_to_hex(&object));\n+\t\tremove_note(t, object.hash);\n \t\tcommit_notes(t, \"Notes removed by 'git notes add'\");\n \t}\n \n@@ -476,7 +476,7 @@ static int copy(int argc, const char **argv, const char *prefix)\n \tint retval = 0, force = 0, from_stdin = 0;\n \tconst struct object_id *from_note, *note;\n \tconst char *object_ref;\n-\tunsigned char object[20], from_obj[20];\n+\tstruct object_id object, from_obj;\n \tstruct notes_tree *t;\n \tconst char *rewrite_cmd = NULL;\n \tstruct option options[] = {\n@@ -509,37 +509,37 @@ static int copy(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(git_notes_copy_usage, options);\n \t}\n \n-\tif (get_sha1(argv[0], from_obj))\n+\tif (get_oid(argv[0], &from_obj))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), argv[0]);\n \n \tobject_ref = 1 < argc ? argv[1] : \"HEAD\";\n \n-\tif (get_sha1(object_ref, object))\n+\tif (get_oid(object_ref, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tt = init_notes_check(\"copy\", NOTES_INIT_WRITABLE);\n-\tnote = get_note(t, object);\n+\tnote = get_note(t, object.hash);\n \n \tif (note) {\n \t\tif (!force) {\n \t\t\tretval = error(_(\"Cannot copy notes. Found existing \"\n \t\t\t\t       \"notes for object %s. Use '-f' to \"\n \t\t\t\t       \"overwrite existing notes\"),\n-\t\t\t\t       sha1_to_hex(object));\n+\t\t\t\t       oid_to_hex(&object));\n \t\t\tgoto out;\n \t\t}\n \t\tfprintf(stderr, _(\"Overwriting existing notes for object %s\\n\"),\n-\t\t\tsha1_to_hex(object));\n+\t\t\toid_to_hex(&object));\n \t}\n \n-\tfrom_note = get_note(t, from_obj);\n+\tfrom_note = get_note(t, from_obj.hash);\n \tif (!from_note) {\n \t\tretval = error(_(\"missing notes on source object %s. Cannot \"\n-\t\t\t       \"copy.\"), sha1_to_hex(from_obj));\n+\t\t\t       \"copy.\"), oid_to_hex(&from_obj));\n \t\tgoto out;\n \t}\n \n-\tif (add_note(t, object, from_note->hash, combine_notes_overwrite))\n+\tif (add_note(t, object.hash, from_note->hash, combine_notes_overwrite))\n \t\tdie(\"BUG: combine_notes_overwrite failed\");\n \tcommit_notes(t, \"Notes added by 'git notes copy'\");\n out:\n@@ -552,7 +552,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \tint allow_empty = 0;\n \tconst char *object_ref;\n \tstruct notes_tree *t;\n-\tunsigned char object[20], new_note[20];\n+\tstruct object_id object, new_note;\n \tconst struct object_id *note;\n \tchar *logmsg;\n \tconst char * const *usage;\n@@ -592,13 +592,13 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \n \tobject_ref = 1 < argc ? argv[1] : \"HEAD\";\n \n-\tif (get_sha1(object_ref, object))\n+\tif (get_oid(object_ref, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tt = init_notes_check(argv[0], NOTES_INIT_WRITABLE);\n-\tnote = get_note(t, object);\n+\tnote = get_note(t, object.hash);\n \n-\tprepare_note_data(object, &d, edit && note ? note->hash : NULL);\n+\tprepare_note_data(&object, &d, edit && note ? note->hash : NULL);\n \n \tif (note && !edit) {\n \t\t/* Append buf to previous note contents */\n@@ -615,14 +615,14 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (d.buf.len || allow_empty) {\n-\t\twrite_note_data(&d, new_note);\n-\t\tif (add_note(t, object, new_note, combine_notes_overwrite))\n+\t\twrite_note_data(&d, new_note.hash);\n+\t\tif (add_note(t, object.hash, new_note.hash, combine_notes_overwrite))\n \t\t\tdie(\"BUG: combine_notes_overwrite failed\");\n \t\tlogmsg = xstrfmt(\"Notes added by 'git notes %s'\", argv[0]);\n \t} else {\n \t\tfprintf(stderr, _(\"Removing note for object %s\\n\"),\n-\t\t\tsha1_to_hex(object));\n-\t\tremove_note(t, object);\n+\t\t\toid_to_hex(&object));\n+\t\tremove_note(t, object.hash);\n \t\tlogmsg = xstrfmt(\"Notes removed by 'git notes %s'\", argv[0]);\n \t}\n \tcommit_notes(t, logmsg);\n@@ -637,7 +637,7 @@ static int show(int argc, const char **argv, const char *prefix)\n {\n \tconst char *object_ref;\n \tstruct notes_tree *t;\n-\tunsigned char object[20];\n+\tstruct object_id object;\n \tconst struct object_id *note;\n \tint retval;\n \tstruct option options[] = {\n@@ -654,15 +654,15 @@ static int show(int argc, const char **argv, const char *prefix)\n \n \tobject_ref = argc ? argv[0] : \"HEAD\";\n \n-\tif (get_sha1(object_ref, object))\n+\tif (get_oid(object_ref, &object))\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tt = init_notes_check(\"show\", 0);\n-\tnote = get_note(t, object);\n+\tnote = get_note(t, object.hash);\n \n \tif (!note)\n \t\tretval = error(_(\"no note found for object %s.\"),\n-\t\t\t       sha1_to_hex(object));\n+\t\t\t       oid_to_hex(&object));\n \telse {\n \t\tconst char *show_args[3] = {\"show\", oid_to_hex(note), NULL};\n \t\tretval = execv_git_cmd(show_args);\n@@ -760,7 +760,7 @@ static int git_config_get_notes_strategy(const char *key,\n static int merge(int argc, const char **argv, const char *prefix)\n {\n \tstruct strbuf remote_ref = STRBUF_INIT, msg = STRBUF_INIT;\n-\tunsigned char result_sha1[20];\n+\tstruct object_id result_oid;\n \tstruct notes_tree *t;\n \tstruct notes_merge_options o;\n \tint do_merge = 0, do_commit = 0, do_abort = 0;\n@@ -842,16 +842,16 @@ static int merge(int argc, const char **argv, const char *prefix)\n \t\t    remote_ref.buf, default_notes_ref());\n \tstrbuf_add(&(o.commit_msg), msg.buf + 7, msg.len - 7); /* skip \"notes: \" */\n \n-\tresult = notes_merge(&o, t, result_sha1);\n+\tresult = notes_merge(&o, t, result_oid.hash);\n \n \tif (result >= 0) /* Merge resulted (trivially) in result_sha1 */\n \t\t/* Update default notes ref with new commit */\n-\t\tupdate_ref(msg.buf, default_notes_ref(), result_sha1, NULL,\n+\t\tupdate_ref(msg.buf, default_notes_ref(), result_oid.hash, NULL,\n \t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n \telse { /* Merge has unresolved conflicts */\n \t\tconst struct worktree *wt;\n \t\t/* Update .git/NOTES_MERGE_PARTIAL with partial merge result */\n-\t\tupdate_ref(msg.buf, \"NOTES_MERGE_PARTIAL\", result_sha1, NULL,\n+\t\tupdate_ref(msg.buf, \"NOTES_MERGE_PARTIAL\", result_oid.hash, NULL,\n \t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\n \t\t/* Store ref-to-be-updated into .git/NOTES_MERGE_REF */\n \t\twt = find_shared_symref(\"NOTES_MERGE_REF\", default_notes_ref());\n@@ -878,10 +878,10 @@ static int merge(int argc, const char **argv, const char *prefix)\n static int remove_one_note(struct notes_tree *t, const char *name, unsigned flag)\n {\n \tint status;\n-\tunsigned char sha1[20];\n-\tif (get_sha1(name, sha1))\n+\tstruct object_id oid;\n+\tif (get_oid(name, &oid))\n \t\treturn error(_(\"Failed to resolve '%s' as a valid ref.\"), name);\n-\tstatus = remove_note(t, sha1);\n+\tstatus = remove_note(t, oid.hash);\n \tif (status)\n \t\tfprintf(stderr, _(\"Object %s has no note\\n\"), name);\n \telse\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 325ff3daa..7d7c22b43 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -155,12 +155,12 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)\n }\n \n int copy_note_for_rewrite(struct notes_rewrite_cfg *c,\n-\t\t\t  const unsigned char *from_obj, const unsigned char *to_obj)\n+\t\t\t  const struct object_id *from_obj, const struct object_id *to_obj)\n {\n \tint ret = 0;\n \tint i;\n \tfor (i = 0; c->trees[i]; i++)\n-\t\tret = copy_note(c->trees[i], from_obj, to_obj, 1, c->combine) || ret;\n+\t\tret = copy_note(c->trees[i], from_obj->hash, to_obj->hash, 1, c->combine) || ret;\n \treturn ret;\n }\n \ndiff --git a/notes-utils.h b/notes-utils.h\nindex fa538e1d9..119057839 100644\n--- a/notes-utils.h\n+++ b/notes-utils.h\n@@ -40,7 +40,7 @@ struct notes_rewrite_cfg {\n int parse_notes_merge_strategy(const char *v, enum notes_merge_strategy *s);\n struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd);\n int copy_note_for_rewrite(struct notes_rewrite_cfg *c,\n-\t\t\t  const unsigned char *from_obj, const unsigned char *to_obj);\n+\t\t\t  const struct object_id *from_obj, const struct object_id *to_obj);\n void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c, const char *msg);\n \n #endif\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321040","messageId":"20170530173109.54904-3-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 02/33] notes: convert internal parts to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:38Z","receivedAt":"2017-05-30T17:31:34Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"From: \"brian m. carlson\" <sandals@crustytoothpaste.net>\n\nConvert several portions of the internals of the code to struct\nobject_id.  Introduce two macros to denote the different constants in\nthe code: KEY_INDEX for the last byte of the object ID, and\nFANOUT_PATH_SEPARATORS for the number of possible path separators (on\nUnix, \"/\").  While these constants are both 19 (one less than the number\nof bytes in the hash), distinguish them to make the code more\nunderstandable, and define them logically based on their intended\npurpose.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n notes.c | 64 +++++++++++++++++++++++++++++++++-------------------------------\n 1 file changed, 33 insertions(+), 31 deletions(-)\n\ndiff --git a/notes.c b/notes.c\nindex 251cf11c9..babe0c0eb 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -65,8 +65,10 @@ struct non_note {\n \n #define GET_NIBBLE(n, sha1) (((sha1[(n) >> 1]) >> ((~(n) & 0x01) << 2)) & 0x0f)\n \n+#define KEY_INDEX (GIT_SHA1_RAWSZ - 1)\n+#define FANOUT_PATH_SEPARATORS ((GIT_SHA1_HEXSZ / 2) - 1)\n #define SUBTREE_SHA1_PREFIXCMP(key_sha1, subtree_sha1) \\\n-\t(memcmp(key_sha1, subtree_sha1, subtree_sha1[19]))\n+\t(memcmp(key_sha1, subtree_sha1, subtree_sha1[KEY_INDEX]))\n \n struct notes_tree default_notes_tree;\n \n@@ -194,7 +196,7 @@ static void note_tree_remove(struct notes_tree *t,\n \t\tstruct leaf_node *entry)\n {\n \tstruct leaf_node *l;\n-\tstruct int_node *parent_stack[20];\n+\tstruct int_node *parent_stack[GIT_SHA1_RAWSZ];\n \tunsigned char i, j;\n \tvoid **p = note_tree_search(t, &tree, &n, entry->key_oid.hash);\n \n@@ -341,21 +343,21 @@ static void note_tree_free(struct int_node *tree)\n  * Otherwise, returns number of bytes written to sha1 (i.e. hex_len / 2).\n  * Pads sha1 with NULs up to sha1_len (not included in returned length).\n  */\n-static int get_sha1_hex_segment(const char *hex, unsigned int hex_len,\n-\t\tunsigned char *sha1, unsigned int sha1_len)\n+static int get_oid_hex_segment(const char *hex, unsigned int hex_len,\n+\t\tunsigned char *oid, unsigned int oid_len)\n {\n \tunsigned int i, len = hex_len >> 1;\n-\tif (hex_len % 2 != 0 || len > sha1_len)\n+\tif (hex_len % 2 != 0 || len > oid_len)\n \t\treturn -1;\n \tfor (i = 0; i < len; i++) {\n \t\tunsigned int val = (hexval(hex[0]) << 4) | hexval(hex[1]);\n \t\tif (val & ~0xff)\n \t\t\treturn -1;\n-\t\t*sha1++ = val;\n+\t\t*oid++ = val;\n \t\thex += 2;\n \t}\n-\tfor (; i < sha1_len; i++)\n-\t\t*sha1++ = 0;\n+\tfor (; i < oid_len; i++)\n+\t\t*oid++ = 0;\n \treturn len;\n }\n \n@@ -413,7 +415,7 @@ static void add_non_note(struct notes_tree *t, char *path,\n static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,\n \t\tstruct int_node *node, unsigned int n)\n {\n-\tunsigned char object_sha1[20];\n+\tstruct object_id object_oid;\n \tunsigned int prefix_len;\n \tvoid *buf;\n \tstruct tree_desc desc;\n@@ -427,13 +429,13 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,\n \t\tdie(\"Could not read %s for notes-index\",\n \t\t     oid_to_hex(&subtree->val_oid));\n \n-\tprefix_len = subtree->key_oid.hash[19];\n+\tprefix_len = subtree->key_oid.hash[KEY_INDEX];\n \tassert(prefix_len * 2 >= n);\n-\tmemcpy(object_sha1, subtree->key_oid.hash, prefix_len);\n+\tmemcpy(object_oid.hash, subtree->key_oid.hash, prefix_len);\n \twhile (tree_entry(&desc, &entry)) {\n \t\tpath_len = strlen(entry.path);\n-\t\tlen = get_sha1_hex_segment(entry.path, path_len,\n-\t\t\t\tobject_sha1 + prefix_len, 20 - prefix_len);\n+\t\tlen = get_oid_hex_segment(entry.path, path_len,\n+\t\t\t\tobject_oid.hash + prefix_len, GIT_SHA1_RAWSZ - prefix_len);\n \t\tif (len < 0)\n \t\t\tgoto handle_non_note; /* entry.path is not a SHA1 */\n \t\tlen += prefix_len;\n@@ -443,16 +445,16 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,\n \t\t * If object SHA1 is incomplete (len < 20), and current\n \t\t * component consists of 2 hex chars, assume note subtree\n \t\t */\n-\t\tif (len <= 20) {\n+\t\tif (len <= GIT_SHA1_RAWSZ) {\n \t\t\ttype = PTR_TYPE_NOTE;\n \t\t\tl = (struct leaf_node *)\n \t\t\t\txcalloc(1, sizeof(struct leaf_node));\n-\t\t\thashcpy(l->key_oid.hash, object_sha1);\n+\t\t\toidcpy(&l->key_oid, &object_oid);\n \t\t\toidcpy(&l->val_oid, entry.oid);\n-\t\t\tif (len < 20) {\n+\t\t\tif (len < GIT_SHA1_RAWSZ) {\n \t\t\t\tif (!S_ISDIR(entry.mode) || path_len != 2)\n \t\t\t\t\tgoto handle_non_note; /* not subtree */\n-\t\t\t\tl->key_oid.hash[19] = (unsigned char) len;\n+\t\t\t\tl->key_oid.hash[KEY_INDEX] = (unsigned char) len;\n \t\t\t\ttype = PTR_TYPE_SUBTREE;\n \t\t\t}\n \t\t\tif (note_tree_insert(t, node, n, l, type,\n@@ -542,14 +544,14 @@ static unsigned char determine_fanout(struct int_node *tree, unsigned char n,\n }\n \n /* hex SHA1 + 19 * '/' + NUL */\n-#define FANOUT_PATH_MAX 40 + 19 + 1\n+#define FANOUT_PATH_MAX GIT_SHA1_HEXSZ + FANOUT_PATH_SEPARATORS + 1\n \n static void construct_path_with_fanout(const unsigned char *sha1,\n \t\tunsigned char fanout, char *path)\n {\n \tunsigned int i = 0, j = 0;\n \tconst char *hex_sha1 = sha1_to_hex(sha1);\n-\tassert(fanout < 20);\n+\tassert(fanout < GIT_SHA1_RAWSZ);\n \twhile (fanout) {\n \t\tpath[i++] = hex_sha1[j++];\n \t\tpath[i++] = hex_sha1[j++];\n@@ -599,7 +601,7 @@ static int for_each_note_helper(struct notes_tree *t, struct int_node *tree,\n \t\t\t    flags & FOR_EACH_NOTE_YIELD_SUBTREES) {\n \t\t\t\t/* invoke callback with subtree */\n \t\t\t\tunsigned int path_len =\n-\t\t\t\t\tl->key_oid.hash[19] * 2 + fanout;\n+\t\t\t\t\tl->key_oid.hash[KEY_INDEX] * 2 + fanout;\n \t\t\t\tassert(path_len < FANOUT_PATH_MAX - 1);\n \t\t\t\tconstruct_path_with_fanout(l->key_oid.hash,\n \t\t\t\t\t\t\t   fanout,\n@@ -654,7 +656,7 @@ static void write_tree_entry(struct strbuf *buf, unsigned int mode,\n \t\tunsigned char *sha1)\n {\n \tstrbuf_addf(buf, \"%o %.*s%c\", mode, path_len, path, '\\0');\n-\tstrbuf_add(buf, sha1, 20);\n+\tstrbuf_add(buf, sha1, GIT_SHA1_RAWSZ);\n }\n \n static void tree_write_stack_init_subtree(struct tree_write_stack *tws,\n@@ -666,7 +668,7 @@ static void tree_write_stack_init_subtree(struct tree_write_stack *tws,\n \tn = (struct tree_write_stack *)\n \t\txmalloc(sizeof(struct tree_write_stack));\n \tn->next = NULL;\n-\tstrbuf_init(&n->buf, 256 * (32 + 40)); /* assume 256 entries per tree */\n+\tstrbuf_init(&n->buf, 256 * (32 + GIT_SHA1_HEXSZ)); /* assume 256 entries per tree */\n \tn->path[0] = n->path[1] = '\\0';\n \ttws->next = n;\n \ttws->path[0] = path[0];\n@@ -677,18 +679,18 @@ static int tree_write_stack_finish_subtree(struct tree_write_stack *tws)\n {\n \tint ret;\n \tstruct tree_write_stack *n = tws->next;\n-\tunsigned char s[20];\n+\tstruct object_id s;\n \tif (n) {\n \t\tret = tree_write_stack_finish_subtree(n);\n \t\tif (ret)\n \t\t\treturn ret;\n-\t\tret = write_sha1_file(n->buf.buf, n->buf.len, tree_type, s);\n+\t\tret = write_sha1_file(n->buf.buf, n->buf.len, tree_type, s.hash);\n \t\tif (ret)\n \t\t\treturn ret;\n \t\tstrbuf_release(&n->buf);\n \t\tfree(n);\n \t\ttws->next = NULL;\n-\t\twrite_tree_entry(&tws->buf, 040000, tws->path, 2, s);\n+\t\twrite_tree_entry(&tws->buf, 040000, tws->path, 2, s.hash);\n \t\ttws->path[0] = tws->path[1] = '\\0';\n \t}\n \treturn 0;\n@@ -771,7 +773,7 @@ static int write_each_note(const unsigned char *object_sha1,\n \t\tnote_path[note_path_len] = '\\0';\n \t\tmode = 040000;\n \t}\n-\tassert(note_path_len <= 40 + 19);\n+\tassert(note_path_len <= GIT_SHA1_HEXSZ + FANOUT_PATH_SEPARATORS);\n \n \t/* Weave non-note entries into note entries */\n \treturn  write_each_non_note_until(note_path, d) ||\n@@ -946,8 +948,8 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)\n \tif (has_glob_specials(glob)) {\n \t\tfor_each_glob_ref(string_list_add_one_ref, glob, list);\n \t} else {\n-\t\tunsigned char sha1[20];\n-\t\tif (get_sha1(glob, sha1))\n+\t\tstruct object_id oid;\n+\t\tif (get_oid(glob, &oid))\n \t\t\twarning(\"notes ref %s is invalid\", glob);\n \t\tif (!unsorted_string_list_has_string(list, glob))\n \t\t\tstring_list_append(list, glob);\n@@ -1150,7 +1152,7 @@ int write_notes_tree(struct notes_tree *t, unsigned char *result)\n \n \t/* Prepare for traversal of current notes tree */\n \troot.next = NULL; /* last forward entry in list is grounded */\n-\tstrbuf_init(&root.buf, 256 * (32 + 40)); /* assume 256 entries */\n+\tstrbuf_init(&root.buf, 256 * (32 + GIT_SHA1_HEXSZ)); /* assume 256 entries */\n \troot.path[0] = root.path[1] = '\\0';\n \tcb_data.root = &root;\n \tcb_data.next_non_note = t->first_non_note;\n@@ -1315,9 +1317,9 @@ void expand_notes_ref(struct strbuf *sb)\n \n void expand_loose_notes_ref(struct strbuf *sb)\n {\n-\tunsigned char object[20];\n+\tstruct object_id object;\n \n-\tif (get_sha1(sb->buf, object)) {\n+\tif (get_oid(sb->buf, &object)) {\n \t\t/* fallback to expand_notes_ref */\n \t\texpand_notes_ref(sb);\n \t}\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321041","messageId":"20170530173109.54904-5-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 04/33] notes: make get_note return pointer to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:40Z","receivedAt":"2017-05-30T17:31:36Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"From: \"brian m. carlson\" <sandals@crustytoothpaste.net>\n\nMake get_note return a pointer to a const struct object_id.  Add a\ndefensive check to ensure we don't accidentally dereference a NULL\npointer.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/notes.c  | 22 +++++++++++-----------\n notes-cache.c    |  8 ++++----\n notes.c          | 18 +++++++++---------\n notes.h          |  2 +-\n remote-testsvn.c |  6 +++---\n 5 files changed, 28 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 53fe6d34d..3d9005b8f 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -351,7 +351,7 @@ static int list(int argc, const char **argv, const char *prefix)\n {\n \tstruct notes_tree *t;\n \tunsigned char object[20];\n-\tconst unsigned char *note;\n+\tconst struct object_id *note;\n \tint retval = -1;\n \tstruct option options[] = {\n \t\tOPT_END()\n@@ -372,7 +372,7 @@ static int list(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), argv[0]);\n \t\tnote = get_note(t, object);\n \t\tif (note) {\n-\t\t\tputs(sha1_to_hex(note));\n+\t\t\tputs(oid_to_hex(note));\n \t\t\tretval = 0;\n \t\t} else\n \t\t\tretval = error(_(\"no note found for object %s.\"),\n@@ -392,7 +392,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \tconst char *object_ref;\n \tstruct notes_tree *t;\n \tunsigned char object[20], new_note[20];\n-\tconst unsigned char *note;\n+\tconst struct object_id *note;\n \tstruct note_data d = { 0, 0, NULL, STRBUF_INIT };\n \tstruct option options[] = {\n \t\t{ OPTION_CALLBACK, 'm', \"message\", &d, N_(\"message\"),\n@@ -453,7 +453,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\tsha1_to_hex(object));\n \t}\n \n-\tprepare_note_data(object, &d, note);\n+\tprepare_note_data(object, &d, note->hash);\n \tif (d.buf.len || allow_empty) {\n \t\twrite_note_data(&d, new_note);\n \t\tif (add_note(t, object, new_note, combine_notes_overwrite))\n@@ -474,7 +474,7 @@ static int add(int argc, const char **argv, const char *prefix)\n static int copy(int argc, const char **argv, const char *prefix)\n {\n \tint retval = 0, force = 0, from_stdin = 0;\n-\tconst unsigned char *from_note, *note;\n+\tconst struct object_id *from_note, *note;\n \tconst char *object_ref;\n \tunsigned char object[20], from_obj[20];\n \tstruct notes_tree *t;\n@@ -539,7 +539,7 @@ static int copy(int argc, const char **argv, const char *prefix)\n \t\tgoto out;\n \t}\n \n-\tif (add_note(t, object, from_note, combine_notes_overwrite))\n+\tif (add_note(t, object, from_note->hash, combine_notes_overwrite))\n \t\tdie(\"BUG: combine_notes_overwrite failed\");\n \tcommit_notes(t, \"Notes added by 'git notes copy'\");\n out:\n@@ -553,7 +553,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \tconst char *object_ref;\n \tstruct notes_tree *t;\n \tunsigned char object[20], new_note[20];\n-\tconst unsigned char *note;\n+\tconst struct object_id *note;\n \tchar *logmsg;\n \tconst char * const *usage;\n \tstruct note_data d = { 0, 0, NULL, STRBUF_INIT };\n@@ -598,13 +598,13 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \tt = init_notes_check(argv[0], NOTES_INIT_WRITABLE);\n \tnote = get_note(t, object);\n \n-\tprepare_note_data(object, &d, edit ? note : NULL);\n+\tprepare_note_data(object, &d, edit && note ? note->hash : NULL);\n \n \tif (note && !edit) {\n \t\t/* Append buf to previous note contents */\n \t\tunsigned long size;\n \t\tenum object_type type;\n-\t\tchar *prev_buf = read_sha1_file(note, &type, &size);\n+\t\tchar *prev_buf = read_sha1_file(note->hash, &type, &size);\n \n \t\tstrbuf_grow(&d.buf, size + 1);\n \t\tif (d.buf.len && prev_buf && size)\n@@ -638,7 +638,7 @@ static int show(int argc, const char **argv, const char *prefix)\n \tconst char *object_ref;\n \tstruct notes_tree *t;\n \tunsigned char object[20];\n-\tconst unsigned char *note;\n+\tconst struct object_id *note;\n \tint retval;\n \tstruct option options[] = {\n \t\tOPT_END()\n@@ -664,7 +664,7 @@ static int show(int argc, const char **argv, const char *prefix)\n \t\tretval = error(_(\"no note found for object %s.\"),\n \t\t\t       sha1_to_hex(object));\n \telse {\n-\t\tconst char *show_args[3] = {\"show\", sha1_to_hex(note), NULL};\n+\t\tconst char *show_args[3] = {\"show\", oid_to_hex(note), NULL};\n \t\tretval = execv_git_cmd(show_args);\n \t}\n \tfree_notes(t);\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 2843e9857..6e84a748f 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -69,15 +69,15 @@ int notes_cache_write(struct notes_cache *c)\n char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \t\t      size_t *outsize)\n {\n-\tconst unsigned char *value_sha1;\n+\tconst struct object_id *value_oid;\n \tenum object_type type;\n \tchar *value;\n \tunsigned long size;\n \n-\tvalue_sha1 = get_note(&c->tree, key_oid->hash);\n-\tif (!value_sha1)\n+\tvalue_oid = get_note(&c->tree, key_oid->hash);\n+\tif (!value_oid)\n \t\treturn NULL;\n-\tvalue = read_sha1_file(value_sha1, &type, &size);\n+\tvalue = read_sha1_file(value_oid->hash, &type, &size);\n \n \t*outsize = size;\n \treturn value;\ndiff --git a/notes.c b/notes.c\nindex e881c10ee..fe4db2c1e 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1119,7 +1119,7 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1)\n \treturn 0;\n }\n \n-const unsigned char *get_note(struct notes_tree *t,\n+const struct object_id *get_note(struct notes_tree *t,\n \t\tconst unsigned char *object_sha1)\n {\n \tstruct leaf_node *found;\n@@ -1128,7 +1128,7 @@ const unsigned char *get_note(struct notes_tree *t,\n \t\tt = &default_notes_tree;\n \tassert(t->initialized);\n \tfound = note_tree_find(t, t->root, 0, object_sha1);\n-\treturn found ? found->val_oid.hash : NULL;\n+\treturn found ? &found->val_oid : NULL;\n }\n \n int for_each_note(struct notes_tree *t, int flags, each_note_fn fn,\n@@ -1219,7 +1219,7 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,\n \t\t\tstruct strbuf *sb, const char *output_encoding, int raw)\n {\n \tstatic const char utf8[] = \"utf-8\";\n-\tconst unsigned char *sha1;\n+\tconst struct object_id *oid;\n \tchar *msg, *msg_p;\n \tunsigned long linelen, msglen;\n \tenum object_type type;\n@@ -1229,11 +1229,11 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,\n \tif (!t->initialized)\n \t\tinit_notes(t, NULL, NULL, 0);\n \n-\tsha1 = get_note(t, object_sha1);\n-\tif (!sha1)\n+\toid = get_note(t, object_sha1);\n+\tif (!oid)\n \t\treturn;\n \n-\tif (!(msg = read_sha1_file(sha1, &type, &msglen)) || type != OBJ_BLOB) {\n+\tif (!(msg = read_sha1_file(oid->hash, &type, &msglen)) || type != OBJ_BLOB) {\n \t\tfree(msg);\n \t\treturn;\n \t}\n@@ -1291,14 +1291,14 @@ int copy_note(struct notes_tree *t,\n \t      const unsigned char *from_obj, const unsigned char *to_obj,\n \t      int force, combine_notes_fn combine_notes)\n {\n-\tconst unsigned char *note = get_note(t, from_obj);\n-\tconst unsigned char *existing_note = get_note(t, to_obj);\n+\tconst struct object_id *note = get_note(t, from_obj);\n+\tconst struct object_id *existing_note = get_note(t, to_obj);\n \n \tif (!force && existing_note)\n \t\treturn 1;\n \n \tif (note)\n-\t\treturn add_note(t, to_obj, note, combine_notes);\n+\t\treturn add_note(t, to_obj, note->hash, combine_notes);\n \telse if (existing_note)\n \t\treturn add_note(t, to_obj, null_sha1, combine_notes);\n \ndiff --git a/notes.h b/notes.h\nindex 6651673ae..c72bb9710 100644\n--- a/notes.h\n+++ b/notes.h\n@@ -140,7 +140,7 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1);\n  *\n  * Return NULL if the given object has no notes.\n  */\n-const unsigned char *get_note(struct notes_tree *t,\n+const struct object_id *get_note(struct notes_tree *t,\n \t\tconst unsigned char *object_sha1);\n \n /*\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 793c4ad1d..017af1bd5 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -53,15 +53,15 @@ static void terminate_batch(void)\n /* NOTE: 'ref' refers to a git reference, while 'rev' refers to a svn revision. */\n static char *read_ref_note(const unsigned char sha1[20])\n {\n-\tconst unsigned char *note_sha1;\n+\tconst struct object_id *note_oid;\n \tchar *msg = NULL;\n \tunsigned long msglen;\n \tenum object_type type;\n \n \tinit_notes(NULL, notes_ref, NULL, 0);\n-\tif (!(note_sha1 = get_note(NULL, sha1)))\n+\tif (!(note_oid = get_note(NULL, sha1)))\n \t\treturn NULL;\t/* note tree not found */\n-\tif (!(msg = read_sha1_file(note_sha1, &type, &msglen)))\n+\tif (!(msg = read_sha1_file(note_oid->hash, &type, &msglen)))\n \t\terror(\"Empty notes tree. %s\", notes_ref);\n \telse if (!msglen || type != OBJ_BLOB) {\n \t\terror(\"Note contains unusable content. \"\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321042","messageId":"20170530173109.54904-10-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 09/33] diff: convert get_stat_data to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:45Z","receivedAt":"2017-05-30T17:31:39Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n diff-lib.c | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 2982bf055..a3bc78162 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -264,12 +264,12 @@ static void diff_index_show_file(struct rev_info *revs,\n }\n \n static int get_stat_data(const struct cache_entry *ce,\n-\t\t\t const unsigned char **sha1p,\n+\t\t\t const struct object_id **oidp,\n \t\t\t unsigned int *modep,\n \t\t\t int cached, int match_missing,\n \t\t\t unsigned *dirty_submodule, struct diff_options *diffopt)\n {\n-\tconst unsigned char *sha1 = ce->oid.hash;\n+\tconst struct object_id *oid = &ce->oid;\n \tunsigned int mode = ce->ce_mode;\n \n \tif (!cached && !ce_uptodate(ce)) {\n@@ -280,7 +280,7 @@ static int get_stat_data(const struct cache_entry *ce,\n \t\t\treturn -1;\n \t\telse if (changed) {\n \t\t\tif (match_missing) {\n-\t\t\t\t*sha1p = sha1;\n+\t\t\t\t*oidp = oid;\n \t\t\t\t*modep = mode;\n \t\t\t\treturn 0;\n \t\t\t}\n@@ -290,11 +290,11 @@ static int get_stat_data(const struct cache_entry *ce,\n \t\t\t\t\t\t    0, dirty_submodule);\n \t\tif (changed) {\n \t\t\tmode = ce_mode_from_stat(ce, st.st_mode);\n-\t\t\tsha1 = null_sha1;\n+\t\t\toid = &null_oid;\n \t\t}\n \t}\n \n-\t*sha1p = sha1;\n+\t*oidp = oid;\n \t*modep = mode;\n \treturn 0;\n }\n@@ -303,7 +303,7 @@ static void show_new_file(struct rev_info *revs,\n \t\t\t  const struct cache_entry *new,\n \t\t\t  int cached, int match_missing)\n {\n-\tconst unsigned char *sha1;\n+\tconst struct object_id *oid;\n \tunsigned int mode;\n \tunsigned dirty_submodule = 0;\n \n@@ -311,11 +311,11 @@ static void show_new_file(struct rev_info *revs,\n \t * New file in the index: it might actually be different in\n \t * the working tree.\n \t */\n-\tif (get_stat_data(new, &sha1, &mode, cached, match_missing,\n+\tif (get_stat_data(new, &oid, &mode, cached, match_missing,\n \t    &dirty_submodule, &revs->diffopt) < 0)\n \t\treturn;\n \n-\tdiff_index_show_file(revs, \"+\", new, sha1, !is_null_sha1(sha1), mode, dirty_submodule);\n+\tdiff_index_show_file(revs, \"+\", new, oid->hash, !is_null_oid(oid), mode, dirty_submodule);\n }\n \n static int show_modified(struct rev_info *revs,\n@@ -325,10 +325,10 @@ static int show_modified(struct rev_info *revs,\n \t\t\t int cached, int match_missing)\n {\n \tunsigned int mode, oldmode;\n-\tconst unsigned char *sha1;\n+\tconst struct object_id *oid;\n \tunsigned dirty_submodule = 0;\n \n-\tif (get_stat_data(new, &sha1, &mode, cached, match_missing,\n+\tif (get_stat_data(new, &oid, &mode, cached, match_missing,\n \t\t\t  &dirty_submodule, &revs->diffopt) < 0) {\n \t\tif (report_missing)\n \t\t\tdiff_index_show_file(revs, \"-\", old,\n@@ -338,7 +338,7 @@ static int show_modified(struct rev_info *revs,\n \t}\n \n \tif (revs->combine_merges && !cached &&\n-\t    (hashcmp(sha1, old->oid.hash) || oidcmp(&old->oid, &new->oid))) {\n+\t    (oidcmp(oid, &old->oid) || oidcmp(&old->oid, &new->oid))) {\n \t\tstruct combine_diff_path *p;\n \t\tint pathlen = ce_namelen(new);\n \n@@ -362,12 +362,12 @@ static int show_modified(struct rev_info *revs,\n \t}\n \n \toldmode = old->ce_mode;\n-\tif (mode == oldmode && !hashcmp(sha1, old->oid.hash) && !dirty_submodule &&\n+\tif (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&\n \t    !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n \t\treturn 0;\n \n \tdiff_change(&revs->diffopt, oldmode, mode,\n-\t\t    old->oid.hash, sha1, 1, !is_null_sha1(sha1),\n+\t\t    old->oid.hash, oid->hash, 1, !is_null_oid(oid),\n \t\t    old->name, 0, dirty_submodule);\n \treturn 0;\n }\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321043","messageId":"20170530173109.54904-8-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 07/33] notes: convert some accessor functions to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:43Z","receivedAt":"2017-05-30T17:31:41Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"From: \"brian m. carlson\" <sandals@crustytoothpaste.net>\n\nConvert add_note, get_note, and copy_note to take struct object_id.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/notes.c  | 20 ++++++++++----------\n notes-cache.c    |  4 ++--\n notes-merge.c    | 18 +++++++++---------\n notes-utils.c    |  2 +-\n notes.c          | 20 ++++++++++----------\n notes.h          |  8 ++++----\n remote-testsvn.c | 10 +++++-----\n 7 files changed, 41 insertions(+), 41 deletions(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 7947a16ed..b13fc8789 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -309,7 +309,7 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n \t\tif (rewrite_cmd)\n \t\t\terr = copy_note_for_rewrite(c, &from_obj, &to_obj);\n \t\telse\n-\t\t\terr = copy_note(t, from_obj.hash, to_obj.hash, force,\n+\t\t\terr = copy_note(t, &from_obj, &to_obj, force,\n \t\t\t\t\tcombine_notes_overwrite);\n \n \t\tif (err) {\n@@ -370,7 +370,7 @@ static int list(int argc, const char **argv, const char *prefix)\n \tif (argc) {\n \t\tif (get_oid(argv[0], &object))\n \t\t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), argv[0]);\n-\t\tnote = get_note(t, object.hash);\n+\t\tnote = get_note(t, &object);\n \t\tif (note) {\n \t\t\tputs(oid_to_hex(note));\n \t\t\tretval = 0;\n@@ -427,7 +427,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tt = init_notes_check(\"add\", NOTES_INIT_WRITABLE);\n-\tnote = get_note(t, object.hash);\n+\tnote = get_note(t, &object);\n \n \tif (note) {\n \t\tif (!force) {\n@@ -456,7 +456,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \tprepare_note_data(&object, &d, note->hash);\n \tif (d.buf.len || allow_empty) {\n \t\twrite_note_data(&d, new_note.hash);\n-\t\tif (add_note(t, object.hash, new_note.hash, combine_notes_overwrite))\n+\t\tif (add_note(t, &object, &new_note, combine_notes_overwrite))\n \t\t\tdie(\"BUG: combine_notes_overwrite failed\");\n \t\tcommit_notes(t, \"Notes added by 'git notes add'\");\n \t} else {\n@@ -518,7 +518,7 @@ static int copy(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tt = init_notes_check(\"copy\", NOTES_INIT_WRITABLE);\n-\tnote = get_note(t, object.hash);\n+\tnote = get_note(t, &object);\n \n \tif (note) {\n \t\tif (!force) {\n@@ -532,14 +532,14 @@ static int copy(int argc, const char **argv, const char *prefix)\n \t\t\toid_to_hex(&object));\n \t}\n \n-\tfrom_note = get_note(t, from_obj.hash);\n+\tfrom_note = get_note(t, &from_obj);\n \tif (!from_note) {\n \t\tretval = error(_(\"missing notes on source object %s. Cannot \"\n \t\t\t       \"copy.\"), oid_to_hex(&from_obj));\n \t\tgoto out;\n \t}\n \n-\tif (add_note(t, object.hash, from_note->hash, combine_notes_overwrite))\n+\tif (add_note(t, &object, from_note, combine_notes_overwrite))\n \t\tdie(\"BUG: combine_notes_overwrite failed\");\n \tcommit_notes(t, \"Notes added by 'git notes copy'\");\n out:\n@@ -596,7 +596,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tt = init_notes_check(argv[0], NOTES_INIT_WRITABLE);\n-\tnote = get_note(t, object.hash);\n+\tnote = get_note(t, &object);\n \n \tprepare_note_data(&object, &d, edit && note ? note->hash : NULL);\n \n@@ -616,7 +616,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \n \tif (d.buf.len || allow_empty) {\n \t\twrite_note_data(&d, new_note.hash);\n-\t\tif (add_note(t, object.hash, new_note.hash, combine_notes_overwrite))\n+\t\tif (add_note(t, &object, &new_note, combine_notes_overwrite))\n \t\t\tdie(\"BUG: combine_notes_overwrite failed\");\n \t\tlogmsg = xstrfmt(\"Notes added by 'git notes %s'\", argv[0]);\n \t} else {\n@@ -658,7 +658,7 @@ static int show(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"failed to resolve '%s' as a valid ref.\"), object_ref);\n \n \tt = init_notes_check(\"show\", 0);\n-\tnote = get_note(t, object.hash);\n+\tnote = get_note(t, &object);\n \n \tif (!note)\n \t\tretval = error(_(\"no note found for object %s.\"),\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 6e84a748f..29b4cede5 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -74,7 +74,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tchar *value;\n \tunsigned long size;\n \n-\tvalue_oid = get_note(&c->tree, key_oid->hash);\n+\tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\n \t\treturn NULL;\n \tvalue = read_sha1_file(value_oid->hash, &type, &size);\n@@ -90,5 +90,5 @@ int notes_cache_put(struct notes_cache *c, struct object_id *key_oid,\n \n \tif (write_sha1_file(data, size, \"blob\", value_oid.hash) < 0)\n \t\treturn -1;\n-\treturn add_note(&c->tree, key_oid->hash, value_oid.hash, NULL);\n+\treturn add_note(&c->tree, key_oid, &value_oid, NULL);\n }\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 6244f6af9..9a1a49506 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -444,14 +444,14 @@ static int merge_one_change(struct notes_merge_options *o,\n \t\tif (o->verbosity >= 2)\n \t\t\tprintf(\"Using remote notes for %s\\n\",\n \t\t\t\t\t\toid_to_hex(&p->obj));\n-\t\tif (add_note(t, p->obj.hash, p->remote.hash, combine_notes_overwrite))\n+\t\tif (add_note(t, &p->obj, &p->remote, combine_notes_overwrite))\n \t\t\tdie(\"BUG: combine_notes_overwrite failed\");\n \t\treturn 0;\n \tcase NOTES_MERGE_RESOLVE_UNION:\n \t\tif (o->verbosity >= 2)\n \t\t\tprintf(\"Concatenating local and remote notes for %s\\n\",\n \t\t\t\t\t\t\toid_to_hex(&p->obj));\n-\t\tif (add_note(t, p->obj.hash, p->remote.hash, combine_notes_concatenate))\n+\t\tif (add_note(t, &p->obj, &p->remote, combine_notes_concatenate))\n \t\t\tdie(\"failed to concatenate notes \"\n \t\t\t    \"(combine_notes_concatenate)\");\n \t\treturn 0;\n@@ -459,7 +459,7 @@ static int merge_one_change(struct notes_merge_options *o,\n \t\tif (o->verbosity >= 2)\n \t\t\tprintf(\"Concatenating unique lines in local and remote \"\n \t\t\t\t\"notes for %s\\n\", oid_to_hex(&p->obj));\n-\t\tif (add_note(t, p->obj.hash, p->remote.hash, combine_notes_cat_sort_uniq))\n+\t\tif (add_note(t, &p->obj, &p->remote, combine_notes_cat_sort_uniq))\n \t\t\tdie(\"failed to concatenate notes \"\n \t\t\t    \"(combine_notes_cat_sort_uniq)\");\n \t\treturn 0;\n@@ -491,7 +491,7 @@ static int merge_changes(struct notes_merge_options *o,\n \t\t\t   !oidcmp(&p->local, &p->base)) {\n \t\t\t/* no local change; adopt remote change */\n \t\t\ttrace_printf(\"\\t\\t\\tno local change, adopted remote\\n\");\n-\t\t\tif (add_note(t, p->obj.hash, p->remote.hash,\n+\t\t\tif (add_note(t, &p->obj, &p->remote,\n \t\t\t\t     combine_notes_overwrite))\n \t\t\t\tdie(\"BUG: combine_notes_overwrite failed\");\n \t\t} else {\n@@ -693,12 +693,12 @@ int notes_merge_commit(struct notes_merge_options *o,\n \tbaselen = path.len;\n \twhile ((e = readdir(dir)) != NULL) {\n \t\tstruct stat st;\n-\t\tunsigned char obj_sha1[20], blob_sha1[20];\n+\t\tstruct object_id obj_oid, blob_oid;\n \n \t\tif (is_dot_or_dotdot(e->d_name))\n \t\t\tcontinue;\n \n-\t\tif (strlen(e->d_name) != 40 || get_sha1_hex(e->d_name, obj_sha1)) {\n+\t\tif (get_oid_hex(e->d_name, &obj_oid)) {\n \t\t\tif (o->verbosity >= 3)\n \t\t\t\tprintf(\"Skipping non-SHA1 entry '%s%s'\\n\",\n \t\t\t\t\tpath.buf, e->d_name);\n@@ -709,14 +709,14 @@ int notes_merge_commit(struct notes_merge_options *o,\n \t\t/* write file as blob, and add to partial_tree */\n \t\tif (stat(path.buf, &st))\n \t\t\tdie_errno(\"Failed to stat '%s'\", path.buf);\n-\t\tif (index_path(blob_sha1, path.buf, &st, HASH_WRITE_OBJECT))\n+\t\tif (index_path(blob_oid.hash, path.buf, &st, HASH_WRITE_OBJECT))\n \t\t\tdie(\"Failed to write blob object from '%s'\", path.buf);\n-\t\tif (add_note(partial_tree, obj_sha1, blob_sha1, NULL))\n+\t\tif (add_note(partial_tree, &obj_oid, &blob_oid, NULL))\n \t\t\tdie(\"Failed to add resolved note '%s' to notes tree\",\n \t\t\t    path.buf);\n \t\tif (o->verbosity >= 4)\n \t\t\tprintf(\"Added resolved note for object %s: %s\\n\",\n-\t\t\t\tsha1_to_hex(obj_sha1), sha1_to_hex(blob_sha1));\n+\t\t\t\toid_to_hex(&obj_oid), oid_to_hex(&blob_oid));\n \t\tstrbuf_setlen(&path, baselen);\n \t}\n \ndiff --git a/notes-utils.c b/notes-utils.c\nindex 7d7c22b43..b2aada90a 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -160,7 +160,7 @@ int copy_note_for_rewrite(struct notes_rewrite_cfg *c,\n \tint ret = 0;\n \tint i;\n \tfor (i = 0; c->trees[i]; i++)\n-\t\tret = copy_note(c->trees[i], from_obj->hash, to_obj->hash, 1, c->combine) || ret;\n+\t\tret = copy_note(c->trees[i], from_obj, to_obj, 1, c->combine) || ret;\n \treturn ret;\n }\n \ndiff --git a/notes.c b/notes.c\nindex b5cabafde..4b3a1adda 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -1086,8 +1086,8 @@ void init_display_notes(struct display_notes_opt *opt)\n \tstring_list_clear(&display_notes_refs, 0);\n }\n \n-int add_note(struct notes_tree *t, const unsigned char *object_sha1,\n-\t\tconst unsigned char *note_sha1, combine_notes_fn combine_notes)\n+int add_note(struct notes_tree *t, const struct object_id *object_oid,\n+\t\tconst struct object_id *note_oid, combine_notes_fn combine_notes)\n {\n \tstruct leaf_node *l;\n \n@@ -1098,8 +1098,8 @@ int add_note(struct notes_tree *t, const unsigned char *object_sha1,\n \tif (!combine_notes)\n \t\tcombine_notes = t->combine_notes;\n \tl = (struct leaf_node *) xmalloc(sizeof(struct leaf_node));\n-\thashcpy(l->key_oid.hash, object_sha1);\n-\thashcpy(l->val_oid.hash, note_sha1);\n+\toidcpy(&l->key_oid, object_oid);\n+\toidcpy(&l->val_oid, note_oid);\n \treturn note_tree_insert(t, t->root, 0, l, PTR_TYPE_NOTE, combine_notes);\n }\n \n@@ -1120,14 +1120,14 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1)\n }\n \n const struct object_id *get_note(struct notes_tree *t,\n-\t\tconst unsigned char *object_sha1)\n+\t\tconst struct object_id *oid)\n {\n \tstruct leaf_node *found;\n \n \tif (!t)\n \t\tt = &default_notes_tree;\n \tassert(t->initialized);\n-\tfound = note_tree_find(t, t->root, 0, object_sha1);\n+\tfound = note_tree_find(t, t->root, 0, oid->hash);\n \treturn found ? &found->val_oid : NULL;\n }\n \n@@ -1229,7 +1229,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tif (!t->initialized)\n \t\tinit_notes(t, NULL, NULL, 0);\n \n-\toid = get_note(t, object_oid->hash);\n+\toid = get_note(t, object_oid);\n \tif (!oid)\n \t\treturn;\n \n@@ -1288,7 +1288,7 @@ void format_display_notes(const struct object_id *object_oid,\n }\n \n int copy_note(struct notes_tree *t,\n-\t      const unsigned char *from_obj, const unsigned char *to_obj,\n+\t      const struct object_id *from_obj, const struct object_id *to_obj,\n \t      int force, combine_notes_fn combine_notes)\n {\n \tconst struct object_id *note = get_note(t, from_obj);\n@@ -1298,9 +1298,9 @@ int copy_note(struct notes_tree *t,\n \t\treturn 1;\n \n \tif (note)\n-\t\treturn add_note(t, to_obj, note->hash, combine_notes);\n+\t\treturn add_note(t, to_obj, note, combine_notes);\n \telse if (existing_note)\n-\t\treturn add_note(t, to_obj, null_sha1, combine_notes);\n+\t\treturn add_note(t, to_obj, &null_oid, combine_notes);\n \n \treturn 0;\n }\ndiff --git a/notes.h b/notes.h\nindex a66532103..3848c2fb3 100644\n--- a/notes.h\n+++ b/notes.h\n@@ -121,8 +121,8 @@ void init_notes(struct notes_tree *t, const char *notes_ref,\n  * are not persistent until a subsequent call to write_notes_tree() returns\n  * zero.\n  */\n-int add_note(struct notes_tree *t, const unsigned char *object_sha1,\n-\t\tconst unsigned char *note_sha1, combine_notes_fn combine_notes);\n+int add_note(struct notes_tree *t, const struct object_id *object_oid,\n+\t\tconst struct object_id *note_oid, combine_notes_fn combine_notes);\n \n /*\n  * Remove the given note object from the given notes_tree structure\n@@ -141,7 +141,7 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1);\n  * Return NULL if the given object has no notes.\n  */\n const struct object_id *get_note(struct notes_tree *t,\n-\t\tconst unsigned char *object_sha1);\n+\t\tconst struct object_id *object_oid);\n \n /*\n  * Copy a note from one object to another in the given notes_tree.\n@@ -156,7 +156,7 @@ const struct object_id *get_note(struct notes_tree *t,\n  * zero.\n  */\n int copy_note(struct notes_tree *t,\n-\t      const unsigned char *from_obj, const unsigned char *to_obj,\n+\t      const struct object_id *from_obj, const struct object_id *to_obj,\n \t      int force, combine_notes_fn combine_notes);\n \n /*\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 017af1bd5..8e8d5c794 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -51,7 +51,7 @@ static void terminate_batch(void)\n }\n \n /* NOTE: 'ref' refers to a git reference, while 'rev' refers to a svn revision. */\n-static char *read_ref_note(const unsigned char sha1[20])\n+static char *read_ref_note(const struct object_id *oid)\n {\n \tconst struct object_id *note_oid;\n \tchar *msg = NULL;\n@@ -59,7 +59,7 @@ static char *read_ref_note(const unsigned char sha1[20])\n \tenum object_type type;\n \n \tinit_notes(NULL, notes_ref, NULL, 0);\n-\tif (!(note_oid = get_note(NULL, sha1)))\n+\tif (!(note_oid = get_note(NULL, oid)))\n \t\treturn NULL;\t/* note tree not found */\n \tif (!(msg = read_sha1_file(note_oid->hash, &type, &msglen)))\n \t\terror(\"Empty notes tree. %s\", notes_ref);\n@@ -174,15 +174,15 @@ static int cmd_import(const char *line)\n \tint code;\n \tint dumpin_fd;\n \tchar *note_msg;\n-\tunsigned char head_sha1[20];\n+\tstruct object_id head_oid;\n \tunsigned int startrev;\n \tstruct child_process svndump_proc = CHILD_PROCESS_INIT;\n \tconst char *command = \"svnrdump\";\n \n-\tif (read_ref(private_ref, head_sha1))\n+\tif (read_ref(private_ref, head_oid.hash))\n \t\tstartrev = 0;\n \telse {\n-\t\tnote_msg = read_ref_note(head_sha1);\n+\t\tnote_msg = read_ref_note(&head_oid);\n \t\tif(note_msg == NULL) {\n \t\t\twarning(\"No note found for %s.\", private_ref);\n \t\t\tstartrev = 0;\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321044","messageId":"20170530173109.54904-9-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 08/33] grep: convert to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:44Z","receivedAt":"2017-05-30T17:31:43Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Convert the remaining parts of grep to use struct object_id.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/grep.c | 22 +++++++++++-----------\n cache.h        |  7 +++++++\n grep.c         | 17 ++++++++---------\n grep.h         |  2 +-\n 4 files changed, 27 insertions(+), 21 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex c6c26e9b9..623c13a93 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -327,7 +327,7 @@ static int grep_oid(struct grep_opt *opt, const struct object_id *oid,\n \n #ifndef NO_PTHREADS\n \tif (num_threads) {\n-\t\tadd_work(opt, GREP_SOURCE_SHA1, pathbuf.buf, path, oid);\n+\t\tadd_work(opt, GREP_SOURCE_OID, pathbuf.buf, path, oid);\n \t\tstrbuf_release(&pathbuf);\n \t\treturn 0;\n \t} else\n@@ -336,7 +336,7 @@ static int grep_oid(struct grep_opt *opt, const struct object_id *oid,\n \t\tstruct grep_source gs;\n \t\tint hit;\n \n-\t\tgrep_source_init(&gs, GREP_SOURCE_SHA1, pathbuf.buf, path, oid);\n+\t\tgrep_source_init(&gs, GREP_SOURCE_OID, pathbuf.buf, path, oid);\n \t\tstrbuf_release(&pathbuf);\n \t\thit = grep_source(opt, &gs);\n \n@@ -570,7 +570,7 @@ static int grep_submodule_launch(struct grep_opt *opt,\n \t * with the object's name: 'tree-name:filename'.  In order to\n \t * provide uniformity of output we want to pass the name of the\n \t * parent project's object name to the submodule so the submodule can\n-\t * prefix its output with the parent's name and not its own SHA1.\n+\t * prefix its output with the parent's name and not its own OID.\n \t */\n \tif (gs->identifier && end_of_base)\n \t\targv_array_pushf(&cp.args, \"--parent-basename=%.*s\",\n@@ -583,12 +583,12 @@ static int grep_submodule_launch(struct grep_opt *opt,\n \t\t * If there is a tree identifier for the submodule, add the\n \t\t * rev after adding the submodule options but before the\n \t\t * pathspecs.  To do this we listen for the '--' and insert the\n-\t\t * sha1 before pushing the '--' onto the child process argv\n+\t\t * oid before pushing the '--' onto the child process argv\n \t\t * array.\n \t\t */\n \t\tif (gs->identifier &&\n \t\t    !strcmp(\"--\", submodule_options.argv[i])) {\n-\t\t\targv_array_push(&cp.args, sha1_to_hex(gs->identifier));\n+\t\t\targv_array_push(&cp.args, oid_to_hex(gs->identifier));\n \t\t}\n \n \t\targv_array_push(&cp.args, submodule_options.argv[i]);\n@@ -618,11 +618,11 @@ static int grep_submodule_launch(struct grep_opt *opt,\n \n /*\n  * Prep grep structures for a submodule grep\n- * sha1: the sha1 of the submodule or NULL if using the working tree\n+ * oid: the oid of the submodule or NULL if using the working tree\n  * filename: name of the submodule including tree name of parent\n  * path: location of the submodule\n  */\n-static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,\n+static int grep_submodule(struct grep_opt *opt, const struct object_id *oid,\n \t\t\t  const char *filename, const char *path)\n {\n \tif (!is_submodule_initialized(path))\n@@ -632,7 +632,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,\n \t\t * If searching history, check for the presense of the\n \t\t * submodule's gitdir before skipping the submodule.\n \t\t */\n-\t\tif (sha1) {\n+\t\tif (oid) {\n \t\t\tconst struct submodule *sub =\n \t\t\t\t\tsubmodule_from_path(null_sha1, path);\n \t\t\tif (sub)\n@@ -647,7 +647,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,\n \n #ifndef NO_PTHREADS\n \tif (num_threads) {\n-\t\tadd_work(opt, GREP_SOURCE_SUBMODULE, filename, path, sha1);\n+\t\tadd_work(opt, GREP_SOURCE_SUBMODULE, filename, path, oid);\n \t\treturn 0;\n \t} else\n #endif\n@@ -656,7 +656,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,\n \t\tint hit;\n \n \t\tgrep_source_init(&gs, GREP_SOURCE_SUBMODULE,\n-\t\t\t\t filename, path, sha1);\n+\t\t\t\t filename, path, oid);\n \t\thit = grep_submodule_launch(opt, &gs);\n \n \t\tgrep_source_clear(&gs);\n@@ -775,7 +775,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\t\t\t check_attr);\n \t\t\tfree(data);\n \t\t} else if (recurse_submodules && S_ISGITLINK(entry.mode)) {\n-\t\t\thit |= grep_submodule(opt, entry.oid->hash, base->buf,\n+\t\t\thit |= grep_submodule(opt, entry.oid, base->buf,\n \t\t\t\t\t      base->buf + tn_len);\n \t\t}\n \ndiff --git a/cache.h b/cache.h\nindex ae4c45d37..50fd2b3cc 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1026,6 +1026,13 @@ static inline void oidcpy(struct object_id *dst, const struct object_id *src)\n \thashcpy(dst->hash, src->hash);\n }\n \n+static inline struct object_id *oiddup(const struct object_id *src)\n+{\n+\tstruct object_id *dst = xmalloc(sizeof(struct object_id));\n+\toidcpy(dst, src);\n+\treturn dst;\n+}\n+\n static inline void hashclr(unsigned char *hash)\n {\n \tmemset(hash, 0, GIT_SHA1_RAWSZ);\ndiff --git a/grep.c b/grep.c\nindex 47cee4506..a240b4cdb 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1403,7 +1403,7 @@ static int fill_textconv_grep(struct userdiff_driver *driver,\n \t */\n \tdf = alloc_filespec(gs->path);\n \tswitch (gs->type) {\n-\tcase GREP_SOURCE_SHA1:\n+\tcase GREP_SOURCE_OID:\n \t\tfill_filespec(df, gs->identifier, 1, 0100644);\n \t\tbreak;\n \tcase GREP_SOURCE_FILE:\n@@ -1747,9 +1747,8 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,\n \t\t * If the identifier is non-NULL (in the submodule case) it\n \t\t * will be a SHA1 that needs to be copied.\n \t\t */\n-\tcase GREP_SOURCE_SHA1:\n-\t\tgs->identifier = xmalloc(20);\n-\t\thashcpy(gs->identifier, identifier);\n+\tcase GREP_SOURCE_OID:\n+\t\tgs->identifier = oiddup(identifier);\n \t\tbreak;\n \tcase GREP_SOURCE_BUF:\n \t\tgs->identifier = NULL;\n@@ -1772,7 +1771,7 @@ void grep_source_clear_data(struct grep_source *gs)\n {\n \tswitch (gs->type) {\n \tcase GREP_SOURCE_FILE:\n-\tcase GREP_SOURCE_SHA1:\n+\tcase GREP_SOURCE_OID:\n \tcase GREP_SOURCE_SUBMODULE:\n \t\tfree(gs->buf);\n \t\tgs->buf = NULL;\n@@ -1784,7 +1783,7 @@ void grep_source_clear_data(struct grep_source *gs)\n \t}\n }\n \n-static int grep_source_load_sha1(struct grep_source *gs)\n+static int grep_source_load_oid(struct grep_source *gs)\n {\n \tenum object_type type;\n \n@@ -1795,7 +1794,7 @@ static int grep_source_load_sha1(struct grep_source *gs)\n \tif (!gs->buf)\n \t\treturn error(_(\"'%s': unable to read %s\"),\n \t\t\t     gs->name,\n-\t\t\t     sha1_to_hex(gs->identifier));\n+\t\t\t     oid_to_hex(gs->identifier));\n \treturn 0;\n }\n \n@@ -1841,8 +1840,8 @@ static int grep_source_load(struct grep_source *gs)\n \tswitch (gs->type) {\n \tcase GREP_SOURCE_FILE:\n \t\treturn grep_source_load_file(gs);\n-\tcase GREP_SOURCE_SHA1:\n-\t\treturn grep_source_load_sha1(gs);\n+\tcase GREP_SOURCE_OID:\n+\t\treturn grep_source_load_oid(gs);\n \tcase GREP_SOURCE_BUF:\n \t\treturn gs->buf ? 0 : -1;\n \tcase GREP_SOURCE_SUBMODULE:\ndiff --git a/grep.h b/grep.h\nindex 267534ca2..c88b40bdc 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -158,7 +158,7 @@ struct grep_source {\n \tchar *name;\n \n \tenum grep_source_type {\n-\t\tGREP_SOURCE_SHA1,\n+\t\tGREP_SOURCE_OID,\n \t\tGREP_SOURCE_FILE,\n \t\tGREP_SOURCE_BUF,\n \t\tGREP_SOURCE_SUBMODULE,\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321045","messageId":"20170530173109.54904-16-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 15/33] diff: convert reuse_worktree_file to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:51Z","receivedAt":"2017-05-30T17:31:46Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n diff.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex e0c179f5f..084c8b2d0 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2717,7 +2717,7 @@ void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,\n  * the work tree has that object contents, return true, so that\n  * prepare_temp_file() does not have to inflate and extract.\n  */\n-static int reuse_worktree_file(const char *name, const unsigned char *sha1, int want_file)\n+static int reuse_worktree_file(const char *name, const struct object_id *oid, int want_file)\n {\n \tconst struct cache_entry *ce;\n \tstruct stat st;\n@@ -2748,7 +2748,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int\n \t * objects however would tend to be slower as they need\n \t * to be individually opened and inflated.\n \t */\n-\tif (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1))\n+\tif (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(oid->hash))\n \t\treturn 0;\n \n \t/*\n@@ -2768,7 +2768,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int\n \t * This is not the sha1 we are looking for, or\n \t * unreusable because it is not a regular file.\n \t */\n-\tif (hashcmp(sha1, ce->oid.hash) || !S_ISREG(ce->ce_mode))\n+\tif (oidcmp(oid, &ce->oid) || !S_ISREG(ce->ce_mode))\n \t\treturn 0;\n \n \t/*\n@@ -2842,7 +2842,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)\n \t\treturn diff_populate_gitlink(s, size_only);\n \n \tif (!s->oid_valid ||\n-\t    reuse_worktree_file(s->path, s->oid.hash, 0)) {\n+\t    reuse_worktree_file(s->path, &s->oid, 0)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tstruct stat st;\n \t\tint fd;\n@@ -3008,7 +3008,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,\n \n \tif (!S_ISGITLINK(one->mode) &&\n \t    (!one->oid_valid ||\n-\t     reuse_worktree_file(name, one->oid.hash, 1))) {\n+\t     reuse_worktree_file(name, &one->oid, 1))) {\n \t\tstruct stat st;\n \t\tif (lstat(name, &st) < 0) {\n \t\t\tif (errno == ENOENT)\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321046","messageId":"20170530173109.54904-11-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 10/33] diff: convert diff_index_show_file to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:46Z","receivedAt":"2017-05-30T17:31:49Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n diff-lib.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex a3bc78162..2c838aaf4 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -255,12 +255,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n static void diff_index_show_file(struct rev_info *revs,\n \t\t\t\t const char *prefix,\n \t\t\t\t const struct cache_entry *ce,\n-\t\t\t\t const unsigned char *sha1, int sha1_valid,\n+\t\t\t\t const struct object_id *oid, int oid_valid,\n \t\t\t\t unsigned int mode,\n \t\t\t\t unsigned dirty_submodule)\n {\n \tdiff_addremove(&revs->diffopt, prefix[0], mode,\n-\t\t       sha1, sha1_valid, ce->name, dirty_submodule);\n+\t\t       oid->hash, oid_valid, ce->name, dirty_submodule);\n }\n \n static int get_stat_data(const struct cache_entry *ce,\n@@ -315,7 +315,7 @@ static void show_new_file(struct rev_info *revs,\n \t    &dirty_submodule, &revs->diffopt) < 0)\n \t\treturn;\n \n-\tdiff_index_show_file(revs, \"+\", new, oid->hash, !is_null_oid(oid), mode, dirty_submodule);\n+\tdiff_index_show_file(revs, \"+\", new, oid, !is_null_oid(oid), mode, dirty_submodule);\n }\n \n static int show_modified(struct rev_info *revs,\n@@ -332,7 +332,7 @@ static int show_modified(struct rev_info *revs,\n \t\t\t  &dirty_submodule, &revs->diffopt) < 0) {\n \t\tif (report_missing)\n \t\t\tdiff_index_show_file(revs, \"-\", old,\n-\t\t\t\t\t     old->oid.hash, 1, old->ce_mode,\n+\t\t\t\t\t     &old->oid, 1, old->ce_mode,\n \t\t\t\t\t     0);\n \t\treturn -1;\n \t}\n@@ -426,7 +426,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,\n \t * Something removed from the tree?\n \t */\n \tif (!idx) {\n-\t\tdiff_index_show_file(revs, \"-\", tree, tree->oid.hash, 1,\n+\t\tdiff_index_show_file(revs, \"-\", tree, &tree->oid, 1,\n \t\t\t\t     tree->ce_mode, 0);\n \t\treturn;\n \t}\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321047","messageId":"20170530173109.54904-20-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 19/33] combine-diff: convert diff_tree_combined to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:55Z","receivedAt":"2017-05-30T17:31:51Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/diff.c |  2 +-\n combine-diff.c | 10 +++++-----\n diff.h         |  2 +-\n 3 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex b2d7c32cd..73b4ff3db 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -194,7 +194,7 @@ static int builtin_diff_combined(struct rev_info *revs,\n \t\trevs->dense_combined_merges = revs->combine_merges = 1;\n \tfor (i = 1; i < ents; i++)\n \t\toid_array_append(&parents, &ent[i].item->oid);\n-\tdiff_tree_combined(ent[0].item->oid.hash, &parents,\n+\tdiff_tree_combined(&ent[0].item->oid, &parents,\n \t\t\t   revs->dense_combined_merges, revs);\n \toid_array_clear(&parents);\n \treturn 0;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex ad063ecb1..84981df75 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1384,7 +1384,7 @@ static struct combine_diff_path *find_paths_multitree(\n }\n \n \n-void diff_tree_combined(const unsigned char *sha1,\n+void diff_tree_combined(const struct object_id *oid,\n \t\t\tconst struct oid_array *parents,\n \t\t\tint dense,\n \t\t\tstruct rev_info *rev)\n@@ -1448,11 +1448,11 @@ void diff_tree_combined(const unsigned char *sha1,\n \t\t * diff(sha1,parent_i) for all i to do the job, specifically\n \t\t * for parent0.\n \t\t */\n-\t\tpaths = find_paths_generic(sha1, parents, &diffopts);\n+\t\tpaths = find_paths_generic(oid->hash, parents, &diffopts);\n \t}\n \telse {\n \t\tint stat_opt;\n-\t\tpaths = find_paths_multitree(sha1, parents, &diffopts);\n+\t\tpaths = find_paths_multitree(oid->hash, parents, &diffopts);\n \n \t\t/*\n \t\t * show stat against the first parent even\n@@ -1463,7 +1463,7 @@ void diff_tree_combined(const unsigned char *sha1,\n \t\tif (stat_opt) {\n \t\t\tdiffopts.output_format = stat_opt;\n \n-\t\t\tdiff_tree_sha1(parents->oid[0].hash, sha1, \"\", &diffopts);\n+\t\t\tdiff_tree_sha1(parents->oid[0].hash, oid->hash, \"\", &diffopts);\n \t\t\tdiffcore_std(&diffopts);\n \t\t\tif (opt->orderfile)\n \t\t\t\tdiffcore_order(opt->orderfile);\n@@ -1539,6 +1539,6 @@ void diff_tree_combined_merge(const struct commit *commit, int dense,\n \t\toid_array_append(&parents, &parent->item->object.oid);\n \t\tparent = parent->next;\n \t}\n-\tdiff_tree_combined(commit->object.oid.hash, &parents, dense, rev);\n+\tdiff_tree_combined(&commit->object.oid, &parents, dense, rev);\n \toid_array_clear(&parents);\n }\ndiff --git a/diff.h b/diff.h\nindex 150f1c5a1..6aeeda035 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -236,7 +236,7 @@ struct combine_diff_path {\n extern void show_combined_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\t      int dense, struct rev_info *);\n \n-extern void diff_tree_combined(const unsigned char *sha1, const struct oid_array *parents, int dense, struct rev_info *rev);\n+extern void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, int dense, struct rev_info *rev);\n \n extern void diff_tree_combined_merge(const struct commit *commit, int dense, struct rev_info *rev);\n \n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321048","messageId":"20170530173109.54904-15-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 14/33] diff: convert fill_filespec to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:50Z","receivedAt":"2017-05-30T17:31:52Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/blame.c   |  2 +-\n builtin/diff.c    |  4 ++--\n combine-diff.c    |  4 ++--\n diff-lib.c        |  2 +-\n diff-no-index.c   |  2 +-\n diff.c            | 16 ++++++++--------\n diffcore-rename.c |  2 +-\n diffcore.h        |  2 +-\n grep.c            |  2 +-\n line-log.c        |  6 +++---\n 10 files changed, 21 insertions(+), 21 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 1043e5376..5ad435380 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -163,7 +163,7 @@ int textconv_object(const char *path,\n \tstruct userdiff_driver *textconv;\n \n \tdf = alloc_filespec(path);\n-\tfill_filespec(df, oid->hash, oid_valid, mode);\n+\tfill_filespec(df, oid, oid_valid, mode);\n \ttextconv = get_textconv(df);\n \tif (!textconv) {\n \t\tfree_filespec(df);\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 8c03ddaf5..b2d7c32cd 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -57,8 +57,8 @@ static void stuff_change(struct diff_options *opt,\n \n \tone = alloc_filespec(old_name);\n \ttwo = alloc_filespec(new_name);\n-\tfill_filespec(one, old_oid->hash, old_oid_valid, old_mode);\n-\tfill_filespec(two, new_oid->hash, new_oid_valid, new_mode);\n+\tfill_filespec(one, old_oid, old_oid_valid, old_mode);\n+\tfill_filespec(two, new_oid, new_oid_valid, new_mode);\n \n \tdiff_queue(&diff_queued_diff, one, two);\n }\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 2848034fe..ad063ecb1 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -302,7 +302,7 @@ static char *grab_blob(const struct object_id *oid, unsigned int mode,\n \t\treturn xcalloc(1, 1);\n \t} else if (textconv) {\n \t\tstruct diff_filespec *df = alloc_filespec(path);\n-\t\tfill_filespec(df, oid->hash, 1, mode);\n+\t\tfill_filespec(df, oid, 1, mode);\n \t\t*size = fill_textconv(textconv, df, &blob);\n \t\tfree_filespec(df);\n \t} else {\n@@ -1022,7 +1022,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\t\t\t\t   &result_size, NULL, NULL);\n \t\t} else if (textconv) {\n \t\t\tstruct diff_filespec *df = alloc_filespec(elem->path);\n-\t\t\tfill_filespec(df, null_sha1, 0, st.st_mode);\n+\t\t\tfill_filespec(df, &null_oid, 0, st.st_mode);\n \t\t\tresult_size = fill_textconv(textconv, df, &result);\n \t\t\tfree_filespec(df);\n \t\t} else if (0 <= (fd = open(elem->path, O_RDONLY))) {\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 1e8215df5..9e076a488 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -409,7 +409,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,\n \t\tstruct diff_filepair *pair;\n \t\tpair = diff_unmerge(&revs->diffopt, idx->name);\n \t\tif (tree)\n-\t\t\tfill_filespec(pair->one, tree->oid.hash, 1,\n+\t\t\tfill_filespec(pair->one, &tree->oid, 1,\n \t\t\t\t      tree->ce_mode);\n \t\treturn;\n \t}\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 79229382b..80ff17d46 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -82,7 +82,7 @@ static struct diff_filespec *noindex_filespec(const char *name, int mode)\n \tif (!name)\n \t\tname = \"/dev/null\";\n \ts = alloc_filespec(name);\n-\tfill_filespec(s, null_sha1, 0, mode);\n+\tfill_filespec(s, &null_oid, 0, mode);\n \tif (name == file_from_standard_input)\n \t\tpopulate_from_stdin(s);\n \treturn s;\ndiff --git a/diff.c b/diff.c\nindex b9bb3f6ca..e0c179f5f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2702,13 +2702,13 @@ void free_filespec(struct diff_filespec *spec)\n \t}\n }\n \n-void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,\n-\t\t   int sha1_valid, unsigned short mode)\n+void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,\n+\t\t   int oid_valid, unsigned short mode)\n {\n \tif (mode) {\n \t\tspec->mode = canon_mode(mode);\n-\t\thashcpy(spec->oid.hash, sha1);\n-\t\tspec->oid_valid = sha1_valid;\n+\t\toidcpy(&spec->oid, oid);\n+\t\tspec->oid_valid = oid_valid;\n \t}\n }\n \n@@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,\n \ttwo = alloc_filespec(concatpath);\n \n \tif (addremove != '+')\n-\t\tfill_filespec(one, oid->hash, oid_valid, mode);\n+\t\tfill_filespec(one, oid, oid_valid, mode);\n \tif (addremove != '-') {\n-\t\tfill_filespec(two, oid->hash, oid_valid, mode);\n+\t\tfill_filespec(two, oid, oid_valid, mode);\n \t\ttwo->dirty_submodule = dirty_submodule;\n \t}\n \n@@ -5153,8 +5153,8 @@ void diff_change(struct diff_options *options,\n \n \tone = alloc_filespec(concatpath);\n \ttwo = alloc_filespec(concatpath);\n-\tfill_filespec(one, old_oid->hash, old_oid_valid, old_mode);\n-\tfill_filespec(two, new_oid->hash, new_oid_valid, new_mode);\n+\tfill_filespec(one, old_oid, old_oid_valid, old_mode);\n+\tfill_filespec(two, new_oid, new_oid_valid, new_mode);\n \tone->dirty_submodule = old_dirty_submodule;\n \ttwo->dirty_submodule = new_dirty_submodule;\n \tp = diff_queue(&diff_queued_diff, one, two);\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex f7444c86b..3d9719dad 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -60,7 +60,7 @@ static int add_rename_dst(struct diff_filespec *two)\n \t\tmemmove(rename_dst + first + 1, rename_dst + first,\n \t\t\t(rename_dst_nr - first - 1) * sizeof(*rename_dst));\n \trename_dst[first].two = alloc_filespec(two->path);\n-\tfill_filespec(rename_dst[first].two, two->oid.hash, two->oid_valid,\n+\tfill_filespec(rename_dst[first].two, &two->oid, two->oid_valid,\n \t\t      two->mode);\n \trename_dst[first].pair = NULL;\n \treturn 0;\ndiff --git a/diffcore.h b/diffcore.h\nindex 623024135..a30da161d 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -52,7 +52,7 @@ struct diff_filespec {\n \n extern struct diff_filespec *alloc_filespec(const char *);\n extern void free_filespec(struct diff_filespec *);\n-extern void fill_filespec(struct diff_filespec *, const unsigned char *,\n+extern void fill_filespec(struct diff_filespec *, const struct object_id *,\n \t\t\t  int, unsigned short);\n \n #define CHECK_SIZE_ONLY 1\ndiff --git a/grep.c b/grep.c\nindex a240b4cdb..3e21c92b9 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1407,7 +1407,7 @@ static int fill_textconv_grep(struct userdiff_driver *driver,\n \t\tfill_filespec(df, gs->identifier, 1, 0100644);\n \t\tbreak;\n \tcase GREP_SOURCE_FILE:\n-\t\tfill_filespec(df, null_sha1, 0, 0100644);\n+\t\tfill_filespec(df, &null_oid, 0, 0100644);\n \t\tbreak;\n \tdefault:\n \t\tdie(\"BUG: attempt to textconv something without a path?\");\ndiff --git a/line-log.c b/line-log.c\nindex b9087814b..a3bd2f2d5 100644\n--- a/line-log.c\n+++ b/line-log.c\n@@ -500,12 +500,12 @@ static struct commit *check_single_commit(struct rev_info *revs)\n static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)\n {\n \tunsigned mode;\n-\tunsigned char sha1[20];\n+\tstruct object_id oid;\n \n \tif (get_tree_entry(commit->object.oid.hash, spec->path,\n-\t\t\t   sha1, &mode))\n+\t\t\t   oid.hash, &mode))\n \t\tdie(\"There is no path %s in the commit\", spec->path);\n-\tfill_filespec(spec, sha1, 1, mode);\n+\tfill_filespec(spec, &oid, 1, mode);\n \n \treturn;\n }\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321049","messageId":"20170530173109.54904-22-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 21/33] tree-diff: convert diff_root_tree_sha1 to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:57Z","receivedAt":"2017-05-30T17:31:55Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/fast-export.c | 4 ++--\n diff.h                | 4 ++--\n log-tree.c            | 2 +-\n patch-ids.c           | 2 +-\n tree-diff.c           | 4 ++--\n 5 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 24e29ad7e..e242726f0 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -566,8 +566,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)\n \t\t\t       commit->tree->object.oid.hash, \"\", &rev->diffopt);\n \t}\n \telse\n-\t\tdiff_root_tree_sha1(commit->tree->object.oid.hash,\n-\t\t\t\t    \"\", &rev->diffopt);\n+\t\tdiff_root_tree_oid(&commit->tree->object.oid,\n+\t\t\t\t   \"\", &rev->diffopt);\n \n \t/* Export the referenced blobs, and remember the marks. */\n \tfor (i = 0; i < diff_queued_diff.nr; i++)\ndiff --git a/diff.h b/diff.h\nindex 6aeeda035..8d46a6709 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -215,8 +215,8 @@ extern struct combine_diff_path *diff_tree_paths(\n \tstruct strbuf *base, struct diff_options *opt);\n extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,\n \t\t\t  const char *base, struct diff_options *opt);\n-extern int diff_root_tree_sha1(const unsigned char *new, const char *base,\n-                               struct diff_options *opt);\n+extern int diff_root_tree_oid(const struct object_id *new_oid, const char *base,\n+\t\t\t      struct diff_options *opt);\n \n struct combine_diff_path {\n \tstruct combine_diff_path *next;\ndiff --git a/log-tree.c b/log-tree.c\nindex 9c0c64a2d..b40242534 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -803,7 +803,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \tparents = get_saved_parents(opt, commit);\n \tif (!parents) {\n \t\tif (opt->show_root_diff) {\n-\t\t\tdiff_root_tree_sha1(oid->hash, \"\", &opt->diffopt);\n+\t\t\tdiff_root_tree_oid(oid, \"\", &opt->diffopt);\n \t\t\tlog_tree_diff_flush(opt);\n \t\t}\n \t\treturn !opt->loginfo;\ndiff --git a/patch-ids.c b/patch-ids.c\nindex a70a291d8..aaf462c03 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -20,7 +20,7 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,\n \t\tdiff_tree_sha1(commit->parents->item->object.oid.hash,\n \t\t\t       commit->object.oid.hash, \"\", options);\n \telse\n-\t\tdiff_root_tree_sha1(commit->object.oid.hash, \"\", options);\n+\t\tdiff_root_tree_oid(&commit->object.oid, \"\", options);\n \tdiffcore_std(options);\n \treturn diff_flush_patch_id(options, oid, diff_header_only);\n }\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 7ae1f10b2..f9bbaf3c4 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -711,7 +711,7 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha\n \treturn retval;\n }\n \n-int diff_root_tree_sha1(const unsigned char *new, const char *base, struct diff_options *opt)\n+int diff_root_tree_oid(const struct object_id *new_oid, const char *base, struct diff_options *opt)\n {\n-\treturn diff_tree_sha1(NULL, new, base, opt);\n+\treturn diff_tree_sha1(NULL, new_oid->hash, base, opt);\n }\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321050","messageId":"20170530173109.54904-25-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 24/33] notes-merge: convert find_notes_merge_pair_ps to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:00Z","receivedAt":"2017-05-30T17:31:58Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n notes-merge.c | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/notes-merge.c b/notes-merge.c\nindex be78f1954..55dbb3659 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -58,7 +58,7 @@ static int verify_notes_filepair(struct diff_filepair *p, unsigned char *sha1)\n }\n \n static struct notes_merge_pair *find_notes_merge_pair_pos(\n-\t\tstruct notes_merge_pair *list, int len, unsigned char *obj,\n+\t\tstruct notes_merge_pair *list, int len, struct object_id *obj,\n \t\tint insert_new, int *occupied)\n {\n \t/*\n@@ -75,7 +75,7 @@ static struct notes_merge_pair *find_notes_merge_pair_pos(\n \tint i = last_index < len ? last_index : len - 1;\n \tint prev_cmp = 0, cmp = -1;\n \twhile (i >= 0 && i < len) {\n-\t\tcmp = hashcmp(obj, list[i].obj.hash);\n+\t\tcmp = oidcmp(obj, &list[i].obj);\n \t\tif (!cmp) /* obj belongs @ i */\n \t\t\tbreak;\n \t\telse if (cmp < 0 && prev_cmp <= 0) /* obj belongs < i */\n@@ -138,19 +138,19 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \t\tstruct diff_filepair *p = diff_queued_diff.queue[i];\n \t\tstruct notes_merge_pair *mp;\n \t\tint occupied;\n-\t\tunsigned char obj[20];\n+\t\tstruct object_id obj;\n \n-\t\tif (verify_notes_filepair(p, obj)) {\n+\t\tif (verify_notes_filepair(p, obj.hash)) {\n \t\t\ttrace_printf(\"\\t\\tCannot merge entry '%s' (%c): \"\n \t\t\t       \"%.7s -> %.7s. Skipping!\\n\", p->one->path,\n \t\t\t       p->status, oid_to_hex(&p->one->oid),\n \t\t\t       oid_to_hex(&p->two->oid));\n \t\t\tcontinue;\n \t\t}\n-\t\tmp = find_notes_merge_pair_pos(changes, len, obj, 1, &occupied);\n+\t\tmp = find_notes_merge_pair_pos(changes, len, &obj, 1, &occupied);\n \t\tif (occupied) {\n \t\t\t/* We've found an addition/deletion pair */\n-\t\t\tassert(!hashcmp(mp->obj.hash, obj));\n+\t\t\tassert(!oidcmp(&mp->obj, &obj));\n \t\t\tif (is_null_oid(&p->one->oid)) { /* addition */\n \t\t\t\tassert(is_null_oid(&mp->remote));\n \t\t\t\toidcpy(&mp->remote, &p->two->oid);\n@@ -160,7 +160,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \t\t\t} else\n \t\t\t\tassert(!\"Invalid existing change recorded\");\n \t\t} else {\n-\t\t\thashcpy(mp->obj.hash, obj);\n+\t\t\toidcpy(&mp->obj, &obj);\n \t\t\toidcpy(&mp->base, &p->one->oid);\n \t\t\toidcpy(&mp->local, &uninitialized);\n \t\t\toidcpy(&mp->remote, &p->two->oid);\n@@ -199,25 +199,25 @@ static void diff_tree_local(struct notes_merge_options *o,\n \t\tstruct diff_filepair *p = diff_queued_diff.queue[i];\n \t\tstruct notes_merge_pair *mp;\n \t\tint match;\n-\t\tunsigned char obj[20];\n+\t\tstruct object_id obj;\n \n-\t\tif (verify_notes_filepair(p, obj)) {\n+\t\tif (verify_notes_filepair(p, obj.hash)) {\n \t\t\ttrace_printf(\"\\t\\tCannot merge entry '%s' (%c): \"\n \t\t\t       \"%.7s -> %.7s. Skipping!\\n\", p->one->path,\n \t\t\t       p->status, oid_to_hex(&p->one->oid),\n \t\t\t       oid_to_hex(&p->two->oid));\n \t\t\tcontinue;\n \t\t}\n-\t\tmp = find_notes_merge_pair_pos(changes, len, obj, 0, &match);\n+\t\tmp = find_notes_merge_pair_pos(changes, len, &obj, 0, &match);\n \t\tif (!match) {\n \t\t\ttrace_printf(\"\\t\\tIgnoring local-only change for %s: \"\n-\t\t\t       \"%.7s -> %.7s\\n\", sha1_to_hex(obj),\n+\t\t\t       \"%.7s -> %.7s\\n\", oid_to_hex(&obj),\n \t\t\t       oid_to_hex(&p->one->oid),\n \t\t\t       oid_to_hex(&p->two->oid));\n \t\t\tcontinue;\n \t\t}\n \n-\t\tassert(!hashcmp(mp->obj.hash, obj));\n+\t\tassert(!oidcmp(&mp->obj, &obj));\n \t\tif (is_null_oid(&p->two->oid)) { /* deletion */\n \t\t\t/*\n \t\t\t * Either this is a true deletion (1), or it is part\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321051","messageId":"20170530173109.54904-19-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 18/33] diff: convert diff_flush_patch_id to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:54Z","receivedAt":"2017-05-30T17:32:00Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n diff.c      | 12 ++++++------\n diff.h      |  2 +-\n patch-ids.c |  2 +-\n 3 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex a8ceeb024..dd325e616 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4584,7 +4584,7 @@ static void patch_id_add_mode(git_SHA_CTX *ctx, unsigned mode)\n }\n \n /* returns 0 upon success, and writes result into sha1 */\n-static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1, int diff_header_only)\n+static int diff_get_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)\n {\n \tstruct diff_queue_struct *q = &diff_queued_diff;\n \tint i;\n@@ -4656,9 +4656,9 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1,\n \t\tif (diff_filespec_is_binary(p->one) ||\n \t\t    diff_filespec_is_binary(p->two)) {\n \t\t\tgit_SHA1_Update(&ctx, oid_to_hex(&p->one->oid),\n-\t\t\t\t\t40);\n+\t\t\t\t\tGIT_SHA1_HEXSZ);\n \t\t\tgit_SHA1_Update(&ctx, oid_to_hex(&p->two->oid),\n-\t\t\t\t\t40);\n+\t\t\t\t\tGIT_SHA1_HEXSZ);\n \t\t\tcontinue;\n \t\t}\n \n@@ -4671,15 +4671,15 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1,\n \t\t\t\t     p->one->path);\n \t}\n \n-\tgit_SHA1_Final(sha1, &ctx);\n+\tgit_SHA1_Final(oid->hash, &ctx);\n \treturn 0;\n }\n \n-int diff_flush_patch_id(struct diff_options *options, unsigned char *sha1, int diff_header_only)\n+int diff_flush_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)\n {\n \tstruct diff_queue_struct *q = &diff_queued_diff;\n \tint i;\n-\tint result = diff_get_patch_id(options, sha1, diff_header_only);\n+\tint result = diff_get_patch_id(options, oid, diff_header_only);\n \n \tfor (i = 0; i < q->nr; i++)\n \t\tdiff_free_filepair(q->queue[i]);\ndiff --git a/diff.h b/diff.h\nindex fcf334bb6..150f1c5a1 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -354,7 +354,7 @@ extern int run_diff_files(struct rev_info *revs, unsigned int option);\n extern int run_diff_index(struct rev_info *revs, int cached);\n \n extern int do_diff_cache(const struct object_id *, struct diff_options *);\n-extern int diff_flush_patch_id(struct diff_options *, unsigned char *, int);\n+extern int diff_flush_patch_id(struct diff_options *, struct object_id *, int);\n \n extern int diff_result_code(struct diff_options *, int);\n \ndiff --git a/patch-ids.c b/patch-ids.c\nindex aab26cbbb..a70a291d8 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -22,7 +22,7 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,\n \telse\n \t\tdiff_root_tree_sha1(commit->object.oid.hash, \"\", options);\n \tdiffcore_std(options);\n-\treturn diff_flush_patch_id(options, oid->hash, diff_header_only);\n+\treturn diff_flush_patch_id(options, oid, diff_header_only);\n }\n \n /*\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321052","messageId":"20170530173109.54904-26-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 25/33] notes-merge: convert verify_notes_filepair to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:01Z","receivedAt":"2017-05-30T17:32:05Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n notes-merge.c | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 55dbb3659..962e9b1bc 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -22,21 +22,21 @@ void init_notes_merge_options(struct notes_merge_options *o)\n \to->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;\n }\n \n-static int path_to_sha1(const char *path, unsigned char *sha1)\n+static int path_to_oid(const char *path, struct object_id *oid)\n {\n-\tchar hex_sha1[40];\n+\tchar hex_oid[GIT_SHA1_HEXSZ];\n \tint i = 0;\n-\twhile (*path && i < 40) {\n+\twhile (*path && i < GIT_SHA1_HEXSZ) {\n \t\tif (*path != '/')\n-\t\t\thex_sha1[i++] = *path;\n+\t\t\thex_oid[i++] = *path;\n \t\tpath++;\n \t}\n-\tif (*path || i != 40)\n+\tif (*path || i != GIT_SHA1_HEXSZ)\n \t\treturn -1;\n-\treturn get_sha1_hex(hex_sha1, sha1);\n+\treturn get_oid_hex(hex_oid, oid);\n }\n \n-static int verify_notes_filepair(struct diff_filepair *p, unsigned char *sha1)\n+static int verify_notes_filepair(struct diff_filepair *p, struct object_id *oid)\n {\n \tswitch (p->status) {\n \tcase DIFF_STATUS_MODIFIED:\n@@ -54,7 +54,7 @@ static int verify_notes_filepair(struct diff_filepair *p, unsigned char *sha1)\n \t\treturn -1;\n \t}\n \tassert(!strcmp(p->one->path, p->two->path));\n-\treturn path_to_sha1(p->one->path, sha1);\n+\treturn path_to_oid(p->one->path, oid);\n }\n \n static struct notes_merge_pair *find_notes_merge_pair_pos(\n@@ -140,7 +140,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \t\tint occupied;\n \t\tstruct object_id obj;\n \n-\t\tif (verify_notes_filepair(p, obj.hash)) {\n+\t\tif (verify_notes_filepair(p, &obj)) {\n \t\t\ttrace_printf(\"\\t\\tCannot merge entry '%s' (%c): \"\n \t\t\t       \"%.7s -> %.7s. Skipping!\\n\", p->one->path,\n \t\t\t       p->status, oid_to_hex(&p->one->oid),\n@@ -201,7 +201,7 @@ static void diff_tree_local(struct notes_merge_options *o,\n \t\tint match;\n \t\tstruct object_id obj;\n \n-\t\tif (verify_notes_filepair(p, obj.hash)) {\n+\t\tif (verify_notes_filepair(p, &obj)) {\n \t\t\ttrace_printf(\"\\t\\tCannot merge entry '%s' (%c): \"\n \t\t\t       \"%.7s -> %.7s. Skipping!\\n\", p->one->path,\n \t\t\t       p->status, oid_to_hex(&p->one->oid),\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321053","messageId":"20170530173109.54904-31-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 30/33] tree-diff: convert diff_tree_paths to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:06Z","receivedAt":"2017-05-30T17:32:07Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n combine-diff.c | 10 +++++-----\n diff.h         |  4 ++--\n tree-diff.c    | 63 +++++++++++++++++++++++++++++-----------------------------\n 3 files changed, 39 insertions(+), 38 deletions(-)\n\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 04c4ae856..ec9d93044 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1364,22 +1364,22 @@ static struct combine_diff_path *find_paths_multitree(\n \tstruct diff_options *opt)\n {\n \tint i, nparent = parents->nr;\n-\tconst unsigned char **parents_sha1;\n+\tconst struct object_id **parents_oid;\n \tstruct combine_diff_path paths_head;\n \tstruct strbuf base;\n \n-\tALLOC_ARRAY(parents_sha1, nparent);\n+\tALLOC_ARRAY(parents_oid, nparent);\n \tfor (i = 0; i < nparent; i++)\n-\t\tparents_sha1[i] = parents->oid[i].hash;\n+\t\tparents_oid[i] = &parents->oid[i];\n \n \t/* fake list head, so worker can assume it is non-NULL */\n \tpaths_head.next = NULL;\n \n \tstrbuf_init(&base, PATH_MAX);\n-\tdiff_tree_paths(&paths_head, oid->hash, parents_sha1, nparent, &base, opt);\n+\tdiff_tree_paths(&paths_head, oid, parents_oid, nparent, &base, opt);\n \n \tstrbuf_release(&base);\n-\tfree(parents_sha1);\n+\tfree(parents_oid);\n \treturn paths_head.next;\n }\n \ndiff --git a/diff.h b/diff.h\nindex e0b503460..0d0c14f28 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -210,8 +210,8 @@ const char *diff_line_prefix(struct diff_options *);\n extern const char mime_boundary_leader[];\n \n extern struct combine_diff_path *diff_tree_paths(\n-\tstruct combine_diff_path *p, const unsigned char *sha1,\n-\tconst unsigned char **parent_sha1, int nparent,\n+\tstruct combine_diff_path *p, const struct object_id *oid,\n+\tconst struct object_id **parents_oid, int nparent,\n \tstruct strbuf *base, struct diff_options *opt);\n extern int diff_tree_oid(const struct object_id *old_oid,\n \t\t\t const struct object_id *new_oid,\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 29e3f6144..6a960f569 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -26,11 +26,12 @@\n } while(0)\n \n static struct combine_diff_path *ll_diff_tree_paths(\n-\tstruct combine_diff_path *p, const unsigned char *sha1,\n-\tconst unsigned char **parents_sha1, int nparent,\n+\tstruct combine_diff_path *p, const struct object_id *oid,\n+\tconst struct object_id **parents_oid, int nparent,\n \tstruct strbuf *base, struct diff_options *opt);\n-static int ll_diff_tree_sha1(const unsigned char *old, const unsigned char *new,\n-\t\t\t     struct strbuf *base, struct diff_options *opt);\n+static int ll_diff_tree_oid(const struct object_id *old_oid,\n+\t\t\t    const struct object_id *new_oid,\n+\t\t\t    struct strbuf *base, struct diff_options *opt);\n \n /*\n  * Compare two tree entries, taking into account only path/S_ISDIR(mode),\n@@ -183,7 +184,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n {\n \tunsigned mode;\n \tconst char *path;\n-\tconst unsigned char *sha1;\n+\tconst struct object_id *oid;\n \tint pathlen;\n \tint old_baselen = base->len;\n \tint i, isdir, recurse = 0, emitthis = 1;\n@@ -193,7 +194,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \n \tif (t) {\n \t\t/* path present in resulting tree */\n-\t\tsha1 = tree_entry_extract(t, &path, &mode)->hash;\n+\t\toid = tree_entry_extract(t, &path, &mode);\n \t\tpathlen = tree_entry_len(&t->entry);\n \t\tisdir = S_ISDIR(mode);\n \t} else {\n@@ -208,7 +209,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \t\tpathlen = tree_entry_len(&tp[imin].entry);\n \n \t\tisdir = S_ISDIR(mode);\n-\t\tsha1 = NULL;\n+\t\toid = NULL;\n \t\tmode = 0;\n \t}\n \n@@ -220,7 +221,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \tif (emitthis) {\n \t\tint keep;\n \t\tstruct combine_diff_path *pprev = p;\n-\t\tp = path_appendnew(p, nparent, base, path, pathlen, mode, sha1);\n+\t\tp = path_appendnew(p, nparent, base, path, pathlen, mode, oid ? oid->hash : NULL);\n \n \t\tfor (i = 0; i < nparent; ++i) {\n \t\t\t/*\n@@ -229,7 +230,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \t\t\t */\n \t\t\tint tpi_valid = tp && !(tp[i].entry.mode & S_IFXMIN_NEQ);\n \n-\t\t\tconst unsigned char *sha1_i;\n+\t\t\tconst struct object_id *oid_i;\n \t\t\tunsigned mode_i;\n \n \t\t\tp->parent[i].status =\n@@ -239,16 +240,16 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \t\t\t\t\t\tDIFF_STATUS_ADDED;\n \n \t\t\tif (tpi_valid) {\n-\t\t\t\tsha1_i = tp[i].entry.oid->hash;\n+\t\t\t\toid_i = tp[i].entry.oid;\n \t\t\t\tmode_i = tp[i].entry.mode;\n \t\t\t}\n \t\t\telse {\n-\t\t\t\tsha1_i = NULL;\n+\t\t\t\toid_i = &null_oid;\n \t\t\t\tmode_i = 0;\n \t\t\t}\n \n \t\t\tp->parent[i].mode = mode_i;\n-\t\t\thashcpy(p->parent[i].oid.hash, sha1_i ? sha1_i : null_sha1);\n+\t\t\toidcpy(&p->parent[i].oid, oid_i);\n \t\t}\n \n \t\tkeep = 1;\n@@ -273,21 +274,20 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \t}\n \n \tif (recurse) {\n-\t\tconst unsigned char **parents_sha1;\n+\t\tconst struct object_id **parents_oid;\n \n-\t\tFAST_ARRAY_ALLOC(parents_sha1, nparent);\n+\t\tFAST_ARRAY_ALLOC(parents_oid, nparent);\n \t\tfor (i = 0; i < nparent; ++i) {\n \t\t\t/* same rule as in emitthis */\n \t\t\tint tpi_valid = tp && !(tp[i].entry.mode & S_IFXMIN_NEQ);\n \n-\t\t\tparents_sha1[i] = tpi_valid ? tp[i].entry.oid->hash\n-\t\t\t\t\t\t    : NULL;\n+\t\t\tparents_oid[i] = tpi_valid ? tp[i].entry.oid : NULL;\n \t\t}\n \n \t\tstrbuf_add(base, path, pathlen);\n \t\tstrbuf_addch(base, '/');\n-\t\tp = ll_diff_tree_paths(p, sha1, parents_sha1, nparent, base, opt);\n-\t\tFAST_ARRAY_FREE(parents_sha1, nparent);\n+\t\tp = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt);\n+\t\tFAST_ARRAY_FREE(parents_oid, nparent);\n \t}\n \n \tstrbuf_setlen(base, old_baselen);\n@@ -312,7 +312,7 @@ static void skip_uninteresting(struct tree_desc *t, struct strbuf *base,\n \n \n /*\n- * generate paths for combined diff D(sha1,parents_sha1[])\n+ * generate paths for combined diff D(sha1,parents_oid[])\n  *\n  * Resulting paths are appended to combine_diff_path linked list, and also, are\n  * emitted on the go via opt->pathchange() callback, so it is possible to\n@@ -404,8 +404,8 @@ static inline void update_tp_entries(struct tree_desc *tp, int nparent)\n }\n \n static struct combine_diff_path *ll_diff_tree_paths(\n-\tstruct combine_diff_path *p, const unsigned char *sha1,\n-\tconst unsigned char **parents_sha1, int nparent,\n+\tstruct combine_diff_path *p, const struct object_id *oid,\n+\tconst struct object_id **parents_oid, int nparent,\n \tstruct strbuf *base, struct diff_options *opt)\n {\n \tstruct tree_desc t, *tp;\n@@ -422,8 +422,8 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t *   diff_tree_oid(parent, commit) )\n \t */\n \tfor (i = 0; i < nparent; ++i)\n-\t\ttptree[i] = fill_tree_descriptor(&tp[i], parents_sha1[i]);\n-\tttree = fill_tree_descriptor(&t, sha1);\n+\t\ttptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]->hash);\n+\tttree = fill_tree_descriptor(&t, oid->hash);\n \n \t/* Enable recursion indefinitely */\n \topt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);\n@@ -548,11 +548,11 @@ static struct combine_diff_path *ll_diff_tree_paths(\n }\n \n struct combine_diff_path *diff_tree_paths(\n-\tstruct combine_diff_path *p, const unsigned char *sha1,\n-\tconst unsigned char **parents_sha1, int nparent,\n+\tstruct combine_diff_path *p, const struct object_id *oid,\n+\tconst struct object_id **parents_oid, int nparent,\n \tstruct strbuf *base, struct diff_options *opt)\n {\n-\tp = ll_diff_tree_paths(p, sha1, parents_sha1, nparent, base, opt);\n+\tp = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt);\n \n \t/*\n \t * free pre-allocated last element, if any\n@@ -617,7 +617,7 @@ static void try_to_follow_renames(const struct object_id *old_oid,\n \tdiff_opts.break_opt = opt->break_opt;\n \tdiff_opts.rename_score = opt->rename_score;\n \tdiff_setup_done(&diff_opts);\n-\tll_diff_tree_sha1(old_oid->hash, new_oid->hash, base, &diff_opts);\n+\tll_diff_tree_oid(old_oid, new_oid, base, &diff_opts);\n \tdiffcore_std(&diff_opts);\n \tclear_pathspec(&diff_opts.pathspec);\n \n@@ -676,15 +676,16 @@ static void try_to_follow_renames(const struct object_id *old_oid,\n \tq->nr = 1;\n }\n \n-static int ll_diff_tree_sha1(const unsigned char *old, const unsigned char *new,\n-\t\t\t     struct strbuf *base, struct diff_options *opt)\n+static int ll_diff_tree_oid(const struct object_id *old_oid,\n+\t\t\t    const struct object_id *new_oid,\n+\t\t\t    struct strbuf *base, struct diff_options *opt)\n {\n \tstruct combine_diff_path phead, *p;\n \tpathchange_fn_t pathchange_old = opt->pathchange;\n \n \tphead.next = NULL;\n \topt->pathchange = emit_diff_first_parent_only;\n-\tdiff_tree_paths(&phead, new, &old, 1, base, opt);\n+\tdiff_tree_paths(&phead, new_oid, &old_oid, 1, base, opt);\n \n \tfor (p = phead.next; p;) {\n \t\tstruct combine_diff_path *pprev = p;\n@@ -706,7 +707,7 @@ int diff_tree_oid(const struct object_id *old_oid,\n \tstrbuf_init(&base, PATH_MAX);\n \tstrbuf_addstr(&base, base_str);\n \n-\tretval = ll_diff_tree_sha1(old_oid->hash, new_oid->hash, &base, opt);\n+\tretval = ll_diff_tree_oid(old_oid, new_oid, &base, opt);\n \tif (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())\n \t\ttry_to_follow_renames(old_oid, new_oid, &base, opt);\n \n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321054","messageId":"20170530173109.54904-27-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 26/33] notes-merge: convert write_note_to_worktree to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:02Z","receivedAt":"2017-05-30T17:32:11Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n notes-merge.c | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 962e9b1bc..7d88857a8 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -292,11 +292,11 @@ static void check_notes_merge_worktree(struct notes_merge_options *o)\n \t\t    git_path(NOTES_MERGE_WORKTREE));\n }\n \n-static void write_buf_to_worktree(const unsigned char *obj,\n+static void write_buf_to_worktree(const struct object_id *obj,\n \t\t\t\t  const char *buf, unsigned long size)\n {\n \tint fd;\n-\tchar *path = git_pathdup(NOTES_MERGE_WORKTREE \"/%s\", sha1_to_hex(obj));\n+\tchar *path = git_pathdup(NOTES_MERGE_WORKTREE \"/%s\", oid_to_hex(obj));\n \tif (safe_create_leading_directories_const(path))\n \t\tdie_errno(\"unable to create directory for '%s'\", path);\n \n@@ -320,19 +320,19 @@ static void write_buf_to_worktree(const unsigned char *obj,\n \tfree(path);\n }\n \n-static void write_note_to_worktree(const unsigned char *obj,\n-\t\t\t\t   const unsigned char *note)\n+static void write_note_to_worktree(const struct object_id *obj,\n+\t\t\t\t   const struct object_id *note)\n {\n \tenum object_type type;\n \tunsigned long size;\n-\tvoid *buf = read_sha1_file(note, &type, &size);\n+\tvoid *buf = read_sha1_file(note->hash, &type, &size);\n \n \tif (!buf)\n \t\tdie(\"cannot read note %s for object %s\",\n-\t\t    sha1_to_hex(note), sha1_to_hex(obj));\n+\t\t    oid_to_hex(note), oid_to_hex(obj));\n \tif (type != OBJ_BLOB)\n \t\tdie(\"blob expected in note %s for object %s\",\n-\t\t    sha1_to_hex(note), sha1_to_hex(obj));\n+\t\t    oid_to_hex(note), oid_to_hex(obj));\n \twrite_buf_to_worktree(obj, buf, size);\n \tfree(buf);\n }\n@@ -358,7 +358,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,\n \tif ((status < 0) || !result_buf.ptr)\n \t\tdie(\"Failed to execute internal merge\");\n \n-\twrite_buf_to_worktree(p->obj.hash, result_buf.ptr, result_buf.size);\n+\twrite_buf_to_worktree(&p->obj, result_buf.ptr, result_buf.size);\n \tfree(result_buf.ptr);\n \n \treturn status;\n@@ -393,7 +393,7 @@ static int merge_one_change_manual(struct notes_merge_options *o,\n \t\t\t\t\"deleted in %s and modified in %s. Version from %s \"\n \t\t\t\t\"left in tree.\\n\",\n \t\t\t\toid_to_hex(&p->obj), lref, rref, rref);\n-\t\twrite_note_to_worktree(p->obj.hash, p->remote.hash);\n+\t\twrite_note_to_worktree(&p->obj, &p->remote);\n \t} else if (is_null_oid(&p->remote)) {\n \t\t/* D/F conflict, checkout p->local */\n \t\tassert(!is_null_oid(&p->local));\n@@ -402,7 +402,7 @@ static int merge_one_change_manual(struct notes_merge_options *o,\n \t\t\t\t\"deleted in %s and modified in %s. Version from %s \"\n \t\t\t\t\"left in tree.\\n\",\n \t\t\t\toid_to_hex(&p->obj), rref, lref, lref);\n-\t\twrite_note_to_worktree(p->obj.hash, p->local.hash);\n+\t\twrite_note_to_worktree(&p->obj, &p->local);\n \t} else {\n \t\t/* \"regular\" conflict, checkout result of ll_merge() */\n \t\tconst char *reason = \"content\";\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321055","messageId":"20170530173109.54904-30-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 29/33] tree-diff: convert try_to_follow_renames to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:05Z","receivedAt":"2017-05-30T17:32:13Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n tree-diff.c | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/tree-diff.c b/tree-diff.c\nindex fc020d76d..29e3f6144 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -577,7 +577,9 @@ static inline int diff_might_be_rename(void)\n \t\t!DIFF_FILE_VALID(diff_queued_diff.queue[0]->one);\n }\n \n-static void try_to_follow_renames(const unsigned char *old, const unsigned char *new, struct strbuf *base, struct diff_options *opt)\n+static void try_to_follow_renames(const struct object_id *old_oid,\n+\t\t\t\t  const struct object_id *new_oid,\n+\t\t\t\t  struct strbuf *base, struct diff_options *opt)\n {\n \tstruct diff_options diff_opts;\n \tstruct diff_queue_struct *q = &diff_queued_diff;\n@@ -615,7 +617,7 @@ static void try_to_follow_renames(const unsigned char *old, const unsigned char\n \tdiff_opts.break_opt = opt->break_opt;\n \tdiff_opts.rename_score = opt->rename_score;\n \tdiff_setup_done(&diff_opts);\n-\tll_diff_tree_sha1(old, new, base, &diff_opts);\n+\tll_diff_tree_sha1(old_oid->hash, new_oid->hash, base, &diff_opts);\n \tdiffcore_std(&diff_opts);\n \tclear_pathspec(&diff_opts.pathspec);\n \n@@ -706,7 +708,7 @@ int diff_tree_oid(const struct object_id *old_oid,\n \n \tretval = ll_diff_tree_sha1(old_oid->hash, new_oid->hash, &base, opt);\n \tif (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())\n-\t\ttry_to_follow_renames(old_oid->hash, new_oid->hash, &base, opt);\n+\t\ttry_to_follow_renames(old_oid, new_oid, &base, opt);\n \n \tstrbuf_release(&base);\n \n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321056","messageId":"20170530173109.54904-21-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 20/33] combine-diff: convert find_paths_* to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:56Z","receivedAt":"2017-05-30T17:32:14Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Convert find_paths_generic and find_paths_multitree to use struct\nobject_id.\n\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n combine-diff.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 84981df75..c82364510 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1311,7 +1311,7 @@ static const char *path_path(void *obj)\n \n \n /* find set of paths that every parent touches */\n-static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,\n+static struct combine_diff_path *find_paths_generic(const struct object_id *oid,\n \tconst struct oid_array *parents, struct diff_options *opt)\n {\n \tstruct combine_diff_path *paths = NULL;\n@@ -1336,7 +1336,7 @@ static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,\n \t\t\topt->output_format = stat_opt;\n \t\telse\n \t\t\topt->output_format = DIFF_FORMAT_NO_OUTPUT;\n-\t\tdiff_tree_sha1(parents->oid[i].hash, sha1, \"\", opt);\n+\t\tdiff_tree_sha1(parents->oid[i].hash, oid->hash, \"\", opt);\n \t\tdiffcore_std(opt);\n \t\tpaths = intersect_paths(paths, i, num_parent);\n \n@@ -1360,7 +1360,7 @@ static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,\n  * rename/copy detection, etc, comparing all trees simultaneously (= faster).\n  */\n static struct combine_diff_path *find_paths_multitree(\n-\tconst unsigned char *sha1, const struct oid_array *parents,\n+\tconst struct object_id *oid, const struct oid_array *parents,\n \tstruct diff_options *opt)\n {\n \tint i, nparent = parents->nr;\n@@ -1376,7 +1376,7 @@ static struct combine_diff_path *find_paths_multitree(\n \tpaths_head.next = NULL;\n \n \tstrbuf_init(&base, PATH_MAX);\n-\tdiff_tree_paths(&paths_head, sha1, parents_sha1, nparent, &base, opt);\n+\tdiff_tree_paths(&paths_head, oid->hash, parents_sha1, nparent, &base, opt);\n \n \tstrbuf_release(&base);\n \tfree(parents_sha1);\n@@ -1448,11 +1448,11 @@ void diff_tree_combined(const struct object_id *oid,\n \t\t * diff(sha1,parent_i) for all i to do the job, specifically\n \t\t * for parent0.\n \t\t */\n-\t\tpaths = find_paths_generic(oid->hash, parents, &diffopts);\n+\t\tpaths = find_paths_generic(oid, parents, &diffopts);\n \t}\n \telse {\n \t\tint stat_opt;\n-\t\tpaths = find_paths_multitree(oid->hash, parents, &diffopts);\n+\t\tpaths = find_paths_multitree(oid, parents, &diffopts);\n \n \t\t/*\n \t\t * show stat against the first parent even\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321057","messageId":"20170530173109.54904-24-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 23/33] notes-merge: convert merge_from_diffs to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:59Z","receivedAt":"2017-05-30T17:32:17Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n notes-merge.c | 31 ++++++++++++++++---------------\n 1 file changed, 16 insertions(+), 15 deletions(-)\n\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 9dbf7f6a3..be78f1954 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -114,8 +114,8 @@ static struct object_id uninitialized = {\n };\n \n static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n-\t\t\t\t\t\t const unsigned char *base,\n-\t\t\t\t\t\t const unsigned char *remote,\n+\t\t\t\t\t\t const struct object_id *base,\n+\t\t\t\t\t\t const struct object_id *remote,\n \t\t\t\t\t\t int *num_changes)\n {\n \tstruct diff_options opt;\n@@ -123,13 +123,13 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \tint i, len = 0;\n \n \ttrace_printf(\"\\tdiff_tree_remote(base = %.7s, remote = %.7s)\\n\",\n-\t       sha1_to_hex(base), sha1_to_hex(remote));\n+\t       oid_to_hex(base), oid_to_hex(remote));\n \n \tdiff_setup(&opt);\n \tDIFF_OPT_SET(&opt, RECURSIVE);\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n-\tdiff_tree_sha1(base, remote, \"\", &opt);\n+\tdiff_tree_sha1(base->hash, remote->hash, \"\", &opt);\n \tdiffcore_std(&opt);\n \n \tchanges = xcalloc(diff_queued_diff.nr, sizeof(struct notes_merge_pair));\n@@ -179,20 +179,20 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \n static void diff_tree_local(struct notes_merge_options *o,\n \t\t\t    struct notes_merge_pair *changes, int len,\n-\t\t\t    const unsigned char *base,\n-\t\t\t    const unsigned char *local)\n+\t\t\t    const struct object_id *base,\n+\t\t\t    const struct object_id *local)\n {\n \tstruct diff_options opt;\n \tint i;\n \n \ttrace_printf(\"\\tdiff_tree_local(len = %i, base = %.7s, local = %.7s)\\n\",\n-\t       len, sha1_to_hex(base), sha1_to_hex(local));\n+\t       len, oid_to_hex(base), oid_to_hex(local));\n \n \tdiff_setup(&opt);\n \tDIFF_OPT_SET(&opt, RECURSIVE);\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n-\tdiff_tree_sha1(base, local, \"\", &opt);\n+\tdiff_tree_sha1(base->hash, local->hash, \"\", &opt);\n \tdiffcore_std(&opt);\n \n \tfor (i = 0; i < diff_queued_diff.nr; i++) {\n@@ -505,16 +505,17 @@ static int merge_changes(struct notes_merge_options *o,\n }\n \n static int merge_from_diffs(struct notes_merge_options *o,\n-\t\t\t    const unsigned char *base,\n-\t\t\t    const unsigned char *local,\n-\t\t\t    const unsigned char *remote, struct notes_tree *t)\n+\t\t\t    const struct object_id *base,\n+\t\t\t    const struct object_id *local,\n+\t\t\t    const struct object_id *remote,\n+\t\t\t    struct notes_tree *t)\n {\n \tstruct notes_merge_pair *changes;\n \tint num_changes, conflicts;\n \n \ttrace_printf(\"\\tmerge_from_diffs(base = %.7s, local = %.7s, \"\n-\t       \"remote = %.7s)\\n\", sha1_to_hex(base), sha1_to_hex(local),\n-\t       sha1_to_hex(remote));\n+\t       \"remote = %.7s)\\n\", oid_to_hex(base), oid_to_hex(local),\n+\t       oid_to_hex(remote));\n \n \tchanges = diff_tree_remote(o, base, remote, &num_changes);\n \tdiff_tree_local(o, changes, num_changes, base, local);\n@@ -636,8 +637,8 @@ int notes_merge(struct notes_merge_options *o,\n \t\tgoto found_result;\n \t}\n \n-\tresult = merge_from_diffs(o, base_tree_oid->hash, local->tree->object.oid.hash,\n-\t\t\t\t  remote->tree->object.oid.hash, local_tree);\n+\tresult = merge_from_diffs(o, base_tree_oid, &local->tree->object.oid,\n+\t\t\t\t  &remote->tree->object.oid, local_tree);\n \n \tif (result != 0) { /* non-trivial merge (with or without conflicts) */\n \t\t/* Commit (partial) result */\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321058","messageId":"20170530173109.54904-23-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 22/33] notes-merge: convert notes_merge* to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:58Z","receivedAt":"2017-05-30T17:32:22Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Convert notes_merge and notes_merge_commit to use struct object_id.\n\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/notes.c |  6 +++---\n notes-merge.c   | 58 ++++++++++++++++++++++++++++-----------------------------\n notes-merge.h   | 12 ++++++------\n 3 files changed, 38 insertions(+), 38 deletions(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex b13fc8789..2ebc2b7c4 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -724,7 +724,7 @@ static int merge_commit(struct notes_merge_options *o)\n \tif (!o->local_ref)\n \t\tdie(_(\"failed to resolve NOTES_MERGE_REF\"));\n \n-\tif (notes_merge_commit(o, t, partial, oid.hash))\n+\tif (notes_merge_commit(o, t, partial, &oid))\n \t\tdie(_(\"failed to finalize notes merge\"));\n \n \t/* Reuse existing commit message in reflog message */\n@@ -842,9 +842,9 @@ static int merge(int argc, const char **argv, const char *prefix)\n \t\t    remote_ref.buf, default_notes_ref());\n \tstrbuf_add(&(o.commit_msg), msg.buf + 7, msg.len - 7); /* skip \"notes: \" */\n \n-\tresult = notes_merge(&o, t, result_oid.hash);\n+\tresult = notes_merge(&o, t, &result_oid);\n \n-\tif (result >= 0) /* Merge resulted (trivially) in result_sha1 */\n+\tif (result >= 0) /* Merge resulted (trivially) in result_oid */\n \t\t/* Update default notes ref with new commit */\n \t\tupdate_ref(msg.buf, default_notes_ref(), result_oid.hash, NULL,\n \t\t\t   0, UPDATE_REFS_DIE_ON_ERR);\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 9a1a49506..9dbf7f6a3 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -533,17 +533,17 @@ static int merge_from_diffs(struct notes_merge_options *o,\n \n int notes_merge(struct notes_merge_options *o,\n \t\tstruct notes_tree *local_tree,\n-\t\tunsigned char *result_sha1)\n+\t\tstruct object_id *result_oid)\n {\n \tstruct object_id local_oid, remote_oid;\n \tstruct commit *local, *remote;\n \tstruct commit_list *bases = NULL;\n-\tconst unsigned char *base_sha1, *base_tree_sha1;\n+\tconst struct object_id *base_oid, *base_tree_oid;\n \tint result = 0;\n \n \tassert(o->local_ref && o->remote_ref);\n \tassert(!strcmp(o->local_ref, local_tree->ref));\n-\thashclr(result_sha1);\n+\toidclr(result_oid);\n \n \ttrace_printf(\"notes_merge(o->local_ref = %s, o->remote_ref = %s)\\n\",\n \t       o->local_ref, o->remote_ref);\n@@ -553,16 +553,16 @@ int notes_merge(struct notes_merge_options *o,\n \t\tdie(\"Failed to resolve local notes ref '%s'\", o->local_ref);\n \telse if (!check_refname_format(o->local_ref, 0) &&\n \t\tis_null_oid(&local_oid))\n-\t\tlocal = NULL; /* local_sha1 == null_sha1 indicates unborn ref */\n+\t\tlocal = NULL; /* local_oid == null_oid indicates unborn ref */\n \telse if (!(local = lookup_commit_reference(&local_oid)))\n \t\tdie(\"Could not parse local commit %s (%s)\",\n \t\t    oid_to_hex(&local_oid), o->local_ref);\n \ttrace_printf(\"\\tlocal commit: %.7s\\n\", oid_to_hex(&local_oid));\n \n-\t/* Dereference o->remote_ref into remote_sha1 */\n+\t/* Dereference o->remote_ref into remote_oid */\n \tif (get_oid(o->remote_ref, &remote_oid)) {\n \t\t/*\n-\t\t * Failed to get remote_sha1. If o->remote_ref looks like an\n+\t\t * Failed to get remote_oid. If o->remote_ref looks like an\n \t\t * unborn ref, perform the merge using an empty notes tree.\n \t\t */\n \t\tif (!check_refname_format(o->remote_ref, 0)) {\n@@ -583,12 +583,12 @@ int notes_merge(struct notes_merge_options *o,\n \t\t    \"(%s)\", o->remote_ref, o->local_ref);\n \tif (!local) {\n \t\t/* result == remote commit */\n-\t\thashcpy(result_sha1, remote_oid.hash);\n+\t\toidcpy(result_oid, &remote_oid);\n \t\tgoto found_result;\n \t}\n \tif (!remote) {\n \t\t/* result == local commit */\n-\t\thashcpy(result_sha1, local_oid.hash);\n+\t\toidcpy(result_oid, &local_oid);\n \t\tgoto found_result;\n \t}\n \tassert(local && remote);\n@@ -596,47 +596,47 @@ int notes_merge(struct notes_merge_options *o,\n \t/* Find merge bases */\n \tbases = get_merge_bases(local, remote);\n \tif (!bases) {\n-\t\tbase_sha1 = null_sha1;\n-\t\tbase_tree_sha1 = EMPTY_TREE_SHA1_BIN;\n+\t\tbase_oid = &null_oid;\n+\t\tbase_tree_oid = &empty_tree_oid;\n \t\tif (o->verbosity >= 4)\n \t\t\tprintf(\"No merge base found; doing history-less merge\\n\");\n \t} else if (!bases->next) {\n-\t\tbase_sha1 = bases->item->object.oid.hash;\n-\t\tbase_tree_sha1 = bases->item->tree->object.oid.hash;\n+\t\tbase_oid = &bases->item->object.oid;\n+\t\tbase_tree_oid = &bases->item->tree->object.oid;\n \t\tif (o->verbosity >= 4)\n \t\t\tprintf(\"One merge base found (%.7s)\\n\",\n-\t\t\t\tsha1_to_hex(base_sha1));\n+\t\t\t       oid_to_hex(base_oid));\n \t} else {\n \t\t/* TODO: How to handle multiple merge-bases? */\n-\t\tbase_sha1 = bases->item->object.oid.hash;\n-\t\tbase_tree_sha1 = bases->item->tree->object.oid.hash;\n+\t\tbase_oid = &bases->item->object.oid;\n+\t\tbase_tree_oid = &bases->item->tree->object.oid;\n \t\tif (o->verbosity >= 3)\n \t\t\tprintf(\"Multiple merge bases found. Using the first \"\n-\t\t\t\t\"(%.7s)\\n\", sha1_to_hex(base_sha1));\n+\t\t\t\t\"(%.7s)\\n\", oid_to_hex(base_oid));\n \t}\n \n \tif (o->verbosity >= 4)\n \t\tprintf(\"Merging remote commit %.7s into local commit %.7s with \"\n \t\t\t\"merge-base %.7s\\n\", oid_to_hex(&remote->object.oid),\n \t\t\toid_to_hex(&local->object.oid),\n-\t\t\tsha1_to_hex(base_sha1));\n+\t\t\toid_to_hex(base_oid));\n \n-\tif (!hashcmp(remote->object.oid.hash, base_sha1)) {\n+\tif (!oidcmp(&remote->object.oid, base_oid)) {\n \t\t/* Already merged; result == local commit */\n \t\tif (o->verbosity >= 2)\n \t\t\tprintf(\"Already up-to-date!\\n\");\n-\t\thashcpy(result_sha1, local->object.oid.hash);\n+\t\toidcpy(result_oid, &local->object.oid);\n \t\tgoto found_result;\n \t}\n-\tif (!hashcmp(local->object.oid.hash, base_sha1)) {\n+\tif (!oidcmp(&local->object.oid, base_oid)) {\n \t\t/* Fast-forward; result == remote commit */\n \t\tif (o->verbosity >= 2)\n \t\t\tprintf(\"Fast-forward\\n\");\n-\t\thashcpy(result_sha1, remote->object.oid.hash);\n+\t\toidcpy(result_oid, &remote->object.oid);\n \t\tgoto found_result;\n \t}\n \n-\tresult = merge_from_diffs(o, base_tree_sha1, local->tree->object.oid.hash,\n+\tresult = merge_from_diffs(o, base_tree_oid->hash, local->tree->object.oid.hash,\n \t\t\t\t  remote->tree->object.oid.hash, local_tree);\n \n \tif (result != 0) { /* non-trivial merge (with or without conflicts) */\n@@ -646,28 +646,28 @@ int notes_merge(struct notes_merge_options *o,\n \t\tcommit_list_insert(local, &parents);\n \t\tcreate_notes_commit(local_tree, parents,\n \t\t\t\t    o->commit_msg.buf, o->commit_msg.len,\n-\t\t\t\t    result_sha1);\n+\t\t\t\t    result_oid->hash);\n \t}\n \n found_result:\n \tfree_commit_list(bases);\n \tstrbuf_release(&(o->commit_msg));\n-\ttrace_printf(\"notes_merge(): result = %i, result_sha1 = %.7s\\n\",\n-\t       result, sha1_to_hex(result_sha1));\n+\ttrace_printf(\"notes_merge(): result = %i, result_oid = %.7s\\n\",\n+\t       result, oid_to_hex(result_oid));\n \treturn result;\n }\n \n int notes_merge_commit(struct notes_merge_options *o,\n \t\t       struct notes_tree *partial_tree,\n \t\t       struct commit *partial_commit,\n-\t\t       unsigned char *result_sha1)\n+\t\t       struct object_id *result_oid)\n {\n \t/*\n \t * Iterate through files in .git/NOTES_MERGE_WORKTREE and add all\n \t * found notes to 'partial_tree'. Write the updated notes tree to\n \t * the DB, and commit the resulting tree object while reusing the\n \t * commit message and parents from 'partial_commit'.\n-\t * Finally store the new commit object SHA1 into 'result_sha1'.\n+\t * Finally store the new commit object OID into 'result_oid'.\n \t */\n \tDIR *dir;\n \tstruct dirent *e;\n@@ -721,11 +721,11 @@ int notes_merge_commit(struct notes_merge_options *o,\n \t}\n \n \tcreate_notes_commit(partial_tree, partial_commit->parents,\n-\t\t\t    msg, strlen(msg), result_sha1);\n+\t\t\t    msg, strlen(msg), result_oid->hash);\n \tunuse_commit_buffer(partial_commit, buffer);\n \tif (o->verbosity >= 4)\n \t\tprintf(\"Finalized notes merge commit: %s\\n\",\n-\t\t\tsha1_to_hex(result_sha1));\n+\t\t\toid_to_hex(result_oid));\n \tstrbuf_release(&path);\n \tclosedir(dir);\n \treturn 0;\ndiff --git a/notes-merge.h b/notes-merge.h\nindex 0d890563b..eaa8e3b86 100644\n--- a/notes-merge.h\n+++ b/notes-merge.h\n@@ -33,15 +33,15 @@ void init_notes_merge_options(struct notes_merge_options *o);\n  *\n  * 1. The merge trivially results in an existing commit (e.g. fast-forward or\n  *    already-up-to-date). 'local_tree' is untouched, the SHA1 of the result\n- *    is written into 'result_sha1' and 0 is returned.\n+ *    is written into 'result_oid' and 0 is returned.\n  * 2. The merge successfully completes, producing a merge commit. local_tree\n  *    contains the updated notes tree, the SHA1 of the resulting commit is\n- *    written into 'result_sha1', and 1 is returned.\n+ *    written into 'result_oid', and 1 is returned.\n  * 3. The merge results in conflicts. This is similar to #2 in that the\n  *    partial merge result (i.e. merge result minus the unmerged entries)\n  *    are stored in 'local_tree', and the SHA1 or the resulting commit\n  *    (to be amended when the conflicts have been resolved) is written into\n- *    'result_sha1'. The unmerged entries are written into the\n+ *    'result_oid'. The unmerged entries are written into the\n  *    .git/NOTES_MERGE_WORKTREE directory with conflict markers.\n  *    -1 is returned.\n  *\n@@ -52,7 +52,7 @@ void init_notes_merge_options(struct notes_merge_options *o);\n  */\n int notes_merge(struct notes_merge_options *o,\n \t\tstruct notes_tree *local_tree,\n-\t\tunsigned char *result_sha1);\n+\t\tstruct object_id *result_oid);\n \n /*\n  * Finalize conflict resolution from an earlier notes_merge()\n@@ -63,12 +63,12 @@ int notes_merge(struct notes_merge_options *o,\n  *\n  * This function will add the (now resolved) notes in .git/NOTES_MERGE_WORKTREE\n  * to 'partial_tree', and create a final notes merge commit, the SHA1 of which\n- * will be stored in 'result_sha1'.\n+ * will be stored in 'result_oid'.\n  */\n int notes_merge_commit(struct notes_merge_options *o,\n \t\t       struct notes_tree *partial_tree,\n \t\t       struct commit *partial_commit,\n-\t\t       unsigned char *result_sha1);\n+\t\t       struct object_id *result_oid);\n \n /*\n  * Abort conflict resolution from an earlier notes_merge()\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321059","messageId":"20170530173109.54904-34-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 33/33] diff: rename diff_fill_sha1_info to diff_fill_oid_info","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:09Z","receivedAt":"2017-05-30T17:32:37Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n diff.c | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex dd325e616..c758a0d73 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3239,7 +3239,7 @@ static void run_diff_cmd(const char *pgm,\n \t\tfprintf(o->file, \"* Unmerged path %s\\n\", name);\n }\n \n-static void diff_fill_sha1_info(struct diff_filespec *one)\n+static void diff_fill_oid_info(struct diff_filespec *one)\n {\n \tif (DIFF_FILE_VALID(one)) {\n \t\tif (!one->oid_valid) {\n@@ -3298,8 +3298,8 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)\n \t\treturn;\n \t}\n \n-\tdiff_fill_sha1_info(one);\n-\tdiff_fill_sha1_info(two);\n+\tdiff_fill_oid_info(one);\n+\tdiff_fill_oid_info(two);\n \n \tif (!pgm &&\n \t    DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two) &&\n@@ -3344,8 +3344,8 @@ static void run_diffstat(struct diff_filepair *p, struct diff_options *o,\n \tif (o->prefix_length)\n \t\tstrip_prefix(o->prefix_length, &name, &other);\n \n-\tdiff_fill_sha1_info(p->one);\n-\tdiff_fill_sha1_info(p->two);\n+\tdiff_fill_oid_info(p->one);\n+\tdiff_fill_oid_info(p->two);\n \n \tbuiltin_diffstat(name, other, p->one, p->two, diffstat, o, p);\n }\n@@ -3368,8 +3368,8 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)\n \tif (o->prefix_length)\n \t\tstrip_prefix(o->prefix_length, &name, &other);\n \n-\tdiff_fill_sha1_info(p->one);\n-\tdiff_fill_sha1_info(p->two);\n+\tdiff_fill_oid_info(p->one);\n+\tdiff_fill_oid_info(p->two);\n \n \tbuiltin_checkdiff(name, other, attr_path, p->one, p->two, o);\n }\n@@ -4616,8 +4616,8 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid\n \t\tif (DIFF_PAIR_UNMERGED(p))\n \t\t\tcontinue;\n \n-\t\tdiff_fill_sha1_info(p->one);\n-\t\tdiff_fill_sha1_info(p->two);\n+\t\tdiff_fill_oid_info(p->one);\n+\t\tdiff_fill_oid_info(p->two);\n \n \t\tlen1 = remove_space(p->one->path, strlen(p->one->path));\n \t\tlen2 = remove_space(p->two->path, strlen(p->two->path));\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321060","messageId":"20170530173109.54904-32-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 31/33] tree-diff: convert path_appendnew to object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:07Z","receivedAt":"2017-05-30T17:32:38Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n tree-diff.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 6a960f569..467e38172 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -132,7 +132,7 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_\n  */\n static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,\n \tint nparent, const struct strbuf *base, const char *path, int pathlen,\n-\tunsigned mode, const unsigned char *sha1)\n+\tunsigned mode, const struct object_id *oid)\n {\n \tstruct combine_diff_path *p;\n \tsize_t len = st_add(base->len, pathlen);\n@@ -162,7 +162,7 @@ static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,\n \tmemcpy(p->path + base->len, path, pathlen);\n \tp->path[len] = 0;\n \tp->mode = mode;\n-\thashcpy(p->oid.hash, sha1 ? sha1 : null_sha1);\n+\toidcpy(&p->oid, oid ? oid : &null_oid);\n \n \treturn p;\n }\n@@ -221,7 +221,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \tif (emitthis) {\n \t\tint keep;\n \t\tstruct combine_diff_path *pprev = p;\n-\t\tp = path_appendnew(p, nparent, base, path, pathlen, mode, oid ? oid->hash : NULL);\n+\t\tp = path_appendnew(p, nparent, base, path, pathlen, mode, oid);\n \n \t\tfor (i = 0; i < nparent; ++i) {\n \t\t\t/*\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321061","messageId":"20170530173109.54904-28-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 27/33] diff-tree: convert diff_tree_sha1 to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:03Z","receivedAt":"2017-05-30T17:32:44Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/blame.c       | 20 ++++++++++----------\n builtin/diff-tree.c   |  8 +++-----\n builtin/diff.c        |  2 +-\n builtin/fast-export.c |  4 ++--\n builtin/log.c         |  6 +++---\n builtin/merge.c       |  2 +-\n combine-diff.c        |  4 ++--\n diff.h                |  5 +++--\n line-log.c            |  4 ++--\n log-tree.c            |  8 ++++----\n merge-recursive.c     |  2 +-\n notes-merge.c         |  4 ++--\n patch-ids.c           |  4 ++--\n revision.c            |  4 ++--\n sequencer.c           |  4 ++--\n tree-diff.c           | 12 +++++++-----\n 16 files changed, 47 insertions(+), 46 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 5ad435380..7645aa991 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -565,9 +565,9 @@ static struct origin *find_origin(struct scoreboard *sb,\n \tif (is_null_oid(&origin->commit->object.oid))\n \t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\n \telse\n-\t\tdiff_tree_sha1(parent->tree->object.oid.hash,\n-\t\t\t       origin->commit->tree->object.oid.hash,\n-\t\t\t       \"\", &diff_opts);\n+\t\tdiff_tree_oid(&parent->tree->object.oid,\n+\t\t\t      &origin->commit->tree->object.oid,\n+\t\t\t      \"\", &diff_opts);\n \tdiffcore_std(&diff_opts);\n \n \tif (!diff_queued_diff.nr) {\n@@ -635,9 +635,9 @@ static struct origin *find_rename(struct scoreboard *sb,\n \tif (is_null_oid(&origin->commit->object.oid))\n \t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\n \telse\n-\t\tdiff_tree_sha1(parent->tree->object.oid.hash,\n-\t\t\t       origin->commit->tree->object.oid.hash,\n-\t\t\t       \"\", &diff_opts);\n+\t\tdiff_tree_oid(&parent->tree->object.oid,\n+\t\t\t      &origin->commit->tree->object.oid,\n+\t\t\t      \"\", &diff_opts);\n \tdiffcore_std(&diff_opts);\n \n \tfor (i = 0; i < diff_queued_diff.nr; i++) {\n@@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct scoreboard *sb,\n \t/* Try \"find copies harder\" on new path if requested;\n \t * we do not want to use diffcore_rename() actually to\n \t * match things up; find_copies_harder is set only to\n-\t * force diff_tree_sha1() to feed all filepairs to diff_queue,\n+\t * force diff_tree_oid() to feed all filepairs to diff_queue,\n \t * and this code needs to be after diff_setup_done(), which\n \t * usually makes find-copies-harder imply copy detection.\n \t */\n@@ -1274,9 +1274,9 @@ static void find_copy_in_parent(struct scoreboard *sb,\n \tif (is_null_oid(&target->commit->object.oid))\n \t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\n \telse\n-\t\tdiff_tree_sha1(parent->tree->object.oid.hash,\n-\t\t\t       target->commit->tree->object.oid.hash,\n-\t\t\t       \"\", &diff_opts);\n+\t\tdiff_tree_oid(&parent->tree->object.oid,\n+\t\t\t      &target->commit->tree->object.oid,\n+\t\t\t      \"\", &diff_opts);\n \n \tif (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))\n \t\tdiffcore_std(&diff_opts);\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex 5ea1c1431..aef167619 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -49,8 +49,8 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)\n \t\treturn -1;\n \tprintf(\"%s %s\\n\", oid_to_hex(&tree1->object.oid),\n \t\t\t  oid_to_hex(&tree2->object.oid));\n-\tdiff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,\n-\t\t       \"\", &log_tree_opt.diffopt);\n+\tdiff_tree_oid(&tree1->object.oid, &tree2->object.oid,\n+\t\t      \"\", &log_tree_opt.diffopt);\n \tlog_tree_diff_flush(&log_tree_opt);\n \treturn 0;\n }\n@@ -148,9 +148,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n \t\tif (tree2->flags & UNINTERESTING) {\n \t\t\tSWAP(tree2, tree1);\n \t\t}\n-\t\tdiff_tree_sha1(tree1->oid.hash,\n-\t\t\t       tree2->oid.hash,\n-\t\t\t       \"\", &opt->diffopt);\n+\t\tdiff_tree_oid(&tree1->oid, &tree2->oid, \"\", &opt->diffopt);\n \t\tlog_tree_diff_flush(opt);\n \t\tbreak;\n \t}\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 73b4ff3db..4c6a1a962 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -174,7 +174,7 @@ static int builtin_diff_tree(struct rev_info *revs,\n \t\tswap = 1;\n \toid[swap] = &ent0->item->oid;\n \toid[1 - swap] = &ent1->item->oid;\n-\tdiff_tree_sha1(oid[0]->hash, oid[1]->hash, \"\", &revs->diffopt);\n+\tdiff_tree_oid(oid[0], oid[1], \"\", &revs->diffopt);\n \tlog_tree_diff_flush(revs);\n \treturn 0;\n }\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex e242726f0..d57f36c43 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -562,8 +562,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)\n \t    get_object_mark(&commit->parents->item->object) != 0 &&\n \t    !full_tree) {\n \t\tparse_commit_or_die(commit->parents->item);\n-\t\tdiff_tree_sha1(commit->parents->item->tree->object.oid.hash,\n-\t\t\t       commit->tree->object.oid.hash, \"\", &rev->diffopt);\n+\t\tdiff_tree_oid(&commit->parents->item->tree->object.oid,\n+\t\t\t      &commit->tree->object.oid, \"\", &rev->diffopt);\n \t}\n \telse\n \t\tdiff_root_tree_oid(&commit->tree->object.oid,\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 6bdba3444..4ef522ee5 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1043,9 +1043,9 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,\n \n \tdiff_setup_done(&opts);\n \n-\tdiff_tree_sha1(origin->tree->object.oid.hash,\n-\t\t       head->tree->object.oid.hash,\n-\t\t       \"\", &opts);\n+\tdiff_tree_oid(&origin->tree->object.oid,\n+\t\t      &head->tree->object.oid,\n+\t\t      \"\", &opts);\n \tdiffcore_std(&opts);\n \tdiff_flush(&opts);\n \ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex a4a098f40..afaed6a2c 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -415,7 +415,7 @@ static void finish(struct commit *head_commit,\n \t\t\tDIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;\n \t\topts.detect_rename = DIFF_DETECT_RENAME;\n \t\tdiff_setup_done(&opts);\n-\t\tdiff_tree_sha1(head->hash, new_head->hash, \"\", &opts);\n+\t\tdiff_tree_oid(head, new_head, \"\", &opts);\n \t\tdiffcore_std(&opts);\n \t\tdiff_flush(&opts);\n \t}\ndiff --git a/combine-diff.c b/combine-diff.c\nindex c82364510..04c4ae856 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1336,7 +1336,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid,\n \t\t\topt->output_format = stat_opt;\n \t\telse\n \t\t\topt->output_format = DIFF_FORMAT_NO_OUTPUT;\n-\t\tdiff_tree_sha1(parents->oid[i].hash, oid->hash, \"\", opt);\n+\t\tdiff_tree_oid(&parents->oid[i], oid, \"\", opt);\n \t\tdiffcore_std(opt);\n \t\tpaths = intersect_paths(paths, i, num_parent);\n \n@@ -1463,7 +1463,7 @@ void diff_tree_combined(const struct object_id *oid,\n \t\tif (stat_opt) {\n \t\t\tdiffopts.output_format = stat_opt;\n \n-\t\t\tdiff_tree_sha1(parents->oid[0].hash, oid->hash, \"\", &diffopts);\n+\t\t\tdiff_tree_oid(&parents->oid[0], oid, \"\", &diffopts);\n \t\t\tdiffcore_std(&diffopts);\n \t\t\tif (opt->orderfile)\n \t\t\t\tdiffcore_order(opt->orderfile);\ndiff --git a/diff.h b/diff.h\nindex 8d46a6709..e0b503460 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -213,8 +213,9 @@ extern struct combine_diff_path *diff_tree_paths(\n \tstruct combine_diff_path *p, const unsigned char *sha1,\n \tconst unsigned char **parent_sha1, int nparent,\n \tstruct strbuf *base, struct diff_options *opt);\n-extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,\n-\t\t\t  const char *base, struct diff_options *opt);\n+extern int diff_tree_oid(const struct object_id *old_oid,\n+\t\t\t const struct object_id *new_oid,\n+\t\t\t const char *base, struct diff_options *opt);\n extern int diff_root_tree_oid(const struct object_id *new_oid, const char *base,\n \t\t\t      struct diff_options *opt);\n \ndiff --git a/line-log.c b/line-log.c\nindex a3bd2f2d5..2588ce076 100644\n--- a/line-log.c\n+++ b/line-log.c\n@@ -819,8 +819,8 @@ static void queue_diffs(struct line_log_data *range,\n \tassert(commit);\n \n \tDIFF_QUEUE_CLEAR(&diff_queued_diff);\n-\tdiff_tree_sha1(parent ? parent->tree->object.oid.hash : NULL,\n-\t\t\tcommit->tree->object.oid.hash, \"\", opt);\n+\tdiff_tree_oid(parent ? &parent->tree->object.oid : NULL,\n+\t\t      &commit->tree->object.oid, \"\", opt);\n \tif (opt->detect_rename) {\n \t\tfilter_diffs_for_paths(range, 1);\n \t\tif (diff_might_be_rename())\ndiff --git a/log-tree.c b/log-tree.c\nindex b40242534..2903874ec 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -822,8 +822,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \t\t\t * we merged _in_.\n \t\t\t */\n \t\t\tparse_commit_or_die(parents->item);\n-\t\t\tdiff_tree_sha1(parents->item->tree->object.oid.hash,\n-\t\t\t\t       oid->hash, \"\", &opt->diffopt);\n+\t\t\tdiff_tree_oid(&parents->item->tree->object.oid,\n+\t\t\t\t      oid, \"\", &opt->diffopt);\n \t\t\tlog_tree_diff_flush(opt);\n \t\t\treturn !opt->loginfo;\n \t\t}\n@@ -837,8 +837,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \t\tstruct commit *parent = parents->item;\n \n \t\tparse_commit_or_die(parent);\n-\t\tdiff_tree_sha1(parent->tree->object.oid.hash,\n-\t\t\t       oid->hash, \"\", &opt->diffopt);\n+\t\tdiff_tree_oid(&parent->tree->object.oid,\n+\t\t\t      oid, \"\", &opt->diffopt);\n \t\tlog_tree_diff_flush(opt);\n \n \t\tshowed_log |= !opt->loginfo;\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex ae5238d82..5cc86df2d 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -528,7 +528,7 @@ static struct string_list *get_renames(struct merge_options *o,\n \topts.show_rename_progress = o->show_rename_progress;\n \topts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opts);\n-\tdiff_tree_sha1(o_tree->object.oid.hash, tree->object.oid.hash, \"\", &opts);\n+\tdiff_tree_oid(&o_tree->object.oid, &tree->object.oid, \"\", &opts);\n \tdiffcore_std(&opts);\n \tif (opts.needed_rename_limit > o->needed_rename_limit)\n \t\to->needed_rename_limit = opts.needed_rename_limit;\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 7d88857a8..70e3fbeef 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -129,7 +129,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \tDIFF_OPT_SET(&opt, RECURSIVE);\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n-\tdiff_tree_sha1(base->hash, remote->hash, \"\", &opt);\n+\tdiff_tree_oid(base, remote, \"\", &opt);\n \tdiffcore_std(&opt);\n \n \tchanges = xcalloc(diff_queued_diff.nr, sizeof(struct notes_merge_pair));\n@@ -192,7 +192,7 @@ static void diff_tree_local(struct notes_merge_options *o,\n \tDIFF_OPT_SET(&opt, RECURSIVE);\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n-\tdiff_tree_sha1(base->hash, local->hash, \"\", &opt);\n+\tdiff_tree_oid(base, local, \"\", &opt);\n \tdiffcore_std(&opt);\n \n \tfor (i = 0; i < diff_queued_diff.nr; i++) {\ndiff --git a/patch-ids.c b/patch-ids.c\nindex aaf462c03..9c0ab9e67 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -17,8 +17,8 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,\n \t\treturn -1;\n \n \tif (commit->parents)\n-\t\tdiff_tree_sha1(commit->parents->item->object.oid.hash,\n-\t\t\t       commit->object.oid.hash, \"\", options);\n+\t\tdiff_tree_oid(&commit->parents->item->object.oid,\n+\t\t\t      &commit->object.oid, \"\", options);\n \telse\n \t\tdiff_root_tree_oid(&commit->object.oid, \"\", options);\n \tdiffcore_std(options);\ndiff --git a/revision.c b/revision.c\nindex 7637e7556..3030f33ee 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,\n \n \ttree_difference = REV_TREE_SAME;\n \tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n-\tif (diff_tree_sha1(t1->object.oid.hash, t2->object.oid.hash, \"\",\n+\tif (diff_tree_oid(&t1->object.oid, &t2->object.oid, \"\",\n \t\t\t   &revs->pruning) < 0)\n \t\treturn REV_TREE_DIFFERENT;\n \treturn tree_difference;\n@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)\n \n \ttree_difference = REV_TREE_SAME;\n \tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n-\tretval = diff_tree_sha1(NULL, t1->object.oid.hash, \"\", &revs->pruning);\n+\tretval = diff_tree_oid(NULL, &t1->object.oid, \"\", &revs->pruning);\n \n \treturn retval >= 0 && (tree_difference == REV_TREE_SAME);\n }\ndiff --git a/sequencer.c b/sequencer.c\nindex a23b948ac..7a114def8 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2129,8 +2129,8 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)\n \t\t\tif (read_oneliner(&buf, rebase_path_orig_head(), 0) &&\n \t\t\t    !get_sha1(buf.buf, orig.hash) &&\n \t\t\t    !get_sha1(\"HEAD\", head.hash)) {\n-\t\t\t\tdiff_tree_sha1(orig.hash, head.hash,\n-\t\t\t\t\t       \"\", &log_tree_opt.diffopt);\n+\t\t\t\tdiff_tree_oid(&orig, &head, \"\",\n+\t\t\t\t\t      &log_tree_opt.diffopt);\n \t\t\t\tlog_tree_diff_flush(&log_tree_opt);\n \t\t\t}\n \t\t}\ndiff --git a/tree-diff.c b/tree-diff.c\nindex f9bbaf3c4..fc020d76d 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -419,7 +419,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t * load parents first, as they are probably already cached.\n \t *\n \t * ( log_tree_diff() parses commit->parent before calling here via\n-\t *   diff_tree_sha1(parent, commit) )\n+\t *   diff_tree_oid(parent, commit) )\n \t */\n \tfor (i = 0; i < nparent; ++i)\n \t\ttptree[i] = fill_tree_descriptor(&tp[i], parents_sha1[i]);\n@@ -694,7 +694,9 @@ static int ll_diff_tree_sha1(const unsigned char *old, const unsigned char *new,\n \treturn 0;\n }\n \n-int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const char *base_str, struct diff_options *opt)\n+int diff_tree_oid(const struct object_id *old_oid,\n+\t\t  const struct object_id *new_oid,\n+\t\t  const char *base_str, struct diff_options *opt)\n {\n \tstruct strbuf base;\n \tint retval;\n@@ -702,9 +704,9 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha\n \tstrbuf_init(&base, PATH_MAX);\n \tstrbuf_addstr(&base, base_str);\n \n-\tretval = ll_diff_tree_sha1(old, new, &base, opt);\n+\tretval = ll_diff_tree_sha1(old_oid->hash, new_oid->hash, &base, opt);\n \tif (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())\n-\t\ttry_to_follow_renames(old, new, &base, opt);\n+\t\ttry_to_follow_renames(old_oid->hash, new_oid->hash, &base, opt);\n \n \tstrbuf_release(&base);\n \n@@ -713,5 +715,5 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha\n \n int diff_root_tree_oid(const struct object_id *new_oid, const char *base, struct diff_options *opt)\n {\n-\treturn diff_tree_sha1(NULL, new_oid->hash, base, opt);\n+\treturn diff_tree_oid(NULL, new_oid, base, opt);\n }\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321062","messageId":"20170530173109.54904-33-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 32/33] diffcore-rename: use is_empty_blob_oid","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:08Z","receivedAt":"2017-05-30T17:32:45Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n diffcore-rename.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 3d9719dad..03d1e8d40 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -464,7 +464,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\t\t strcmp(options->single_follow, p->two->path))\n \t\t\t\tcontinue; /* not interested */\n \t\t\telse if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&\n-\t\t\t\t is_empty_blob_sha1(p->two->oid.hash))\n+\t\t\t\t is_empty_blob_oid(&p->two->oid))\n \t\t\t\tcontinue;\n \t\t\telse if (add_rename_dst(p->two) < 0) {\n \t\t\t\twarning(\"skipping rename detection, detected\"\n@@ -474,7 +474,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\t}\n \t\t}\n \t\telse if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&\n-\t\t\t is_empty_blob_sha1(p->one->oid.hash))\n+\t\t\t is_empty_blob_oid(&p->one->oid))\n \t\t\tcontinue;\n \t\telse if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {\n \t\t\t/*\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321063","messageId":"20170530173109.54904-29-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 28/33] builtin/diff-tree: cleanup references to sha1","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:31:04Z","receivedAt":"2017-05-30T17:32:48Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/diff-tree.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/diff-tree.c b/builtin/diff-tree.c\nindex aef167619..8b26a66a9 100644\n--- a/builtin/diff-tree.c\n+++ b/builtin/diff-tree.c\n@@ -7,7 +7,7 @@\n \n static struct rev_info log_tree_opt;\n \n-static int diff_tree_commit_sha1(const struct object_id *oid)\n+static int diff_tree_commit_oid(const struct object_id *oid)\n {\n \tstruct commit *commit = lookup_commit_reference(oid);\n \tif (!commit)\n@@ -98,7 +98,6 @@ static void diff_tree_tweak_rev(struct rev_info *rev, struct setup_revision_opt\n \n int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n {\n-\tint nr_sha1;\n \tchar line[1000];\n \tstruct object *tree1, *tree2;\n \tstatic struct rev_info *opt = &log_tree_opt;\n@@ -132,15 +131,14 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n \t * reverse the order of the objects if the second one\n \t * is marked UNINTERESTING.\n \t */\n-\tnr_sha1 = opt->pending.nr;\n-\tswitch (nr_sha1) {\n+\tswitch (opt->pending.nr) {\n \tcase 0:\n \t\tif (!read_stdin)\n \t\t\tusage(diff_tree_usage);\n \t\tbreak;\n \tcase 1:\n \t\ttree1 = opt->pending.objects[0].item;\n-\t\tdiff_tree_commit_sha1(&tree1->oid);\n+\t\tdiff_tree_commit_oid(&tree1->oid);\n \t\tbreak;\n \tcase 2:\n \t\ttree1 = opt->pending.objects[0].item;\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321064","messageId":"20170530173109.54904-18-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 17/33] patch-ids: convert to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:53Z","receivedAt":"2017-05-30T17:32:50Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/log.c |  2 +-\n patch-ids.c   | 20 ++++++++++----------\n patch-ids.h   |  4 ++--\n 3 files changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex a440601ef..6bdba3444 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1354,7 +1354,7 @@ static void prepare_bases(struct base_tree_info *bases,\n \t\tstruct object_id *patch_id;\n \t\tif (commit->util)\n \t\t\tcontinue;\n-\t\tif (commit_patch_id(commit, &diffopt, oid.hash, 0))\n+\t\tif (commit_patch_id(commit, &diffopt, &oid, 0))\n \t\t\tdie(_(\"cannot get patch id\"));\n \t\tALLOC_GROW(bases->patch_id, bases->nr_patch_id + 1, bases->alloc_patch_id);\n \t\tpatch_id = bases->patch_id + bases->nr_patch_id;\ndiff --git a/patch-ids.c b/patch-ids.c\nindex 92eba7a05..aab26cbbb 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -11,7 +11,7 @@ static int patch_id_defined(struct commit *commit)\n }\n \n int commit_patch_id(struct commit *commit, struct diff_options *options,\n-\t\t    unsigned char *sha1, int diff_header_only)\n+\t\t    struct object_id *oid, int diff_header_only)\n {\n \tif (!patch_id_defined(commit))\n \t\treturn -1;\n@@ -22,7 +22,7 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,\n \telse\n \t\tdiff_root_tree_sha1(commit->object.oid.hash, \"\", options);\n \tdiffcore_std(options);\n-\treturn diff_flush_patch_id(options, sha1, diff_header_only);\n+\treturn diff_flush_patch_id(options, oid->hash, diff_header_only);\n }\n \n /*\n@@ -39,15 +39,15 @@ static int patch_id_cmp(struct patch_id *a,\n \t\t\tstruct patch_id *b,\n \t\t\tstruct diff_options *opt)\n {\n-\tif (is_null_sha1(a->patch_id) &&\n-\t    commit_patch_id(a->commit, opt, a->patch_id, 0))\n+\tif (is_null_oid(&a->patch_id) &&\n+\t    commit_patch_id(a->commit, opt, &a->patch_id, 0))\n \t\treturn error(\"Could not get patch ID for %s\",\n \t\t\toid_to_hex(&a->commit->object.oid));\n-\tif (is_null_sha1(b->patch_id) &&\n-\t    commit_patch_id(b->commit, opt, b->patch_id, 0))\n+\tif (is_null_oid(&b->patch_id) &&\n+\t    commit_patch_id(b->commit, opt, &b->patch_id, 0))\n \t\treturn error(\"Could not get patch ID for %s\",\n \t\t\toid_to_hex(&b->commit->object.oid));\n-\treturn hashcmp(a->patch_id, b->patch_id);\n+\treturn oidcmp(&a->patch_id, &b->patch_id);\n }\n \n int init_patch_ids(struct patch_ids *ids)\n@@ -71,13 +71,13 @@ static int init_patch_id_entry(struct patch_id *patch,\n \t\t\t       struct commit *commit,\n \t\t\t       struct patch_ids *ids)\n {\n-\tunsigned char header_only_patch_id[GIT_MAX_RAWSZ];\n+\tstruct object_id header_only_patch_id;\n \n \tpatch->commit = commit;\n-\tif (commit_patch_id(commit, &ids->diffopts, header_only_patch_id, 1))\n+\tif (commit_patch_id(commit, &ids->diffopts, &header_only_patch_id, 1))\n \t\treturn -1;\n \n-\thashmap_entry_init(patch, sha1hash(header_only_patch_id));\n+\thashmap_entry_init(patch, sha1hash(header_only_patch_id.hash));\n \treturn 0;\n }\n \ndiff --git a/patch-ids.h b/patch-ids.h\nindex b9e5751f8..bec0f727a 100644\n--- a/patch-ids.h\n+++ b/patch-ids.h\n@@ -3,7 +3,7 @@\n \n struct patch_id {\n \tstruct hashmap_entry ent;\n-\tunsigned char patch_id[GIT_MAX_RAWSZ];\n+\tstruct object_id patch_id;\n \tstruct commit *commit;\n };\n \n@@ -13,7 +13,7 @@ struct patch_ids {\n };\n \n int commit_patch_id(struct commit *commit, struct diff_options *options,\n-\t\t    unsigned char *sha1, int);\n+\t\t    struct object_id *oid, int);\n int init_patch_ids(struct patch_ids *);\n int free_patch_ids(struct patch_ids *);\n struct patch_id *add_commit_patch_id(struct commit *, struct patch_ids *);\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321065","messageId":"20170530173109.54904-17-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 16/33] diff: finish conversion for prepare_temp_file to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:52Z","receivedAt":"2017-05-30T17:32:55Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n diff.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 084c8b2d0..a8ceeb024 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3030,13 +3030,13 @@ static struct diff_tempfile *prepare_temp_file(const char *name,\n \t\t\t/* we can borrow from the file in the work tree */\n \t\t\ttemp->name = name;\n \t\t\tif (!one->oid_valid)\n-\t\t\t\tsha1_to_hex_r(temp->hex, null_sha1);\n+\t\t\t\toid_to_hex_r(temp->hex, &null_oid);\n \t\t\telse\n \t\t\t\toid_to_hex_r(temp->hex, &one->oid);\n \t\t\t/* Even though we may sometimes borrow the\n \t\t\t * contents from the work tree, we always want\n \t\t\t * one->mode.  mode is trustworthy even when\n-\t\t\t * !(one->sha1_valid), as long as\n+\t\t\t * !(one->oid_valid), as long as\n \t\t\t * DIFF_FILE_VALID(one).\n \t\t\t */\n \t\t\txsnprintf(temp->mode, sizeof(temp->mode), \"%06o\", one->mode);\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321066","messageId":"20170530173109.54904-12-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 11/33] diff: convert diff_addremove to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:47Z","receivedAt":"2017-05-30T17:32:58Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Convert diff_addremove to take a struct object_id.  In addtion convert\nthe function pointer type 'add_remove_fn_t' to also take a struct\nobject_id.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n diff-lib.c  | 6 +++---\n diff.c      | 8 ++++----\n diff.h      | 8 ++++----\n revision.c  | 4 ++--\n tree-diff.c | 8 ++++----\n 5 files changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 2c838aaf4..7984ff962 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -210,14 +210,14 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \t\t\t\t\tcontinue;\n \t\t\t\t}\n \t\t\t\tdiff_addremove(&revs->diffopt, '-', ce->ce_mode,\n-\t\t\t\t\t       ce->oid.hash,\n+\t\t\t\t\t       &ce->oid,\n \t\t\t\t\t       !is_null_oid(&ce->oid),\n \t\t\t\t\t       ce->name, 0);\n \t\t\t\tcontinue;\n \t\t\t} else if (revs->diffopt.ita_invisible_in_index &&\n \t\t\t\t   ce_intent_to_add(ce)) {\n \t\t\t\tdiff_addremove(&revs->diffopt, '+', ce->ce_mode,\n-\t\t\t\t\t       EMPTY_BLOB_SHA1_BIN, 0,\n+\t\t\t\t\t       &empty_tree_oid, 0,\n \t\t\t\t\t       ce->name, 0);\n \t\t\t\tcontinue;\n \t\t\t}\n@@ -260,7 +260,7 @@ static void diff_index_show_file(struct rev_info *revs,\n \t\t\t\t unsigned dirty_submodule)\n {\n \tdiff_addremove(&revs->diffopt, prefix[0], mode,\n-\t\t       oid->hash, oid_valid, ce->name, dirty_submodule);\n+\t\t       oid, oid_valid, ce->name, dirty_submodule);\n }\n \n static int get_stat_data(const struct cache_entry *ce,\ndiff --git a/diff.c b/diff.c\nindex f3546536b..3fa335f44 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5081,8 +5081,8 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)\n \n void diff_addremove(struct diff_options *options,\n \t\t    int addremove, unsigned mode,\n-\t\t    const unsigned char *sha1,\n-\t\t    int sha1_valid,\n+\t\t    const struct object_id *oid,\n+\t\t    int oid_valid,\n \t\t    const char *concatpath, unsigned dirty_submodule)\n {\n \tstruct diff_filespec *one, *two;\n@@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,\n \ttwo = alloc_filespec(concatpath);\n \n \tif (addremove != '+')\n-\t\tfill_filespec(one, sha1, sha1_valid, mode);\n+\t\tfill_filespec(one, oid->hash, oid_valid, mode);\n \tif (addremove != '-') {\n-\t\tfill_filespec(two, sha1, sha1_valid, mode);\n+\t\tfill_filespec(two, oid->hash, oid_valid, mode);\n \t\ttwo->dirty_submodule = dirty_submodule;\n \t}\n \ndiff --git a/diff.h b/diff.h\nindex d75e6d15e..1086975a5 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -31,8 +31,8 @@ typedef void (*change_fn_t)(struct diff_options *options,\n \n typedef void (*add_remove_fn_t)(struct diff_options *options,\n \t\t    int addremove, unsigned mode,\n-\t\t    const unsigned char *sha1,\n-\t\t    int sha1_valid,\n+\t\t    const struct object_id *oid,\n+\t\t    int oid_valid,\n \t\t    const char *fullpath, unsigned dirty_submodule);\n \n typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,\n@@ -247,8 +247,8 @@ extern int diff_can_quit_early(struct diff_options *);\n extern void diff_addremove(struct diff_options *,\n \t\t\t   int addremove,\n \t\t\t   unsigned mode,\n-\t\t\t   const unsigned char *sha1,\n-\t\t\t   int sha1_valid,\n+\t\t\t   const struct object_id *oid,\n+\t\t\t   int oid_valid,\n \t\t\t   const char *fullpath, unsigned dirty_submodule);\n \n extern void diff_change(struct diff_options *,\ndiff --git a/revision.c b/revision.c\nindex 475d5b2dc..71519193c 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -401,8 +401,8 @@ static int tree_difference = REV_TREE_SAME;\n \n static void file_add_remove(struct diff_options *options,\n \t\t    int addremove, unsigned mode,\n-\t\t    const unsigned char *sha1,\n-\t\t    int sha1_valid,\n+\t\t    const struct object_id *oid,\n+\t\t    int oid_valid,\n \t\t    const char *fullpath, unsigned dirty_submodule)\n {\n \tint diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;\ndiff --git a/tree-diff.c b/tree-diff.c\nindex e164e532b..f2c747ea5 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -78,21 +78,21 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_\n \t\t\t1, 1, p->path, 0, 0);\n \t}\n \telse {\n-\t\tconst unsigned char *sha1;\n+\t\tconst struct object_id *oid;\n \t\tunsigned int mode;\n \t\tint addremove;\n \n \t\tif (p->mode) {\n \t\t\taddremove = '+';\n-\t\t\tsha1 = p->oid.hash;\n+\t\t\toid = &p->oid;\n \t\t\tmode = p->mode;\n \t\t} else {\n \t\t\taddremove = '-';\n-\t\t\tsha1 = p0->oid.hash;\n+\t\t\toid = &p0->oid;\n \t\t\tmode = p0->mode;\n \t\t}\n \n-\t\topt->add_remove(opt, addremove, mode, sha1, 1, p->path, 0);\n+\t\topt->add_remove(opt, addremove, mode, oid, 1, p->path, 0);\n \t}\n \n \treturn 0;\t/* we are done with p */\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321067","messageId":"20170530173109.54904-13-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 12/33] diff: convert run_diff_files to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:48Z","receivedAt":"2017-05-30T17:33:02Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Signed-off-by: Brandon Williams <bmwill@google.com>\n---\n diff-lib.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 7984ff962..c82b07dc1 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -101,7 +101,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \t\tstruct cache_entry *ce = active_cache[i];\n \t\tint changed;\n \t\tunsigned dirty_submodule = 0;\n-\t\tconst unsigned char *old_sha1, *new_sha1;\n+\t\tconst struct object_id *old_oid, *new_oid;\n \n \t\tif (diff_can_quit_early(&revs->diffopt))\n \t\t\tbreak;\n@@ -233,12 +233,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \t\t\t\tcontinue;\n \t\t}\n \t\toldmode = ce->ce_mode;\n-\t\told_sha1 = ce->oid.hash;\n-\t\tnew_sha1 = changed ? null_sha1 : ce->oid.hash;\n+\t\told_oid = &ce->oid;\n+\t\tnew_oid = changed ? &null_oid : &ce->oid;\n \t\tdiff_change(&revs->diffopt, oldmode, newmode,\n-\t\t\t    old_sha1, new_sha1,\n-\t\t\t    !is_null_sha1(old_sha1),\n-\t\t\t    !is_null_sha1(new_sha1),\n+\t\t\t    old_oid->hash, new_oid->hash,\n+\t\t\t    !is_null_oid(old_oid),\n+\t\t\t    !is_null_oid(new_oid),\n \t\t\t    ce->name, 0, dirty_submodule);\n \n \t}\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321068","messageId":"20170530173109.54904-14-bmwill@google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"[PATCH 13/33] diff: convert diff_change to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-30T17:30:49Z","receivedAt":"2017-05-30T17:33:03Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Convert diff_change to take a struct object_id.  In addition convert the\nfunction pointer type 'change_fn_t' to also take a struct object_id.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n diff-lib.c  |  4 ++--\n diff.c      | 14 +++++++-------\n diff.h      | 13 ++++++-------\n revision.c  |  6 +++---\n tree-diff.c |  2 +-\n 5 files changed, 19 insertions(+), 20 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex c82b07dc1..1e8215df5 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -236,7 +236,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \t\told_oid = &ce->oid;\n \t\tnew_oid = changed ? &null_oid : &ce->oid;\n \t\tdiff_change(&revs->diffopt, oldmode, newmode,\n-\t\t\t    old_oid->hash, new_oid->hash,\n+\t\t\t    old_oid, new_oid,\n \t\t\t    !is_null_oid(old_oid),\n \t\t\t    !is_null_oid(new_oid),\n \t\t\t    ce->name, 0, dirty_submodule);\n@@ -367,7 +367,7 @@ static int show_modified(struct rev_info *revs,\n \t\treturn 0;\n \n \tdiff_change(&revs->diffopt, oldmode, mode,\n-\t\t    old->oid.hash, oid->hash, 1, !is_null_oid(oid),\n+\t\t    &old->oid, oid, 1, !is_null_oid(oid),\n \t\t    old->name, 0, dirty_submodule);\n \treturn 0;\n }\ndiff --git a/diff.c b/diff.c\nindex 3fa335f44..b9bb3f6ca 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5127,9 +5127,9 @@ void diff_addremove(struct diff_options *options,\n \n void diff_change(struct diff_options *options,\n \t\t unsigned old_mode, unsigned new_mode,\n-\t\t const unsigned char *old_sha1,\n-\t\t const unsigned char *new_sha1,\n-\t\t int old_sha1_valid, int new_sha1_valid,\n+\t\t const struct object_id *old_oid,\n+\t\t const struct object_id *new_oid,\n+\t\t int old_oid_valid, int new_oid_valid,\n \t\t const char *concatpath,\n \t\t unsigned old_dirty_submodule, unsigned new_dirty_submodule)\n {\n@@ -5142,8 +5142,8 @@ void diff_change(struct diff_options *options,\n \n \tif (DIFF_OPT_TST(options, REVERSE_DIFF)) {\n \t\tSWAP(old_mode, new_mode);\n-\t\tSWAP(old_sha1, new_sha1);\n-\t\tSWAP(old_sha1_valid, new_sha1_valid);\n+\t\tSWAP(old_oid, new_oid);\n+\t\tSWAP(old_oid_valid, new_oid_valid);\n \t\tSWAP(old_dirty_submodule, new_dirty_submodule);\n \t}\n \n@@ -5153,8 +5153,8 @@ void diff_change(struct diff_options *options,\n \n \tone = alloc_filespec(concatpath);\n \ttwo = alloc_filespec(concatpath);\n-\tfill_filespec(one, old_sha1, old_sha1_valid, old_mode);\n-\tfill_filespec(two, new_sha1, new_sha1_valid, new_mode);\n+\tfill_filespec(one, old_oid->hash, old_oid_valid, old_mode);\n+\tfill_filespec(two, new_oid->hash, new_oid_valid, new_mode);\n \tone->dirty_submodule = old_dirty_submodule;\n \ttwo->dirty_submodule = new_dirty_submodule;\n \tp = diff_queue(&diff_queued_diff, one, two);\ndiff --git a/diff.h b/diff.h\nindex 1086975a5..fcf334bb6 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -23,9 +23,9 @@ typedef int (*pathchange_fn_t)(struct diff_options *options,\n \n typedef void (*change_fn_t)(struct diff_options *options,\n \t\t unsigned old_mode, unsigned new_mode,\n-\t\t const unsigned char *old_sha1,\n-\t\t const unsigned char *new_sha1,\n-\t\t int old_sha1_valid, int new_sha1_valid,\n+\t\t const struct object_id *old_oid,\n+\t\t const struct object_id *new_oid,\n+\t\t int old_oid_valid, int new_oid_valid,\n \t\t const char *fullpath,\n \t\t unsigned old_dirty_submodule, unsigned new_dirty_submodule);\n \n@@ -253,10 +253,9 @@ extern void diff_addremove(struct diff_options *,\n \n extern void diff_change(struct diff_options *,\n \t\t\tunsigned mode1, unsigned mode2,\n-\t\t\tconst unsigned char *sha1,\n-\t\t\tconst unsigned char *sha2,\n-\t\t\tint sha1_valid,\n-\t\t\tint sha2_valid,\n+\t\t\tconst struct object_id *old_oid,\n+\t\t\tconst struct object_id *new_oid,\n+\t\t\tint old_oid_valid, int new_oid_valid,\n \t\t\tconst char *fullpath,\n \t\t\tunsigned dirty_submodule1, unsigned dirty_submodule2);\n \ndiff --git a/revision.c b/revision.c\nindex 71519193c..7637e7556 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -414,9 +414,9 @@ static void file_add_remove(struct diff_options *options,\n \n static void file_change(struct diff_options *options,\n \t\t unsigned old_mode, unsigned new_mode,\n-\t\t const unsigned char *old_sha1,\n-\t\t const unsigned char *new_sha1,\n-\t\t int old_sha1_valid, int new_sha1_valid,\n+\t\t const struct object_id *old_oid,\n+\t\t const struct object_id *new_oid,\n+\t\t int old_oid_valid, int new_oid_valid,\n \t\t const char *fullpath,\n \t\t unsigned old_dirty_submodule, unsigned new_dirty_submodule)\n {\ndiff --git a/tree-diff.c b/tree-diff.c\nindex f2c747ea5..7ae1f10b2 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -74,7 +74,7 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_\n {\n \tstruct combine_diff_parent *p0 = &p->parent[0];\n \tif (p->mode && p0->mode) {\n-\t\topt->change(opt, p0->mode, p->mode, p0->oid.hash, p->oid.hash,\n+\t\topt->change(opt, p0->mode, p->mode, &p0->oid, &p->oid,\n \t\t\t1, 1, p->path, 0, 0);\n \t}\n \telse {\n-- \n2.13.0.219.gdb65acc882-goog\n\n"},{"id":"321103","messageId":"CAGZ79kZsQCWkA+bSH2RSdHxiAX2KADJXqQGywmpP-t4BQYMCWw@mail.gmail.com","threadId":"46073","inReplyTo":"20170530173109.54904-17-bmwill@google.com","subject":"Re: [PATCH 16/33] diff: finish conversion for prepare_temp_file to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-31T00:41:30Z","receivedAt":"2017-05-31T00:41:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 30, 2017 at 10:30 AM, Brandon Williams <bmwill@google.com> wrote:\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n\nUp to (and including) this commit, the series looks good to me.\nWill continue to review this series later.\n\nThanks,\nStefan\n\n> ---\n>  diff.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/diff.c b/diff.c\n> index 084c8b2d0..a8ceeb024 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -3030,13 +3030,13 @@ static struct diff_tempfile *prepare_temp_file(const char *name,\n>                         /* we can borrow from the file in the work tree */\n>                         temp->name = name;\n>                         if (!one->oid_valid)\n> -                               sha1_to_hex_r(temp->hex, null_sha1);\n> +                               oid_to_hex_r(temp->hex, &null_oid);\n>                         else\n>                                 oid_to_hex_r(temp->hex, &one->oid);\n>                         /* Even though we may sometimes borrow the\n>                          * contents from the work tree, we always want\n>                          * one->mode.  mode is trustworthy even when\n> -                        * !(one->sha1_valid), as long as\n> +                        * !(one->oid_valid), as long as\n>                          * DIFF_FILE_VALID(one).\n>                          */\n>                         xsnprintf(temp->mode, sizeof(temp->mode), \"%06o\", one->mode);\n> --\n> 2.13.0.219.gdb65acc882-goog\n>\n"},{"id":"321143","messageId":"CAGZ79kbPaWEuZr1yXKnMwUeLzW4h_pnD-f2bEj7dyE7Q12z2sw@mail.gmail.com","threadId":"46073","inReplyTo":"20170530173109.54904-21-bmwill@google.com","subject":"Re: [PATCH 20/33] combine-diff: convert find_paths_* to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-31T17:49:53Z","receivedAt":"2017-05-31T17:51:41Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 30, 2017 at 10:30 AM, Brandon Williams <bmwill@google.com> wrote:\n> Convert find_paths_generic and find_paths_multitree to use struct\n> object_id.\n>\n>\n\ndouble empty line?\n\nUnlike some other prior patches, it is nice to see a commit message here. :)\n\nCode of the patches up to here looks good.\n"},{"id":"321145","messageId":"CAGZ79kZ9oWE1vniOPc+i4x-iLBwTU8B3f+OfiF0ZKN=_sqoDtA@mail.gmail.com","threadId":"46073","inReplyTo":"20170530173109.54904-23-bmwill@google.com","subject":"Re: [PATCH 22/33] notes-merge: convert notes_merge* to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-31T17:54:32Z","receivedAt":"2017-05-31T17:55:28Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 30, 2017 at 10:30 AM, Brandon Williams <bmwill@google.com> wrote:\n> Convert notes_merge and notes_merge_commit to use struct object_id.\n>\n>\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n\nspurious new line before sign off.\n"},{"id":"321146","messageId":"CAGZ79kajzJGdN1uu5kni3AB31joP5hdnsWp1NBGkX3Rs-BkPpw@mail.gmail.com","threadId":"46073","inReplyTo":"20170530173109.54904-24-bmwill@google.com","subject":"Re: [PATCH 23/33] notes-merge: convert merge_from_diffs to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-31T18:04:54Z","receivedAt":"2017-05-31T18:06:59Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"> @@ -505,16 +505,17 @@ static int merge_changes(struct notes_merge_options *o,\n>  }\n>\n>  static int merge_from_diffs(struct notes_merge_options *o,\n> -                           const unsigned char *base,\n> -                           const unsigned char *local,\n> -                           const unsigned char *remote, struct notes_tree *t)\n> +                           const struct object_id *base,\n> +                           const struct object_id *local,\n> +                           const struct object_id *remote,\n> +                           struct notes_tree *t)\n>  {\n>         struct notes_merge_pair *changes;\n>         int num_changes, conflicts;\n>\n>         trace_printf(\"\\tmerge_from_diffs(base = %.7s, local = %.7s, \"\n> -              \"remote = %.7s)\\n\", sha1_to_hex(base), sha1_to_hex(local),\n> -              sha1_to_hex(remote));\n> +              \"remote = %.7s)\\n\", oid_to_hex(base), oid_to_hex(local),\n> +              oid_to_hex(remote));\n\nThis part is interesting.\n\n7 used to be the default abbreviation length for sha1s (see\ne6c587c733 (abbrev: auto size the default abbreviation, 2016-09-30)\nfor details) and this may have been a left over from the conversion\nto variable length abbreviated hashes. This could be a reminder\nwe want to fix these, too. (Though not in this series?).\n\nRoughly like\n\n    trace_printf(\"\\tmerge_from_diffs(base = %s, local = %s, remote = %s)\\n\",\n        find_unique_abbrev(base.hash, DEFAULT_ABBREV),\n        find_unique_abbrev(local.hash, DEFAULT_ABBREV)\n        find_unique_abbrev(remote.hash, DEFAULT_ABBREV));\n"},{"id":"321148","messageId":"CAGZ79kYz7jhBVivhVNVMHhO1NfC_j4CEHF5uis-S093dzZL8tw@mail.gmail.com","threadId":"46073","inReplyTo":"20170530173109.54904-26-bmwill@google.com","subject":"Re: [PATCH 25/33] notes-merge: convert verify_notes_filepair to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-31T18:09:19Z","receivedAt":"2017-05-31T18:09:24Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 30, 2017 at 10:31 AM, Brandon Williams <bmwill@google.com> wrote:\n>\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n> ---\n>  notes-merge.c | 20 ++++++++++----------\n>  1 file changed, 10 insertions(+), 10 deletions(-)\n>\n> diff --git a/notes-merge.c b/notes-merge.c\n> index 55dbb3659..962e9b1bc 100644\n> --- a/notes-merge.c\n> +++ b/notes-merge.c\n> @@ -22,21 +22,21 @@ void init_notes_merge_options(struct notes_merge_options *o)\n>         o->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;\n>  }\n>\n> -static int path_to_sha1(const char *path, unsigned char *sha1)\n> +static int path_to_oid(const char *path, struct object_id *oid)\n>  {\n> -       char hex_sha1[40];\n> +       char hex_oid[GIT_SHA1_HEXSZ];\n\nHere we better use GIT_MAX_HEXSZ ?\n"},{"id":"321149","messageId":"CAGZ79kZjVvk8GoUFMnR7XJMDyvjkKPhw_7kUYPFq_ShcW50pVQ@mail.gmail.com","threadId":"46073","inReplyTo":"20170530173109.54904-31-bmwill@google.com","subject":"Re: [PATCH 30/33] tree-diff: convert diff_tree_paths to struct object_id","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-31T18:24:33Z","receivedAt":"2017-05-31T18:24:55Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 30, 2017 at 10:31 AM, Brandon Williams <bmwill@google.com> wrote:\n>\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n> ---\n>  combine-diff.c | 10 +++++-----\n>  diff.h         |  4 ++--\n>  tree-diff.c    | 63 +++++++++++++++++++++++++++++-----------------------------\n>  3 files changed, 39 insertions(+), 38 deletions(-)\n>\n> diff --git a/combine-diff.c b/combine-diff.c\n> index 04c4ae856..ec9d93044 100644\n> --- a/combine-diff.c\n> +++ b/combine-diff.c\n> @@ -1364,22 +1364,22 @@ static struct combine_diff_path *find_paths_multitree(\n>         struct diff_options *opt)\n>  {\n>         int i, nparent = parents->nr;\n> -       const unsigned char **parents_sha1;\n> +       const struct object_id **parents_oid;\n>         struct combine_diff_path paths_head;\n>         struct strbuf base;\n>\n> -       ALLOC_ARRAY(parents_sha1, nparent);\n> +       ALLOC_ARRAY(parents_oid, nparent);\n>         for (i = 0; i < nparent; i++)\n> -               parents_sha1[i] = parents->oid[i].hash;\n> +               parents_oid[i] = &parents->oid[i];\n\nI have the impression that we could get away with one layer less\nof indirection. Previously we had a heap allocated array (*) of (char*),\nnow we'd have a an array (*) of pointers(*) of the oid struct, that\nis a (char[]) essentially. Maybe I am just confused?\n"},{"id":"321167","messageId":"20170531212920.yy3swp732rjfnzge@sigill.intra.peff.net","threadId":"46073","inReplyTo":"CAGZ79kZjVvk8GoUFMnR7XJMDyvjkKPhw_7kUYPFq_ShcW50pVQ@mail.gmail.com","subject":"Re: [PATCH 30/33] tree-diff: convert diff_tree_paths to struct object_id","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-05-31T21:29:20Z","receivedAt":"2017-05-31T21:29:25Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 31, 2017 at 11:24:33AM -0700, Stefan Beller wrote:\n\n> On Tue, May 30, 2017 at 10:31 AM, Brandon Williams <bmwill@google.com> wrote:\n> >\n> > Signed-off-by: Brandon Williams <bmwill@google.com>\n> > ---\n> >  combine-diff.c | 10 +++++-----\n> >  diff.h         |  4 ++--\n> >  tree-diff.c    | 63 +++++++++++++++++++++++++++++-----------------------------\n> >  3 files changed, 39 insertions(+), 38 deletions(-)\n> >\n> > diff --git a/combine-diff.c b/combine-diff.c\n> > index 04c4ae856..ec9d93044 100644\n> > --- a/combine-diff.c\n> > +++ b/combine-diff.c\n> > @@ -1364,22 +1364,22 @@ static struct combine_diff_path *find_paths_multitree(\n> >         struct diff_options *opt)\n> >  {\n> >         int i, nparent = parents->nr;\n> > -       const unsigned char **parents_sha1;\n> > +       const struct object_id **parents_oid;\n> >         struct combine_diff_path paths_head;\n> >         struct strbuf base;\n> >\n> > -       ALLOC_ARRAY(parents_sha1, nparent);\n> > +       ALLOC_ARRAY(parents_oid, nparent);\n> >         for (i = 0; i < nparent; i++)\n> > -               parents_sha1[i] = parents->oid[i].hash;\n> > +               parents_oid[i] = &parents->oid[i];\n> \n> I have the impression that we could get away with one layer less\n> of indirection. Previously we had a heap allocated array (*) of (char*),\n> now we'd have a an array (*) of pointers(*) of the oid struct, that\n> is a (char[]) essentially. Maybe I am just confused?\n\nI don't think so. We always could have allocated the original as an\narray of 20-byte chunks. It's syntactically less awkward in C when that\n20-byte chunk is wrapped in a struct like object_id. But fundamentally\nI think we don't need to be making a copy of the oid. We're pointing to\nthe existing copy in the \"parents\" array.\n\nOr did you mean that diff_tree_paths() could now take an actual\narray-of-struct rather than an array-of-pointer-to-struct? That would\ndrop the \"parents_oid\" array entirely. I think that's actually\northogonal to this change (the same could have been done with the\noriginal sha1 array), but would be a nice cleanup on top.\n\n-Peff\n"},{"id":"321168","messageId":"20170531213920.daqlw3s5ppmq36ww@sigill.intra.peff.net","threadId":"46073","inReplyTo":"20170531212920.yy3swp732rjfnzge@sigill.intra.peff.net","subject":"Re: [PATCH 30/33] tree-diff: convert diff_tree_paths to struct object_id","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-05-31T21:39:20Z","receivedAt":"2017-05-31T21:39:27Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 31, 2017 at 05:29:20PM -0400, Jeff King wrote:\n\n> Or did you mean that diff_tree_paths() could now take an actual\n> array-of-struct rather than an array-of-pointer-to-struct? That would\n> drop the \"parents_oid\" array entirely. I think that's actually\n> orthogonal to this change (the same could have been done with the\n> original sha1 array), but would be a nice cleanup on top.\n\nI took a quick look at this, but it doesn't work. This caller\n(find_paths_multitree) would be happy to just pass the existing\n\"parents\" array.\n\nBut if we change the interface to diff_tree_paths(), we also have to\nchange ll_diff_tree_paths() to match. And that function is called from\nemit_path(), which really does assemble a list of pointers to\nnon-adjacent bits of memory. So it would still have to allocate, and\nwould now have to copy whole oids rather than just pointers.\n\nBut even worse, it seems to leave some entries as NULL. We'd need some\nsentinel value (like the null sha1) to replace that.\n\nSo I think the code is already in its simplest form.\n\n-Peff\n"},{"id":"321204","messageId":"20170530185653.cfy4cbq3pmxfq5x6@genre.crustytoothpaste.net","threadId":"46073","inReplyTo":"20170530173109.54904-23-bmwill@google.com","subject":"Re: [PATCH 22/33] notes-merge: convert notes_merge* to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-05-31T22:00:57Z","receivedAt":"2017-05-31T22:01:07Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Tue, May 30, 2017 at 10:30:58AM -0700, Brandon Williams wrote:\n> @@ -596,47 +596,47 @@ int notes_merge(struct notes_merge_options *o,\n>  \t/* Find merge bases */\n>  \tbases = get_merge_bases(local, remote);\n>  \tif (!bases) {\n> -\t\tbase_sha1 = null_sha1;\n> -\t\tbase_tree_sha1 = EMPTY_TREE_SHA1_BIN;\n> +\t\tbase_oid = &null_oid;\n> +\t\tbase_tree_oid = &empty_tree_oid;\n>  \t\tif (o->verbosity >= 4)\n>  \t\t\tprintf(\"No merge base found; doing history-less merge\\n\");\n>  \t} else if (!bases->next) {\n> -\t\tbase_sha1 = bases->item->object.oid.hash;\n> -\t\tbase_tree_sha1 = bases->item->tree->object.oid.hash;\n> +\t\tbase_oid = &bases->item->object.oid;\n> +\t\tbase_tree_oid = &bases->item->tree->object.oid;\n>  \t\tif (o->verbosity >= 4)\n>  \t\t\tprintf(\"One merge base found (%.7s)\\n\",\n> -\t\t\t\tsha1_to_hex(base_sha1));\n> +\t\t\t       oid_to_hex(base_oid));\n\nI noticed you fixed up the indentation.  Thanks.\n\n> diff --git a/notes-merge.h b/notes-merge.h\n> index 0d890563b..eaa8e3b86 100644\n> --- a/notes-merge.h\n> +++ b/notes-merge.h\n> @@ -33,15 +33,15 @@ void init_notes_merge_options(struct notes_merge_options *o);\n>   *\n>   * 1. The merge trivially results in an existing commit (e.g. fast-forward or\n>   *    already-up-to-date). 'local_tree' is untouched, the SHA1 of the result\n> - *    is written into 'result_sha1' and 0 is returned.\n> + *    is written into 'result_oid' and 0 is returned.\n>   * 2. The merge successfully completes, producing a merge commit. local_tree\n>   *    contains the updated notes tree, the SHA1 of the resulting commit is\n> - *    written into 'result_sha1', and 1 is returned.\n> + *    written into 'result_oid', and 1 is returned.\n>   * 3. The merge results in conflicts. This is similar to #2 in that the\n>   *    partial merge result (i.e. merge result minus the unmerged entries)\n>   *    are stored in 'local_tree', and the SHA1 or the resulting commit\n>   *    (to be amended when the conflicts have been resolved) is written into\n> - *    'result_sha1'. The unmerged entries are written into the\n> + *    'result_oid'. The unmerged entries are written into the\n>   *    .git/NOTES_MERGE_WORKTREE directory with conflict markers.\n>   *    -1 is returned.\n>   *\n\nDid you want to change the comment to say \"object ID\" or \"OID\" instead\nof \"SHA1\" like you did in an earlier patch?\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"321206","messageId":"20170531220640.kd73vbyx6fr4ht7h@genre.crustytoothpaste.net","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"Re: [PATCH 00/33] object id conversion (grep and diff)","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-05-31T22:06:40Z","receivedAt":"2017-05-31T22:06:50Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Tue, May 30, 2017 at 10:30:36AM -0700, Brandon Williams wrote:\n> A month or so ago I thought I would lend a hand to Brian and do a round of\n> conversions from sha1 -> struct object_id.  Now that Brian's latest series has\n> hit master I can finally send these patches out.\n> \n> The first couple patches are from Brian which convert some of the notes logic\n> to using 'struct object_id'.  The remaining patches are to convert the grep and\n> diff machinery to using 'struct object_id'.\n> \n> Brandon Williams (26):\n>   grep: convert to struct object_id\n>   diff: convert get_stat_data to struct object_id\n>   diff: convert diff_index_show_file to struct object_id\n>   diff: convert diff_addremove to struct object_id\n>   diff: convert run_diff_files to struct object_id\n>   diff: convert diff_change to struct object_id\n>   diff: convert fill_filespec to struct object_id\n>   diff: convert reuse_worktree_file to struct object_id\n>   diff: finish conversion for prepare_temp_file to struct object_id\n>   patch-ids: convert to struct object_id\n>   diff: convert diff_flush_patch_id to struct object_id\n>   combine-diff: convert diff_tree_combined to struct object_id\n>   combine-diff: convert find_paths_* to struct object_id\n>   tree-diff: convert diff_root_tree_sha1 to struct object_id\n>   notes-merge: convert notes_merge* to struct object_id\n>   notes-merge: convert merge_from_diffs to struct object_id\n>   notes-merge: convert find_notes_merge_pair_ps to struct object_id\n>   notes-merge: convert verify_notes_filepair to struct object_id\n>   notes-merge: convert write_note_to_worktree to struct object_id\n>   diff-tree: convert diff_tree_sha1 to struct object_id\n\nI've wanted to convert this function for some time.  I'm glad you got\naround to it.\n\nOther than the issue I pointed out, the fact that I'm obviously not\nqualified to review my own patches, and the issue that Stefan pointed\nout with GIT_MAX_HEXSZ, this looks good to me.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"321366","messageId":"xmqqtw3z2pat.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"CAGZ79kajzJGdN1uu5kni3AB31joP5hdnsWp1NBGkX3Rs-BkPpw@mail.gmail.com","subject":"Re: [PATCH 23/33] notes-merge: convert merge_from_diffs to struct object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T00:42:18Z","receivedAt":"2017-06-02T00:42:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n>>         trace_printf(\"\\tmerge_from_diffs(base = %.7s, local = %.7s, \"\n>> -              \"remote = %.7s)\\n\", sha1_to_hex(base), sha1_to_hex(local),\n>> -              sha1_to_hex(remote));\n>> +              \"remote = %.7s)\\n\", oid_to_hex(base), oid_to_hex(local),\n>> +              oid_to_hex(remote));\n>\n> This part is interesting.\n>\n> 7 used to be the default abbreviation length for sha1s (see\n> e6c587c733 (abbrev: auto size the default abbreviation, 2016-09-30)\n> for details) and this may have been a left over from the conversion\n> to variable length abbreviated hashes. This could be a reminder\n> we want to fix these, too. (Though not in this series?).\n>\n> Roughly like\n>\n>     trace_printf(\"\\tmerge_from_diffs(base = %s, local = %s, remote = %s)\\n\",\n>         find_unique_abbrev(base.hash, DEFAULT_ABBREV),\n>         find_unique_abbrev(local.hash, DEFAULT_ABBREV)\n>         find_unique_abbrev(remote.hash, DEFAULT_ABBREV));\n\nSharp eyes ;-) As you said, this is definitely outside the scope of\nthis series.\n\n"},{"id":"321367","messageId":"xmqqpoen2p2a.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170530173109.54904-26-bmwill@google.com","subject":"Re: [PATCH 25/33] notes-merge: convert verify_notes_filepair to struct object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T00:47:25Z","receivedAt":"2017-06-02T00:47:32Z","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> Signed-off-by: Brandon Williams <bmwill@google.com>\n> ---\n>  notes-merge.c | 20 ++++++++++----------\n>  1 file changed, 10 insertions(+), 10 deletions(-)\n>\n> diff --git a/notes-merge.c b/notes-merge.c\n> index 55dbb3659..962e9b1bc 100644\n> --- a/notes-merge.c\n> +++ b/notes-merge.c\n> @@ -22,21 +22,21 @@ void init_notes_merge_options(struct notes_merge_options *o)\n>  \to->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;\n>  }\n>  \n> -static int path_to_sha1(const char *path, unsigned char *sha1)\n> +static int path_to_oid(const char *path, struct object_id *oid)\n>  {\n> -\tchar hex_sha1[40];\n> +\tchar hex_oid[GIT_SHA1_HEXSZ];\n>  \tint i = 0;\n> -\twhile (*path && i < 40) {\n> +\twhile (*path && i < GIT_SHA1_HEXSZ) {\n>  \t\tif (*path != '/')\n> -\t\t\thex_sha1[i++] = *path;\n> +\t\t\thex_oid[i++] = *path;\n>  \t\tpath++;\n>  \t}\n\nIt's no brainer to do s/GIT_SHA1_HEXSZ/GIT_MAX_HEXSZ/ for all of the\nabove, but ...\n\n> -\tif (*path || i != 40)\n> +\tif (*path || i != GIT_SHA1_HEXSZ)\n>  \t\treturn -1;\n\n... this one is tricky.  \n\nWhat's in our envisioned future?  Are we expecing to see object\nnames, named with two or more hash functions, in a same repository?\nIf so, and one is 20 bytes and another one is 32 bytes, then this\nshould check 'i' against 40 and 64 and pass if 'i' is one of these\nexpected lengths?\n\n> -\treturn get_sha1_hex(hex_sha1, sha1);\n> +\treturn get_oid_hex(hex_oid, oid);\n>  }\n"},{"id":"321369","messageId":"xmqqlgpb2og9.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170530173109.54904-9-bmwill@google.com","subject":"Re: [PATCH 08/33] grep: convert to struct object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T01:00:38Z","receivedAt":"2017-06-02T01:00:46Z","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> Convert the remaining parts of grep to use struct object_id.\n>\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n> ---\n>  builtin/grep.c | 22 +++++++++++-----------\n>  cache.h        |  7 +++++++\n>  grep.c         | 17 ++++++++---------\n>  grep.h         |  2 +-\n>  4 files changed, 27 insertions(+), 21 deletions(-)\n> ...\n> +static inline struct object_id *oiddup(const struct object_id *src)\n> +{\n> +\tstruct object_id *dst = xmalloc(sizeof(struct object_id));\n> +\toidcpy(dst, src);\n> +\treturn dst;\n> +}\n> +\n>  static inline void hashclr(unsigned char *hash)\n>  {\n>  \tmemset(hash, 0, GIT_SHA1_RAWSZ);\n> diff --git a/grep.c b/grep.c\n> index 47cee4506..a240b4cdb 100644\n> --- a/grep.c\n> +++ b/grep.c\n> @@ -1747,9 +1747,8 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,\n>  \t\t * If the identifier is non-NULL (in the submodule case) it\n>  \t\t * will be a SHA1 that needs to be copied.\n>  \t\t */\n> -\tcase GREP_SOURCE_SHA1:\n> -\t\tgs->identifier = xmalloc(20);\n> -\t\thashcpy(gs->identifier, identifier);\n> +\tcase GREP_SOURCE_OID:\n> +\t\tgs->identifier = oiddup(identifier);\n>  \t\tbreak;\n>  \tcase GREP_SOURCE_BUF:\n>  \t\tgs->identifier = NULL;\n\nThese hunks triggered my \"Huh?\" meter a bit, simply because I tend\nto wonder not just \"is this useful in many other places?\" but also\n\"is it a good idea to encourage the use of this thing?\"; these look\nOK.\n\nThanks.\n\n"},{"id":"321370","messageId":"xmqqh8zz2nul.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170530185653.cfy4cbq3pmxfq5x6@genre.crustytoothpaste.net","subject":"Re: [PATCH 22/33] notes-merge: convert notes_merge* to struct object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T01:13:38Z","receivedAt":"2017-06-02T01:13:45Z","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>> diff --git a/notes-merge.h b/notes-merge.h\n>> index 0d890563b..eaa8e3b86 100644\n>> --- a/notes-merge.h\n>> +++ b/notes-merge.h\n>> @@ -33,15 +33,15 @@ void init_notes_merge_options(struct notes_merge_options *o);\n>>   *\n>>   * 1. The merge trivially results in an existing commit (e.g. fast-forward or\n>>   *    already-up-to-date). 'local_tree' is untouched, the SHA1 of the result\n>> - *    is written into 'result_sha1' and 0 is returned.\n>> + *    is written into 'result_oid' and 0 is returned.\n>>   * 2. The merge successfully completes, producing a merge commit. local_tree\n>>   *    contains the updated notes tree, the SHA1 of the resulting commit is\n>> - *    written into 'result_sha1', and 1 is returned.\n>> + *    written into 'result_oid', and 1 is returned.\n>>   * 3. The merge results in conflicts. This is similar to #2 in that the\n>>   *    partial merge result (i.e. merge result minus the unmerged entries)\n>>   *    are stored in 'local_tree', and the SHA1 or the resulting commit\n>>   *    (to be amended when the conflicts have been resolved) is written into\n>> - *    'result_sha1'. The unmerged entries are written into the\n>> + *    'result_oid'. The unmerged entries are written into the\n>>   *    .git/NOTES_MERGE_WORKTREE directory with conflict markers.\n>>   *    -1 is returned.\n>>   *\n>\n> Did you want to change the comment to say \"object ID\" or \"OID\" instead\n> of \"SHA1\" like you did in an earlier patch?\n\nYes, that's a good suggestion.  Will queue a trivial squash on top.\n"},{"id":"321371","messageId":"xmqqd1an2n92.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170530173109.54904-29-bmwill@google.com","subject":"Re: [PATCH 28/33] builtin/diff-tree: cleanup references to sha1","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T01:26:33Z","receivedAt":"2017-06-02T01:26:40Z","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> @@ -132,15 +131,14 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n>  \t * reverse the order of the objects if the second one\n>  \t * is marked UNINTERESTING.\n>  \t */\n> -\tnr_sha1 = opt->pending.nr;\n> -\tswitch (nr_sha1) {\n> +\tswitch (opt->pending.nr) {\n\nUnrelated to the topic of this patch, but I notice that the comment\nwhose tail shows in the pre-context of this hunk is incorrect.\n\n  We expect \"a..b\" to expand to \"^a b\" but it is perfectly possible\n  for revision range parser to produce \"b ^a\", which means the same\n  thing.  We we get the latter, i.e. the second one is marked\n  UNINTERESTING, we recover the original \"a..b\" by swapping the\n  order.\n\nis probably what we wanted to say.  These days, I suspect that we\nmay be able to do a lot better by using rev_cmdline_info thing,\nwhich did not exist when this code was written.\n\n"},{"id":"321372","messageId":"xmqq8tlb2n1g.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170530173109.54904-31-bmwill@google.com","subject":"Re: [PATCH 30/33] tree-diff: convert diff_tree_paths to struct object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T01:31:07Z","receivedAt":"2017-06-02T01:31:14Z","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> @@ -220,7 +221,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n>  \tif (emitthis) {\n>  \t\tint keep;\n>  \t\tstruct combine_diff_path *pprev = p;\n> -\t\tp = path_appendnew(p, nparent, base, path, pathlen, mode, sha1);\n> +\t\tp = path_appendnew(p, nparent, base, path, pathlen, mode, oid ? oid->hash : NULL);\n\nThis is a correct conversion, but it shows that \"struct oid\" that\nhas \"hash\" sometimes makes things a bit cumbersome.  Perhaps\npath_appendnew() and friends need to learn to take a pointer to\n\"struct oid\" next.\n\n"},{"id":"321373","messageId":"xmqq4lvz2mzm.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170530173109.54904-32-bmwill@google.com","subject":"Re: [PATCH 31/33] tree-diff: convert path_appendnew to object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T01:32:13Z","receivedAt":"2017-06-02T01:32:19Z","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> @@ -221,7 +221,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n>  \tif (emitthis) {\n>  \t\tint keep;\n>  \t\tstruct combine_diff_path *pprev = p;\n> -\t\tp = path_appendnew(p, nparent, base, path, pathlen, mode, oid ? oid->hash : NULL);\n> +\t\tp = path_appendnew(p, nparent, base, path, pathlen, mode, oid);\n>  \n>  \t\tfor (i = 0; i < nparent; ++i) {\n>  \t\t\t/*\n\nAhh, it happens here ;-)\n\nAnd of course, the order of these two patches cannot be swapped, so\nthis is the best organization of the series.\n\n"},{"id":"321374","messageId":"xmqqzidr18an.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170530173109.54904-1-bmwill@google.com","subject":"Re: [PATCH 00/33] object id conversion (grep and diff)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T01:34:56Z","receivedAt":"2017-06-02T01:35:02Z","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> A month or so ago I thought I would lend a hand to Brian and do a round of\n> conversions from sha1 -> struct object_id.  Now that Brian's latest series has\n> hit master I can finally send these patches out.\n>\n> The first couple patches are from Brian which convert some of the notes logic\n> to using 'struct object_id'.  The remaining patches are to convert the grep and\n> diff machinery to using 'struct object_id'.\n\nNicely done for all of them.  Thanks.  Will queue (with tweaks\nmentioned in the comments).\n"},{"id":"321375","messageId":"xmqqvaof1860.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"CAGZ79kbPaWEuZr1yXKnMwUeLzW4h_pnD-f2bEj7dyE7Q12z2sw@mail.gmail.com","subject":"Re: [PATCH 20/33] combine-diff: convert find_paths_* to struct object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T01:37:43Z","receivedAt":"2017-06-02T01:37:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Tue, May 30, 2017 at 10:30 AM, Brandon Williams <bmwill@google.com> wrote:\n>> Convert find_paths_generic and find_paths_multitree to use struct\n>> object_id.\n>>\n>>\n>\n> double empty line?\n\nIs it because\n\n\tsed -e 's/^Change-ID:.*//'\n\ninsead of\n\n\tsed -e '/^Change-ID:.*/d'\n\nis used somewhere in a commit-message-rewriting-machinery?\n\nIn any case, it doesn't bother Git at all---stripspace squishes\nduplicated empty lines into one while making other whitespace\nclean-ups like trailing SP removal and trailing blank line removal.\n\n"},{"id":"321386","messageId":"xmqqefv3yo23.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"xmqqzidr18an.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 00/33] object id conversion (grep and diff)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T05:08:04Z","receivedAt":"2017-06-02T05:08:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Brandon Williams <bmwill@google.com> writes:\n>\n>> A month or so ago I thought I would lend a hand to Brian and do a round of\n>> conversions from sha1 -> struct object_id.  Now that Brian's latest series has\n>> hit master I can finally send these patches out.\n>>\n>> The first couple patches are from Brian which convert some of the notes logic\n>> to using 'struct object_id'.  The remaining patches are to convert the grep and\n>> diff machinery to using 'struct object_id'.\n>\n> Nicely done for all of them.  Thanks.  Will queue (with tweaks\n> mentioned in the comments).\n\nOops.  I won't be able to queue this for now as it heavily conflicts\nwith blame-lib topic.  The resolution should be trivial, mechanical\nand boring, but takes time that I do not have today.\n"},{"id":"321394","messageId":"xmqqtw3yyhzc.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"xmqqefv3yo23.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 00/33] object id conversion (grep and diff)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T07:19:19Z","receivedAt":"2017-06-02T07:19:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Brandon Williams <bmwill@google.com> writes:\n>>\n>>> A month or so ago I thought I would lend a hand to Brian and do a round of\n>>> conversions from sha1 -> struct object_id.  Now that Brian's latest series has\n>>> hit master I can finally send these patches out.\n>>>\n>>> The first couple patches are from Brian which convert some of the notes logic\n>>> to using 'struct object_id'.  The remaining patches are to convert the grep and\n>>> diff machinery to using 'struct object_id'.\n>>\n>> Nicely done for all of them.  Thanks.  Will queue (with tweaks\n>> mentioned in the comments).\n>\n> Oops.  I won't be able to queue this for now as it heavily conflicts\n> with blame-lib topic.  The resolution should be trivial, mechanical\n> and boring, but takes time that I do not have today.\n\nI lied.  This also conflicts somewhat with Peff's diff-blob topic.\nI think I resolved them correctly (there needs evil merges applied\nto two files when merging this topic), and hopefully can push out\nthe result by the end of the day.\n\nThanks.\n"},{"id":"321415","messageId":"20170602182215.GA57260@google.com","threadId":"46073","inReplyTo":"xmqqtw3yyhzc.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 00/33] object id conversion (grep and diff)","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-06-02T18:22:15Z","receivedAt":"2017-06-02T18:22:22Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 06/02, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > Junio C Hamano <gitster@pobox.com> writes:\n> >\n> >> Brandon Williams <bmwill@google.com> writes:\n> >>\n> >>> A month or so ago I thought I would lend a hand to Brian and do a round of\n> >>> conversions from sha1 -> struct object_id.  Now that Brian's latest series has\n> >>> hit master I can finally send these patches out.\n> >>>\n> >>> The first couple patches are from Brian which convert some of the notes logic\n> >>> to using 'struct object_id'.  The remaining patches are to convert the grep and\n> >>> diff machinery to using 'struct object_id'.\n> >>\n> >> Nicely done for all of them.  Thanks.  Will queue (with tweaks\n> >> mentioned in the comments).\n> >\n> > Oops.  I won't be able to queue this for now as it heavily conflicts\n> > with blame-lib topic.  The resolution should be trivial, mechanical\n> > and boring, but takes time that I do not have today.\n> \n> I lied.  This also conflicts somewhat with Peff's diff-blob topic.\n> I think I resolved them correctly (there needs evil merges applied\n> to two files when merging this topic), and hopefully can push out\n> the result by the end of the day.\n> \n> Thanks.\n\nIf it ends up being too much of a headache for you to deal with, let me\nknow and I can rebase on top of those series.  That way you don't have to\ndeal with the conflict resolutions.  Just let me know what you'd like me\nto do.\n\n-- \nBrandon Williams\n"},{"id":"321416","messageId":"20170602183238.GB57260@google.com","threadId":"46073","inReplyTo":"20170530185653.cfy4cbq3pmxfq5x6@genre.crustytoothpaste.net","subject":"Re: [PATCH 22/33] notes-merge: convert notes_merge* to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-06-02T18:32:38Z","receivedAt":"2017-06-02T18:32:45Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/31, brian m. carlson wrote:\n> On Tue, May 30, 2017 at 10:30:58AM -0700, Brandon Williams wrote:\n> > @@ -596,47 +596,47 @@ int notes_merge(struct notes_merge_options *o,\n> >  \t/* Find merge bases */\n> >  \tbases = get_merge_bases(local, remote);\n> >  \tif (!bases) {\n> > -\t\tbase_sha1 = null_sha1;\n> > -\t\tbase_tree_sha1 = EMPTY_TREE_SHA1_BIN;\n> > +\t\tbase_oid = &null_oid;\n> > +\t\tbase_tree_oid = &empty_tree_oid;\n> >  \t\tif (o->verbosity >= 4)\n> >  \t\t\tprintf(\"No merge base found; doing history-less merge\\n\");\n> >  \t} else if (!bases->next) {\n> > -\t\tbase_sha1 = bases->item->object.oid.hash;\n> > -\t\tbase_tree_sha1 = bases->item->tree->object.oid.hash;\n> > +\t\tbase_oid = &bases->item->object.oid;\n> > +\t\tbase_tree_oid = &bases->item->tree->object.oid;\n> >  \t\tif (o->verbosity >= 4)\n> >  \t\t\tprintf(\"One merge base found (%.7s)\\n\",\n> > -\t\t\t\tsha1_to_hex(base_sha1));\n> > +\t\t\t       oid_to_hex(base_oid));\n> \n> I noticed you fixed up the indentation.  Thanks.\n> \n> > diff --git a/notes-merge.h b/notes-merge.h\n> > index 0d890563b..eaa8e3b86 100644\n> > --- a/notes-merge.h\n> > +++ b/notes-merge.h\n> > @@ -33,15 +33,15 @@ void init_notes_merge_options(struct notes_merge_options *o);\n> >   *\n> >   * 1. The merge trivially results in an existing commit (e.g. fast-forward or\n> >   *    already-up-to-date). 'local_tree' is untouched, the SHA1 of the result\n> > - *    is written into 'result_sha1' and 0 is returned.\n> > + *    is written into 'result_oid' and 0 is returned.\n> >   * 2. The merge successfully completes, producing a merge commit. local_tree\n> >   *    contains the updated notes tree, the SHA1 of the resulting commit is\n> > - *    written into 'result_sha1', and 1 is returned.\n> > + *    written into 'result_oid', and 1 is returned.\n> >   * 3. The merge results in conflicts. This is similar to #2 in that the\n> >   *    partial merge result (i.e. merge result minus the unmerged entries)\n> >   *    are stored in 'local_tree', and the SHA1 or the resulting commit\n> >   *    (to be amended when the conflicts have been resolved) is written into\n> > - *    'result_sha1'. The unmerged entries are written into the\n> > + *    'result_oid'. The unmerged entries are written into the\n> >   *    .git/NOTES_MERGE_WORKTREE directory with conflict markers.\n> >   *    -1 is returned.\n> >   *\n> \n> Did you want to change the comment to say \"object ID\" or \"OID\" instead\n> of \"SHA1\" like you did in an earlier patch?\n\nYep I can do that here and in the comment below this one.\n\n> -- \n> brian m. carlson / brian with sandals: Houston, Texas, US\n> https://www.crustytoothpaste.net/~bmc | My opinion only\n> OpenPGP: https://keybase.io/bk2204\n\n\n\n-- \nBrandon Williams\n"},{"id":"321417","messageId":"20170602185528.GC57260@google.com","threadId":"46073","inReplyTo":"xmqqpoen2p2a.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 25/33] notes-merge: convert verify_notes_filepair to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-06-02T18:55:28Z","receivedAt":"2017-06-02T18:55:43Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 06/02, Junio C Hamano wrote:\n> Brandon Williams <bmwill@google.com> writes:\n> \n> > Signed-off-by: Brandon Williams <bmwill@google.com>\n> > ---\n> >  notes-merge.c | 20 ++++++++++----------\n> >  1 file changed, 10 insertions(+), 10 deletions(-)\n> >\n> > diff --git a/notes-merge.c b/notes-merge.c\n> > index 55dbb3659..962e9b1bc 100644\n> > --- a/notes-merge.c\n> > +++ b/notes-merge.c\n> > @@ -22,21 +22,21 @@ void init_notes_merge_options(struct notes_merge_options *o)\n> >  \to->verbosity = NOTES_MERGE_VERBOSITY_DEFAULT;\n> >  }\n> >  \n> > -static int path_to_sha1(const char *path, unsigned char *sha1)\n> > +static int path_to_oid(const char *path, struct object_id *oid)\n> >  {\n> > -\tchar hex_sha1[40];\n> > +\tchar hex_oid[GIT_SHA1_HEXSZ];\n> >  \tint i = 0;\n> > -\twhile (*path && i < 40) {\n> > +\twhile (*path && i < GIT_SHA1_HEXSZ) {\n> >  \t\tif (*path != '/')\n> > -\t\t\thex_sha1[i++] = *path;\n> > +\t\t\thex_oid[i++] = *path;\n> >  \t\tpath++;\n> >  \t}\n> \n> It's no brainer to do s/GIT_SHA1_HEXSZ/GIT_MAX_HEXSZ/ for all of the\n> above, but ...\n\nI'll fix this.\n\n> \n> > -\tif (*path || i != 40)\n> > +\tif (*path || i != GIT_SHA1_HEXSZ)\n> >  \t\treturn -1;\n> \n> ... this one is tricky.  \n> \n> What's in our envisioned future?  Are we expecing to see object\n> names, named with two or more hash functions, in a same repository?\n> If so, and one is 20 bytes and another one is 32 bytes, then this\n> should check 'i' against 40 and 64 and pass if 'i' is one of these\n> expected lengths?\n\nThat's a good question, and at this point in time do we have an\nenvisioned future?  From some of our conversations I seem to remember\nthat we don't want a single repository to have objects based on two\ndifferent hash functions, but rather some translation layer to convert\nbetween two hashing functions (for compatibility with other\nnon-converted repos).  Though nothing has been settled upon yet so I\ndon't know what the future would look like (and the best way to prepare\nfor it).\n\n> \n> > -\treturn get_sha1_hex(hex_sha1, sha1);\n> > +\treturn get_oid_hex(hex_oid, oid);\n> >  }\n\n-- \nBrandon Williams\n"},{"id":"321422","messageId":"20170602192454.GD57260@google.com","threadId":"46073","inReplyTo":"20170531220640.kd73vbyx6fr4ht7h@genre.crustytoothpaste.net","subject":"Re: [PATCH 00/33] object id conversion (grep and diff)","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-06-02T19:24:54Z","receivedAt":"2017-06-02T19:25:02Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/31, brian m. carlson wrote:\n> On Tue, May 30, 2017 at 10:30:36AM -0700, Brandon Williams wrote:\n> > A month or so ago I thought I would lend a hand to Brian and do a round of\n> > conversions from sha1 -> struct object_id.  Now that Brian's latest series has\n> > hit master I can finally send these patches out.\n> > \n> > The first couple patches are from Brian which convert some of the notes logic\n> > to using 'struct object_id'.  The remaining patches are to convert the grep and\n> > diff machinery to using 'struct object_id'.\n> > \n> > Brandon Williams (26):\n> >   grep: convert to struct object_id\n> >   diff: convert get_stat_data to struct object_id\n> >   diff: convert diff_index_show_file to struct object_id\n> >   diff: convert diff_addremove to struct object_id\n> >   diff: convert run_diff_files to struct object_id\n> >   diff: convert diff_change to struct object_id\n> >   diff: convert fill_filespec to struct object_id\n> >   diff: convert reuse_worktree_file to struct object_id\n> >   diff: finish conversion for prepare_temp_file to struct object_id\n> >   patch-ids: convert to struct object_id\n> >   diff: convert diff_flush_patch_id to struct object_id\n> >   combine-diff: convert diff_tree_combined to struct object_id\n> >   combine-diff: convert find_paths_* to struct object_id\n> >   tree-diff: convert diff_root_tree_sha1 to struct object_id\n> >   notes-merge: convert notes_merge* to struct object_id\n> >   notes-merge: convert merge_from_diffs to struct object_id\n> >   notes-merge: convert find_notes_merge_pair_ps to struct object_id\n> >   notes-merge: convert verify_notes_filepair to struct object_id\n> >   notes-merge: convert write_note_to_worktree to struct object_id\n> >   diff-tree: convert diff_tree_sha1 to struct object_id\n> \n> I've wanted to convert this function for some time.  I'm glad you got\n> around to it.\n\nOf course, glad to help!  After working on this stuff I realized how serial this sort\nof conversion can be since its easy to have a function span many many\nparts of the code base.\n\n> \n> Other than the issue I pointed out, the fact that I'm obviously not\n> qualified to review my own patches, and the issue that Stefan pointed\n> out with GIT_MAX_HEXSZ, this looks good to me.\n> -- \n> brian m. carlson / brian with sandals: Houston, Texas, US\n> https://www.crustytoothpaste.net/~bmc | My opinion only\n> OpenPGP: https://keybase.io/bk2204\n\n\n\n-- \nBrandon Williams\n"},{"id":"321459","messageId":"xmqqpoemx8t4.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170602182215.GA57260@google.com","subject":"Re: [PATCH 00/33] object id conversion (grep and diff)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T23:35:03Z","receivedAt":"2017-06-02T23:35:11Z","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> On 06/02, Junio C Hamano wrote:\n>> \n>> I lied.  This also conflicts somewhat with Peff's diff-blob topic.\n>> I think I resolved them correctly (there needs evil merges applied\n>> to two files when merging this topic), and hopefully can push out\n>> the result by the end of the day.\n>> \n>> Thanks.\n>\n> If it ends up being too much of a headache for you to deal with, let me\n> know and I can rebase on top of those series.  That way you don't have to\n> deal with the conflict resolutions.  Just let me know what you'd like me\n> to do.\n\nSorry, I forgot to push the result out, even though I double checked\nthe conflict resolution I did last night.  Now it is in the public\nrepository.  I have one squash queued at the right place to update\nSHA1s to OIDs in the comment Brian pointed out.\n\nIf you ever need to rebase this on top of future 'master' that\nalready has js/blame-lib topic, fetching from me and checking\nthe evil merge I did may turn out to be helpful:\n\n $ git fetch git://github.com/gitster/git refs/merge-fix/bw/object-id\n $ git show FETCH_HEAD\n\nbut I can take patches based on the same old 'master'; as long as\nthe evil merge above is correct, that would probably be preferrable,\nas it makes it easier to compare the two iterations of your series.\n\nRepeating some backstory of \"merge-fix\" might be beneficial, if a\nreader is interested.  Otherwise the remainder of this message can\nsafely be skipped.\n\nAfter a topic (i.e. js/blame-lib) moves a lot of code around (i.e. a\nbulk of what used to be in builtin/blame.c is now in blame.c and\nsome in diff.c), merging a topic that touches places in the code\nthat was moved in-place (i.e. bw/object-id, which updates the code\nin builtin/blame.c) will leave a conflict that looks like:\n\n    <<<<<<< HEAD\n    ... very little that is left after moving\n    ... bunch of code out of this file\n    ||||||| common\n    ... a lot of\n    ... stuff before\n    ... your change from SHA1 to OID\n    ... is here\n    =======\n    ... a lot of\n    ... stuff after\n    ... your change from SHA1 to OID\n    ... is here\n    >>>>>>> theirs\n\nAs far as builtin/blame.c is concerned, the resolution for this\nset of conflicts is just to take the HEAD version, ignoring all of\nyour SHA1-to-OID changes.  Once it is resolved, \"rerere\" can help\nus remember this resolution to builtin/blame.c\n\nBut the ignored changes need to go somewhere else.\n\nWhat the user who is doing a merge does at this point is to compare\nwhat is between ||||||| and ======= (i.e. common ancestor's version)\nwith what is between ======= and >>>>>>> (i.e. their version) to\nfigure out what the branch being merged did.  And the user needs to\nknow where the common code went in the version in HEAD.\n\n $ git log [--no-merges] -p MERGE_HEAD.. -- builtin/blame.c\n\nis helpful to locate the commit that lost the common lines from the\nfile.  And \"git show\" on it will tell us that they mostly went to\nblame.c while some migrating to diff.c; we found out what you did by\ncomparing \"common\" and \"theirs\" in the previous step and we apply\nthese changes to these \"new\" places.\n\nAnd that is the diff you see in refs/merge-fix/bw/object-id.  The\nscript I use to re-build 'pu' every day (probably I use it three\ntimes a day on average) knows about that ref.  The script starts\nfrom the tip of 'master', and for each topic, (1) run \"git merge\"\ninto HEAD, (2) take resolution recorded by \"rerere\" and (3) if\nmerge/fix/$topic exists, cherry-pick it on top to squash into the\nmerge made in (2).\n\nOnce I have taught my rerere database and refs/merge-fix/ about this\nmerge, it is not too big a deal to redo the merge to adjust to an\nupdated 'master' or a new interation of your series because of the\nabove mechanism.  And that is why I say it is OK for an updated series\nto be based on the same old 'master'.\n\nThanks.\n\n\n"},{"id":"321460","messageId":"xmqqlgpax84s.fsf@gitster.mtv.corp.google.com","threadId":"46073","inReplyTo":"20170602185528.GC57260@google.com","subject":"Re: [PATCH 25/33] notes-merge: convert verify_notes_filepair to struct object_id","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-02T23:49:39Z","receivedAt":"2017-06-02T23:49:48Z","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> On 06/02, Junio C Hamano wrote:\n>> \n>> > -static int path_to_sha1(const char *path, unsigned char *sha1)\n>> > +static int path_to_oid(const char *path, struct object_id *oid)\n>> >  {\n>> > -\tchar hex_sha1[40];\n>> > +\tchar hex_oid[GIT_SHA1_HEXSZ];\n>> >  \tint i = 0;\n>> > -\twhile (*path && i < 40) {\n>> > +\twhile (*path && i < GIT_SHA1_HEXSZ) {\n>> >  \t\tif (*path != '/')\n>> > -\t\t\thex_sha1[i++] = *path;\n>> > +\t\t\thex_oid[i++] = *path;\n>> >  \t\tpath++;\n>> >  \t}\n>> \n>> It's no brainer to do s/GIT_SHA1_HEXSZ/GIT_MAX_HEXSZ/ for all of the\n>> above, but ...\n>\n> I'll fix this.\n>\n>> \n>> > -\tif (*path || i != 40)\n>> > +\tif (*path || i != GIT_SHA1_HEXSZ)\n>> >  \t\treturn -1;\n>> \n>> ... this one is tricky.  \n>> \n>> What's in our envisioned future?  Are we expecing to see object\n>> names, named with two or more hash functions, in a same repository?\n>> If so, and one is 20 bytes and another one is 32 bytes, then this\n>> should check 'i' against 40 and 64 and pass if 'i' is one of these\n>> expected lengths?\n>\n> That's a good question, and at this point in time do we have an\n> envisioned future?  From some of our conversations I seem to remember\n> that we don't want a single repository to have objects based on two\n> different hash functions, but rather some translation layer to convert\n> between two hashing functions (for compatibility with other\n> non-converted repos).  Though nothing has been settled upon yet so I\n> don't know what the future would look like (and the best way to prepare\n> for it).\n\nI do not think we know precisely what we want yet.  The \"MAX\" in the\nallocation size is an indication that we are allocating for the\nlargest variant possible in the version of Git being compiled, which\nis a hint that we anticipate that we may have multiple variants with\ndifferent sizes.  And that is where my \"against 40 and 64 ... one of\nthese expected lengths\" come from.  \n\nBut there is no such set of macros that define acceptable/expected\nlengths and that tells me that nobody among who defined, reviewed\nand accepted the MAX macro has thought this part through yet.\n\nI see Jonathan started talking about experiments with \"different\nhash\" elsewhere; I am reading his message as assuming one hash at a\ntime, and the repository tells us what the hash is.  And I think\nthat is one plausible design.\n\nIf we were to go that route, then\n\n    - MAX will be the maximum among hashes we can choose at the\n      beginning of a process (perhaps by consulting the repository\n      extension).\n\n    - In addition to GIT_SHA1_HEXSZ, GIT_SHA2_HEXSZ, and friends, we\n      need a variable that records the length of the hash chosen for\n      the process at the startup, GIT_OIDHASH_HEXSZ.  That would\n      become one of the fields in your \"struct repository\",\n\n        #define GIT_OIDHASH_HEXSZ (the_repository.oidhash_hexsz)\n\n      among other things like what the oid for an empty blob is.\n\nI'd say in the meantime we can do something like the attached and\nuse it here, perhaps?\n\n cache.h | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/cache.h b/cache.h\nindex 53999418d3..cafb13db9f 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -70,6 +70,10 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long);\n #define GIT_MAX_RAWSZ GIT_SHA1_RAWSZ\n #define GIT_MAX_HEXSZ GIT_SHA1_HEXSZ\n \n+/* The length for the object name hash */\n+#define GIT_OIDHASH_RAWSZ GIT_SHA1_RAWSZ\n+#define GIT_OIDHASH_HEXSZ GIT_SHA1_HEXSZ\n+\n struct object_id {\n \tunsigned char hash[GIT_MAX_RAWSZ];\n };\n"},{"id":"321554","messageId":"20170605194227.GE40426@google.com","threadId":"46073","inReplyTo":"xmqqpoemx8t4.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 00/33] object id conversion (grep and diff)","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-06-05T19:42:27Z","receivedAt":"2017-06-05T19:42:35Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 06/03, Junio C Hamano wrote:\n> Brandon Williams <bmwill@google.com> writes:\n> \n> > On 06/02, Junio C Hamano wrote:\n> >> \n> >> I lied.  This also conflicts somewhat with Peff's diff-blob topic.\n> >> I think I resolved them correctly (there needs evil merges applied\n> >> to two files when merging this topic), and hopefully can push out\n> >> the result by the end of the day.\n> >> \n> >> Thanks.\n> >\n> > If it ends up being too much of a headache for you to deal with, let me\n> > know and I can rebase on top of those series.  That way you don't have to\n> > deal with the conflict resolutions.  Just let me know what you'd like me\n> > to do.\n> \n> Sorry, I forgot to push the result out, even though I double checked\n> the conflict resolution I did last night.  Now it is in the public\n> repository.  I have one squash queued at the right place to update\n> SHA1s to OIDs in the comment Brian pointed out.\n> \n\nWhat you have at 'bw/object-id' matches the changes I made locally\n(changing SHA1 to OID) and looks good to me!\n\n> If you ever need to rebase this on top of future 'master' that\n> already has js/blame-lib topic, fetching from me and checking\n> the evil merge I did may turn out to be helpful:\n> \n>  $ git fetch git://github.com/gitster/git refs/merge-fix/bw/object-id\n>  $ git show FETCH_HEAD\n> \n> but I can take patches based on the same old 'master'; as long as\n> the evil merge above is correct, that would probably be preferrable,\n> as it makes it easier to compare the two iterations of your series.\n\nSounds like basing it on the original 'master' would work easiest for\nyou, so I'll continue to do that :)\n\n> \n> Repeating some backstory of \"merge-fix\" might be beneficial, if a\n> reader is interested.  Otherwise the remainder of this message can\n> safely be skipped.\n> \n> After a topic (i.e. js/blame-lib) moves a lot of code around (i.e. a\n> bulk of what used to be in builtin/blame.c is now in blame.c and\n> some in diff.c), merging a topic that touches places in the code\n> that was moved in-place (i.e. bw/object-id, which updates the code\n> in builtin/blame.c) will leave a conflict that looks like:\n> \n>     <<<<<<< HEAD\n>     ... very little that is left after moving\n>     ... bunch of code out of this file\n>     ||||||| common\n>     ... a lot of\n>     ... stuff before\n>     ... your change from SHA1 to OID\n>     ... is here\n>     =======\n>     ... a lot of\n>     ... stuff after\n>     ... your change from SHA1 to OID\n>     ... is here\n>     >>>>>>> theirs\n> \n> As far as builtin/blame.c is concerned, the resolution for this\n> set of conflicts is just to take the HEAD version, ignoring all of\n> your SHA1-to-OID changes.  Once it is resolved, \"rerere\" can help\n> us remember this resolution to builtin/blame.c\n> \n> But the ignored changes need to go somewhere else.\n> \n> What the user who is doing a merge does at this point is to compare\n> what is between ||||||| and ======= (i.e. common ancestor's version)\n> with what is between ======= and >>>>>>> (i.e. their version) to\n> figure out what the branch being merged did.  And the user needs to\n> know where the common code went in the version in HEAD.\n> \n>  $ git log [--no-merges] -p MERGE_HEAD.. -- builtin/blame.c\n> \n> is helpful to locate the commit that lost the common lines from the\n> file.  And \"git show\" on it will tell us that they mostly went to\n> blame.c while some migrating to diff.c; we found out what you did by\n> comparing \"common\" and \"theirs\" in the previous step and we apply\n> these changes to these \"new\" places.\n> \n> And that is the diff you see in refs/merge-fix/bw/object-id.  The\n> script I use to re-build 'pu' every day (probably I use it three\n> times a day on average) knows about that ref.  The script starts\n> from the tip of 'master', and for each topic, (1) run \"git merge\"\n> into HEAD, (2) take resolution recorded by \"rerere\" and (3) if\n> merge/fix/$topic exists, cherry-pick it on top to squash into the\n> merge made in (2).\n> \n> Once I have taught my rerere database and refs/merge-fix/ about this\n> merge, it is not too big a deal to redo the merge to adjust to an\n> updated 'master' or a new interation of your series because of the\n> above mechanism.  And that is why I say it is OK for an updated series\n> to be based on the same old 'master'.\n> \n> Thanks.\n> \n> \n\n-- \nBrandon Williams\n"},{"id":"324580","messageId":"28328b72-40c0-f6bb-09dc-574ca33ce622@web.de","threadId":"46073","inReplyTo":"20170530173109.54904-31-bmwill@google.com","subject":"Re: [PATCH 30/33] tree-diff: convert diff_tree_paths to struct object_id","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2017-07-15T17:18:51Z","receivedAt":"2017-07-15T17:19:26Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 30.05.2017 um 19:31 schrieb Brandon Williams:\n> @@ -273,21 +274,20 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n>   \t}\n>   \n>   \tif (recurse) {\n> -\t\tconst unsigned char **parents_sha1;\n> +\t\tconst struct object_id **parents_oid;\n>   \n> -\t\tFAST_ARRAY_ALLOC(parents_sha1, nparent);\n> +\t\tFAST_ARRAY_ALLOC(parents_oid, nparent);\n>   \t\tfor (i = 0; i < nparent; ++i) {\n>   \t\t\t/* same rule as in emitthis */\n>   \t\t\tint tpi_valid = tp && !(tp[i].entry.mode & S_IFXMIN_NEQ);\n>   \n> -\t\t\tparents_sha1[i] = tpi_valid ? tp[i].entry.oid->hash\n> -\t\t\t\t\t\t    : NULL;\n> +\t\t\tparents_oid[i] = tpi_valid ? tp[i].entry.oid : NULL;\n>   \t\t}\n\nSo elements of parents_oid can be NULL...\n\n>   \n>   \t\tstrbuf_add(base, path, pathlen);\n>   \t\tstrbuf_addch(base, '/');\n> -\t\tp = ll_diff_tree_paths(p, sha1, parents_sha1, nparent, base, opt);\n> -\t\tFAST_ARRAY_FREE(parents_sha1, nparent);\n> +\t\tp = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt);\n\n... and we pass that array to ll_diff_tree_paths()...\n\n> +\t\tFAST_ARRAY_FREE(parents_oid, nparent);\n>   \t}\n>   \n>   \tstrbuf_setlen(base, old_baselen);\n> @@ -312,7 +312,7 @@ static void skip_uninteresting(struct tree_desc *t, struct strbuf *base,\n>   \n>   \n>   /*\n> - * generate paths for combined diff D(sha1,parents_sha1[])\n> + * generate paths for combined diff D(sha1,parents_oid[])\n>    *\n>    * Resulting paths are appended to combine_diff_path linked list, and also, are\n>    * emitted on the go via opt->pathchange() callback, so it is possible to\n> @@ -404,8 +404,8 @@ static inline void update_tp_entries(struct tree_desc *tp, int nparent)\n>   }\n>   \n>   static struct combine_diff_path *ll_diff_tree_paths(\n> -\tstruct combine_diff_path *p, const unsigned char *sha1,\n> -\tconst unsigned char **parents_sha1, int nparent,\n> +\tstruct combine_diff_path *p, const struct object_id *oid,\n> +\tconst struct object_id **parents_oid, int nparent,\n>   \tstruct strbuf *base, struct diff_options *opt)\n>   {\n>   \tstruct tree_desc t, *tp;\n> @@ -422,8 +422,8 @@ static struct combine_diff_path *ll_diff_tree_paths(\n>   \t *   diff_tree_oid(parent, commit) )\n>   \t */\n>   \tfor (i = 0; i < nparent; ++i)\n> -\t\ttptree[i] = fill_tree_descriptor(&tp[i], parents_sha1[i]);\n> -\tttree = fill_tree_descriptor(&t, sha1);\n> +\t\ttptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]->hash);\n\n... and here we are in that function, dereferencing a pointer that may\nbe NULL.\n\n> +\tttree = fill_tree_descriptor(&t, oid->hash);\n\noid here can also be NULL, but I think that's not as easy to see.\n\n-- >8 --\nSubject: [PATCH] tree-diff: don't access hash of NULL object_id pointer\n\nThe object_id pointers can be NULL for invalid entries.  Don't try to\ndereference them and pass NULL along to fill_tree_descriptor() instead,\nwhich handles them just fine.\n\nFound with Clang's UBSan.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\nfill_tree_descriptor() can easily be converted to object_id, by the\nway, which would get us rid of the extra check introduced here, but\nthis patch is meant as a minimal fix.\n\n tree-diff.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/tree-diff.c b/tree-diff.c\nindex bd6d65a409..2357f72899 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -421,8 +421,9 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t *   diff_tree_oid(parent, commit) )\n \t */\n \tfor (i = 0; i < nparent; ++i)\n-\t\ttptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]->hash);\n-\tttree = fill_tree_descriptor(&t, oid->hash);\n+\t\ttptree[i] = fill_tree_descriptor(&tp[i],\n+\t\t\t\tparents_oid[i] ? parents_oid[i]->hash : NULL);\n+\tttree = fill_tree_descriptor(&t, oid ? oid->hash : NULL);\n \n \t/* Enable recursion indefinitely */\n \topt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);\n-- \n2.13.3\n"},{"id":"324581","messageId":"20170715172230.x65t5pof4upkonpl@genre.crustytoothpaste.net","threadId":"46073","inReplyTo":"28328b72-40c0-f6bb-09dc-574ca33ce622@web.de","subject":"Re: [PATCH 30/33] tree-diff: convert diff_tree_paths to struct object_id","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-07-15T17:22:30Z","receivedAt":"2017-07-15T17:22:41Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sat, Jul 15, 2017 at 07:18:51PM +0200, René Scharfe wrote:\n> -- >8 --\n> Subject: [PATCH] tree-diff: don't access hash of NULL object_id pointer\n> \n> The object_id pointers can be NULL for invalid entries.  Don't try to\n> dereference them and pass NULL along to fill_tree_descriptor() instead,\n> which handles them just fine.\n> \n> Found with Clang's UBSan.\n> \n> Signed-off-by: Rene Scharfe <l.s.r@web.de>\n> ---\n> fill_tree_descriptor() can easily be converted to object_id, by the\n> way, which would get us rid of the extra check introduced here, but\n> this patch is meant as a minimal fix.\n> \n>  tree-diff.c | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n> \n> diff --git a/tree-diff.c b/tree-diff.c\n> index bd6d65a409..2357f72899 100644\n> --- a/tree-diff.c\n> +++ b/tree-diff.c\n> @@ -421,8 +421,9 @@ static struct combine_diff_path *ll_diff_tree_paths(\n>  \t *   diff_tree_oid(parent, commit) )\n>  \t */\n>  \tfor (i = 0; i < nparent; ++i)\n> -\t\ttptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]->hash);\n> -\tttree = fill_tree_descriptor(&t, oid->hash);\n> +\t\ttptree[i] = fill_tree_descriptor(&tp[i],\n> +\t\t\t\tparents_oid[i] ? parents_oid[i]->hash : NULL);\n> +\tttree = fill_tree_descriptor(&t, oid ? oid->hash : NULL);\n\nGood catch.  This seems obviously correct.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"324582","messageId":"4c10c481-45c9-1b36-d83f-f70adca60bdb@web.de","threadId":"46073","inReplyTo":"20170530173109.54904-5-bmwill@google.com","subject":"Re: [PATCH 04/33] notes: make get_note return pointer to struct object_id","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2017-07-15T18:15:26Z","receivedAt":"2017-07-15T18:16:02Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 30.05.2017 um 19:30 schrieb Brandon Williams:\n> @@ -392,7 +392,7 @@ static int add(int argc, const char **argv, const char *prefix)\n>   \tconst char *object_ref;\n>   \tstruct notes_tree *t;\n>   \tunsigned char object[20], new_note[20];\n> -\tconst unsigned char *note;\n> +\tconst struct object_id *note;\n>   \tstruct note_data d = { 0, 0, NULL, STRBUF_INIT };\n>   \tstruct option options[] = {\n>   \t\t{ OPTION_CALLBACK, 'm', \"message\", &d, N_(\"message\"),\n\nIn between here, note can be set to NULL...\n\n> @@ -453,7 +453,7 @@ static int add(int argc, const char **argv, const char *prefix)\n>   \t\t\tsha1_to_hex(object));\n>   \t}\n>   \n> -\tprepare_note_data(object, &d, note);\n> +\tprepare_note_data(object, &d, note->hash);\n\n... which we then dereference here.\n\n> @@ -598,13 +598,13 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n>   \tt = init_notes_check(argv[0], NOTES_INIT_WRITABLE);\n>   \tnote = get_note(t, object);\n>   \n> -\tprepare_note_data(object, &d, edit ? note : NULL);\n> +\tprepare_note_data(object, &d, edit && note ? note->hash : NULL);\n\nHere a NULL check was added; we need a similar one above as well.\n\n-- >8 --\nSubject: [PATCH] notes: don't access hash of NULL object_id pointer\n\nCheck if note is NULL, as we already do for different purposes a few\nlines above, and pass a NULL pointer to prepare_note_data() in that\ncase instead of trying to access the hash member.\n\nFound with Clang's UBSan.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\nThe third parameter of prepare_note_data() could easily be turned into\nan object_id pointer (and it should), but this patch is meant to be a\nminimal fix.\n\n builtin/notes.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 77573cf1ea..4303848e04 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -456,7 +456,7 @@ static int add(int argc, const char **argv, const char *prefix)\n \t\t\toid_to_hex(&object));\n \t}\n \n-\tprepare_note_data(&object, &d, note->hash);\n+\tprepare_note_data(&object, &d, note ? note->hash : NULL);\n \tif (d.buf.len || allow_empty) {\n \t\twrite_note_data(&d, new_note.hash);\n \t\tif (add_note(t, &object, &new_note, combine_notes_overwrite))\n-- \n2.13.3\n"},{"id":"324653","messageId":"20170717174925.GA10548@google.com","threadId":"46073","inReplyTo":"4c10c481-45c9-1b36-d83f-f70adca60bdb@web.de","subject":"Re: [PATCH 04/33] notes: make get_note return pointer to struct object_id","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-07-17T17:49:25Z","receivedAt":"2017-07-17T17:49:34Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 07/15, René Scharfe wrote:\n> Am 30.05.2017 um 19:30 schrieb Brandon Williams:\n> > @@ -392,7 +392,7 @@ static int add(int argc, const char **argv, const char *prefix)\n> >   \tconst char *object_ref;\n> >   \tstruct notes_tree *t;\n> >   \tunsigned char object[20], new_note[20];\n> > -\tconst unsigned char *note;\n> > +\tconst struct object_id *note;\n> >   \tstruct note_data d = { 0, 0, NULL, STRBUF_INIT };\n> >   \tstruct option options[] = {\n> >   \t\t{ OPTION_CALLBACK, 'm', \"message\", &d, N_(\"message\"),\n> \n> In between here, note can be set to NULL...\n> \n> > @@ -453,7 +453,7 @@ static int add(int argc, const char **argv, const char *prefix)\n> >   \t\t\tsha1_to_hex(object));\n> >   \t}\n> >   \n> > -\tprepare_note_data(object, &d, note);\n> > +\tprepare_note_data(object, &d, note->hash);\n> \n> ... which we then dereference here.\n> \n> > @@ -598,13 +598,13 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n> >   \tt = init_notes_check(argv[0], NOTES_INIT_WRITABLE);\n> >   \tnote = get_note(t, object);\n> >   \n> > -\tprepare_note_data(object, &d, edit ? note : NULL);\n> > +\tprepare_note_data(object, &d, edit && note ? note->hash : NULL);\n> \n> Here a NULL check was added; we need a similar one above as well.\n> \n> -- >8 --\n> Subject: [PATCH] notes: don't access hash of NULL object_id pointer\n> \n> Check if note is NULL, as we already do for different purposes a few\n> lines above, and pass a NULL pointer to prepare_note_data() in that\n> case instead of trying to access the hash member.\n\nLooks good, thanks for catching this!\n\n> \n> Found with Clang's UBSan.\n> \n> Signed-off-by: Rene Scharfe <l.s.r@web.de>\n> ---\n> The third parameter of prepare_note_data() could easily be turned into\n> an object_id pointer (and it should), but this patch is meant to be a\n> minimal fix.\n> \n>  builtin/notes.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/builtin/notes.c b/builtin/notes.c\n> index 77573cf1ea..4303848e04 100644\n> --- a/builtin/notes.c\n> +++ b/builtin/notes.c\n> @@ -456,7 +456,7 @@ static int add(int argc, const char **argv, const char *prefix)\n>  \t\t\toid_to_hex(&object));\n>  \t}\n>  \n> -\tprepare_note_data(&object, &d, note->hash);\n> +\tprepare_note_data(&object, &d, note ? note->hash : NULL);\n>  \tif (d.buf.len || allow_empty) {\n>  \t\twrite_note_data(&d, new_note.hash);\n>  \t\tif (add_note(t, &object, &new_note, combine_notes_overwrite))\n> -- \n> 2.13.3\n\n-- \nBrandon Williams\n"}]}