Skip to content

Commit aaa3c80

Browse files
committed
Merge branch 'bc/hash-transition-interop-part-1'
SHA-256 transition. * bc/hash-transition-interop-part-1: hex: print objects using the hash algorithm member hex: default to the_hash_algo on zero algorithm value builtin/pack-objects: avoid using struct object_id for pack hash commit-graph: don't store file hashes as struct object_id builtin/show-index: set the algorithm for object IDs hash: provide per-algorithm null OIDs hash: set, copy, and use algo field in struct object_id builtin/pack-redundant: avoid casting buffers to struct object_id Use the final_oid_fn to finalize hashing of object IDs hash: add a function to finalize object IDs http-push: set algorithm when reading object ID Always use oidread to read into struct object_id hash: add an algo member to struct object_id
2 parents 2d677e5 + 3dd7146 commit aaa3c80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+304
-197
lines changed

archive.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static void queue_directory(const unsigned char *sha1,
203203
d->mode = mode;
204204
c->bottom = d;
205205
d->len = xsnprintf(d->path, len, "%.*s%s/", (int)base->len, base->buf, filename);
206-
hashcpy(d->oid.hash, sha1);
206+
oidread(&d->oid, sha1);
207207
}
208208

209209
static int write_directory(struct archiver_context *c)
@@ -275,9 +275,11 @@ int write_archive_entries(struct archiver_args *args,
275275
int err;
276276
struct strbuf path_in_archive = STRBUF_INIT;
277277
struct strbuf content = STRBUF_INIT;
278-
struct object_id fake_oid = null_oid;
278+
struct object_id fake_oid;
279279
int i;
280280

281+
oidcpy(&fake_oid, null_oid());
282+
281283
if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
282284
size_t len = args->baselen;
283285

blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
242242
switch (st.st_mode & S_IFMT) {
243243
case S_IFREG:
244244
if (opt->flags.allow_textconv &&
245-
textconv_object(r, read_from, mode, &null_oid, 0, &buf_ptr, &buf_len))
245+
textconv_object(r, read_from, mode, null_oid(), 0, &buf_ptr, &buf_len))
246246
strbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);
247247
else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
248248
die_errno("cannot open or read '%s'", read_from);

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void create_branch(struct repository *r,
322322
transaction = ref_transaction_begin(&err);
323323
if (!transaction ||
324324
ref_transaction_update(transaction, ref.buf,
325-
&oid, forcing ? NULL : &null_oid,
325+
&oid, forcing ? NULL : null_oid(),
326326
0, msg, &err) ||
327327
ref_transaction_commit(transaction, &err))
328328
die("%s", err.buf);

builtin/checkout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm
106106
int changed)
107107
{
108108
return run_hook_le(NULL, "post-checkout",
109-
oid_to_hex(old_commit ? &old_commit->object.oid : &null_oid),
110-
oid_to_hex(new_commit ? &new_commit->object.oid : &null_oid),
109+
oid_to_hex(old_commit ? &old_commit->object.oid : null_oid()),
110+
oid_to_hex(new_commit ? &new_commit->object.oid : null_oid()),
111111
changed ? "1" : "0", NULL);
112112
/* "new_commit" can be NULL when checking out from the index before
113113
a commit exists. */
@@ -644,7 +644,7 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
644644
opts.src_index = &the_index;
645645
opts.dst_index = &the_index;
646646
init_checkout_metadata(&opts.meta, info->refname,
647-
info->commit ? &info->commit->object.oid : &null_oid,
647+
info->commit ? &info->commit->object.oid : null_oid(),
648648
NULL);
649649
parse_tree(tree);
650650
init_tree_desc(&tree_desc, tree->buffer, tree->size);

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ static int checkout(int submodule_progress)
820820
if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
821821
die(_("unable to write new index file"));
822822

823-
err |= run_hook_le(NULL, "post-checkout", oid_to_hex(&null_oid),
823+
err |= run_hook_le(NULL, "post-checkout", oid_to_hex(null_oid()),
824824
oid_to_hex(&oid), "1", NULL);
825825

826826
if (!err && (option_recurse_submodules.nr > 0)) {

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
502502
{
503503
struct rev_info revs;
504504
struct strvec args = STRVEC_INIT;
505-
struct process_commit_data pcd = { null_oid, oid, dst, &revs};
505+
struct process_commit_data pcd = { *null_oid(), oid, dst, &revs};
506506

507507
strvec_pushl(&args, "internal: The first arg is not parsed",
508508
"--objects", "--in-commit-order", "--reverse", "HEAD",

builtin/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int builtin_diff_b_f(struct rev_info *revs,
9898

9999
stuff_change(&revs->diffopt,
100100
blob[0]->mode, canon_mode(st.st_mode),
101-
&blob[0]->item->oid, &null_oid,
101+
&blob[0]->item->oid, null_oid(),
102102
1, 0,
103103
blob[0]->path ? blob[0]->path : path,
104104
path);

builtin/fast-export.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ static void handle_tag(const char *name, struct tag *tag)
870870
p = rewrite_commit((struct commit *)tagged);
871871
if (!p) {
872872
printf("reset %s\nfrom %s\n\n",
873-
name, oid_to_hex(&null_oid));
873+
name, oid_to_hex(null_oid()));
874874
free(buf);
875875
return;
876876
}
@@ -884,7 +884,7 @@ static void handle_tag(const char *name, struct tag *tag)
884884

885885
if (tagged->type == OBJ_TAG) {
886886
printf("reset %s\nfrom %s\n\n",
887-
name, oid_to_hex(&null_oid));
887+
name, oid_to_hex(null_oid()));
888888
}
889889
skip_prefix(name, "refs/tags/", &name);
890890
printf("tag %s\n", name);
@@ -1016,7 +1016,7 @@ static void handle_tags_and_duplicates(struct string_list *extras)
10161016
* it.
10171017
*/
10181018
printf("reset %s\nfrom %s\n\n",
1019-
name, oid_to_hex(&null_oid));
1019+
name, oid_to_hex(null_oid()));
10201020
continue;
10211021
}
10221022

@@ -1035,7 +1035,7 @@ static void handle_tags_and_duplicates(struct string_list *extras)
10351035
if (!reference_excluded_commits) {
10361036
/* delete the ref */
10371037
printf("reset %s\nfrom %s\n\n",
1038-
name, oid_to_hex(&null_oid));
1038+
name, oid_to_hex(null_oid()));
10391039
continue;
10401040
}
10411041
/* set ref to commit using oid, not mark */
@@ -1146,7 +1146,7 @@ static void handle_deletes(void)
11461146
continue;
11471147

11481148
printf("reset %s\nfrom %s\n\n",
1149-
refspec->dst, oid_to_hex(&null_oid));
1149+
refspec->dst, oid_to_hex(null_oid()));
11501150
}
11511151
}
11521152

