Skip to content

Commit 8be8342

Browse files
committed
Merge branch 'po/object-id'
Conversion from uchar[20] to struct object_id continues. * po/object-id: sha1_file: rename hash_sha1_file_literally sha1_file: convert write_loose_object to object_id sha1_file: convert force_object_loose to object_id sha1_file: convert write_sha1_file to object_id notes: convert write_notes_tree to object_id notes: convert combine_notes_* to object_id commit: convert commit_tree* to object_id match-trees: convert splice_tree to object_id cache: clear whole hash buffer with oidclr sha1_file: convert hash_sha1_file to object_id dir: convert struct sha1_stat to use object_id sha1_file: convert pretend_sha1_file to object_id
2 parents 157ee05 + 1752cbb commit 8be8342

39 files changed

+302
-281
lines changed

Documentation/technical/api-object-access.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Talk about <sha1_file.c> and <object.h> family, things like
77
* read_object_with_reference()
88
* has_sha1_file()
99
* write_sha1_file()
10-
* pretend_sha1_file()
10+
* pretend_object_file()
1111
* lookup_{object,commit,tag,blob,tree}
1212
* parse_{object,commit,tag,blob,tree}
1313
* Use of object flags

apply.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,7 +3154,7 @@ static int apply_binary(struct apply_state *state,
31543154
* See if the old one matches what the patch
31553155
* applies to.
31563156
*/
3157-
hash_sha1_file(img->buf, img->len, blob_type, oid.hash);
3157+
hash_object_file(img->buf, img->len, blob_type, &oid);
31583158
if (strcmp(oid_to_hex(&oid), patch->old_sha1_prefix))
31593159
return error(_("the patch applies to '%s' (%s), "
31603160
"which does not match the "
@@ -3199,7 +3199,7 @@ static int apply_binary(struct apply_state *state,
31993199
name);
32003200

32013201
/* verify that the result matches */
3202-
hash_sha1_file(img->buf, img->len, blob_type, oid.hash);
3202+
hash_object_file(img->buf, img->len, blob_type, &oid);
32033203
if (strcmp(oid_to_hex(&oid), patch->new_sha1_prefix))
32043204
return error(_("binary patch to '%s' creates incorrect result (expecting %s, got %s)"),
32053205
name, patch->new_sha1_prefix, oid_to_hex(&oid));
@@ -3554,7 +3554,7 @@ static int try_threeway(struct apply_state *state,
35543554

35553555
/* Preimage the patch was prepared for */
35563556
if (patch->is_new)
3557-
write_sha1_file("", 0, blob_type, pre_oid.hash);
3557+
write_object_file("", 0, blob_type, &pre_oid);
35583558
else if (get_oid(patch->old_sha1_prefix, &pre_oid) ||
35593559
read_blob_object(&buf, &pre_oid, patch->old_mode))
35603560
return error(_("repository lacks the necessary blob to fall back on 3-way merge."));
@@ -3570,7 +3570,7 @@ static int try_threeway(struct apply_state *state,
35703570
return -1;
35713571
}
35723572
/* post_oid is theirs */
3573-
write_sha1_file(tmp_image.buf, tmp_image.len, blob_type, post_oid.hash);
3573+
write_object_file(tmp_image.buf, tmp_image.len, blob_type, &post_oid);
35743574
clear_image(&tmp_image);
35753575

35763576
/* our_oid is ours */
@@ -3583,7 +3583,7 @@ static int try_threeway(struct apply_state *state,
35833583
return error(_("cannot read the current contents of '%s'"),
35843584
patch->old_name);
35853585
}
3586-
write_sha1_file(tmp_image.buf, tmp_image.len, blob_type, our_oid.hash);
3586+
write_object_file(tmp_image.buf, tmp_image.len, blob_type, &our_oid);
35873587
clear_image(&tmp_image);
35883588

35893589
/* in-core three-way merge between post and our using pre as base */
@@ -4291,7 +4291,7 @@ static int add_index_file(struct apply_state *state,
42914291
}
42924292
fill_stat_cache_info(ce, &st);
42934293
}
4294-
if (write_sha1_file(buf, size, blob_type, ce->oid.hash) < 0) {
4294+
if (write_object_file(buf, size, blob_type, &ce->oid) < 0) {
42954295
free(ce);
42964296
return error(_("unable to create backing store "
42974297
"for newly created file %s"), path);

blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
232232
convert_to_git(&the_index, path, buf.buf, buf.len, &buf, 0);
233233
origin->file.ptr = buf.buf;
234234
origin->file.size = buf.len;
235-
pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_oid.hash);
235+
pretend_object_file(buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);
236236

237237
/*
238238
* Read the current index, replace the path entry with

builtin/am.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,8 +1641,8 @@ static void do_commit(const struct am_state *state)
16411641
setenv("GIT_COMMITTER_DATE",
16421642
state->ignore_date ? "" : state->author_date, 1);
16431643

1644-
if (commit_tree(state->msg, state->msg_len, tree.hash, parents, commit.hash,
1645-
author, state->sign_commit))
1644+
if (commit_tree(state->msg, state->msg_len, &tree, parents, &commit,
1645+
author, state->sign_commit))
16461646
die(_("failed to write commit object"));
16471647

16481648
reflog_msg = getenv("GIT_REFLOG_ACTION");

builtin/checkout.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ static int checkout_merged(int pos, const struct checkout *state)
227227
* (it also writes the merge result to the object database even
228228
* when it may contain conflicts).
229229
*/
230-
if (write_sha1_file(result_buf.ptr, result_buf.size,
231-
blob_type, oid.hash))
230+
if (write_object_file(result_buf.ptr, result_buf.size, blob_type, &oid))
232231
die(_("Unable to add merge result for '%s'"), path);
233232
free(result_buf.ptr);
234233
ce = make_cache_entry(mode, oid.hash, path, 2, 0);

builtin/commit-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
117117
die_errno("git commit-tree: failed to read");
118118
}
119119

120-
if (commit_tree(buffer.buf, buffer.len, tree_oid.hash, parents,
121-
commit_oid.hash, NULL, sign_commit)) {
120+
if (commit_tree(buffer.buf, buffer.len, &tree_oid, parents, &commit_oid,
121+
NULL, sign_commit)) {
122122
strbuf_release(&buffer);
123123
return 1;
124124
}

builtin/commit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,8 +1579,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
15791579
append_merge_tag_headers(parents, &tail);
15801580
}
15811581

1582-
if (commit_tree_extended(sb.buf, sb.len, active_cache_tree->oid.hash,
1583-
parents, oid.hash, author_ident.buf, sign_commit, extra)) {
1582+
if (commit_tree_extended(sb.buf, sb.len, &active_cache_tree->oid,
1583+
parents, &oid, author_ident.buf, sign_commit,
1584+
extra)) {
15841585
rollback_index_files();
15851586
die(_("failed to write commit object"));
15861587
}

builtin/hash-object.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig
2424
if (strbuf_read(&buf, fd, 4096) < 0)
2525
ret = -1;
2626
else
27-
ret = hash_sha1_file_literally(buf.buf, buf.len, type, oid, flags);
27+
ret = hash_object_file_literally(buf.buf, buf.len, type, oid,
28+
flags);
2829
strbuf_release(&buf);
2930
return ret;
3031
}

builtin/index-pack.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -958,9 +958,8 @@ static void resolve_delta(struct object_entry *delta_obj,
958958
free(delta_data);
959959
if (!result->data)
960960
bad_object(delta_obj->idx.offset, _("failed to apply delta"));
961-
hash_sha1_file(result->data, result->size,
962-
typename(delta_obj->real_type),
963-
delta_obj->idx.oid.hash);
961+
hash_object_file(result->data, result->size,
962+
typename(delta_obj->real_type), &delta_obj->idx.oid);
964963
sha1_object(result->data, NULL, result->size, delta_obj->real_type,
965964
&delta_obj->idx.oid);
966965
counter_lock();

builtin/merge.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,8 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
820820
pptr = commit_list_append(head, pptr);
821821
pptr = commit_list_append(remoteheads->item, pptr);
822822
prepare_to_commit(remoteheads);
823-
if (commit_tree(merge_msg.buf, merge_msg.len, result_tree.hash, parents,
824-
result_commit.hash, NULL, sign_commit))
823+
if (commit_tree(merge_msg.buf, merge_msg.len, &result_tree, parents,
824+
&result_commit, NULL, sign_commit))
825825
die(_("failed to write commit object"));
826826
finish(head, remoteheads, &result_commit, "In-index merge");
827827
drop_save();
@@ -845,8 +845,8 @@ static int finish_automerge(struct commit *head,
845845
commit_list_insert(head, &parents);
846846
strbuf_addch(&merge_msg, '\n');
847847
prepare_to_commit(remoteheads);
848-
if (commit_tree(merge_msg.buf, merge_msg.len, result_tree->hash, parents,
849-
result_commit.hash, NULL, sign_commit))
848+
if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parents,
849+
&result_commit, NULL, sign_commit))
850850
die(_("failed to write commit object"));
851851
strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy);
852852
finish(head, remoteheads, &result_commit, buf.buf);

0 commit comments

Comments
 (0)