builtin/fast-import.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ static int store_object(
940940
the_hash_algo->init_fn(&c);
941941
the_hash_algo->update_fn(&c, hdr, hdrlen);
942942
the_hash_algo->update_fn(&c, dat->buf, dat->len);
943-
the_hash_algo->final_fn(oid.hash, &c);
943+
the_hash_algo->final_oid_fn(&oid, &c);
944944
if (oidout)
945945
oidcpy(oidout, &oid);
946946

@@ -1136,7 +1136,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
11361136
}
11371137
}
11381138
git_deflate_end(&s);
1139-
the_hash_algo->final_fn(oid.hash, &c);
1139+
the_hash_algo->final_oid_fn(&oid, &c);
11401140

11411141
if (oidout)
11421142
oidcpy(oidout, &oid);
@@ -1276,8 +1276,8 @@ static void load_tree(struct tree_entry *root)
12761276
e->versions[0].mode = e->versions[1].mode;
12771277
e->name = to_atom(c, strlen(c));
12781278
c += e->name->str_len + 1;
1279-
hashcpy(e->versions[0].oid.hash, (unsigned char *)c);
1280-
hashcpy(e->versions[1].oid.hash, (unsigned char *)c);
1279+
oidread(&e->versions[0].oid, (unsigned char *)c);
1280+
oidread(&e->versions[1].oid, (unsigned char *)c);
12811281
c += the_hash_algo->rawsz;
12821282
}
12831283
free(buf);

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static int grep_submodule(struct grep_opt *opt,
421421
struct grep_opt subopt;
422422
int hit;
423423

424-
sub = submodule_from_path(superproject, &null_oid, path);
424+
sub = submodule_from_path(superproject, null_oid(), path);
425425

426426
if (!is_submodule_active(superproject, path))
427427
return 0;

0 commit comments

Comments
 (0)