Skip to content

Commit ee847e0

Browse files
committed
Merge branch 'ps/object-wo-the-repository'
The object layer has been updated to take an explicit repository instance as a parameter in more code paths. * ps/object-wo-the-repository: hash: stop depending on `the_repository` in `null_oid()` hash: fix "-Wsign-compare" warnings object-file: split out logic regarding hash algorithms delta-islands: stop depending on `the_repository` object-file-convert: stop depending on `the_repository` pack-bitmap-write: stop depending on `the_repository` pack-revindex: stop depending on `the_repository` pack-check: stop depending on `the_repository` environment: move access to "core.bigFileThreshold" into repo settings pack-write: stop depending on `the_repository` and `the_hash_algo` object: stop depending on `the_repository` csum-file: stop depending on `the_repository`
2 parents f3f00d9 + 7d70b29 commit ee847e0

Some content is hidden

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

87 files changed

+677
-613
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ LIB_OBJS += gpg-interface.o
10421042
LIB_OBJS += graph.o
10431043
LIB_OBJS += grep.o
10441044
LIB_OBJS += hash-lookup.o
1045+
LIB_OBJS += hash.o
10451046
LIB_OBJS += hashmap.o
10461047
LIB_OBJS += help.o
10471048
LIB_OBJS += hex.o

archive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
216216
/* Stream it? */
217217
if (S_ISREG(mode) && !args->convert &&
218218
oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&
219-
size > big_file_threshold)
219+
size > repo_settings_get_big_file_threshold(the_repository))
220220
return write_entry(args, oid, path.buf, path.len, mode, NULL, size);
221221

222222
buffer = object_file_to_archive(args, path.buf, oid, mode, &type, &size);
@@ -312,7 +312,7 @@ int write_archive_entries(struct archiver_args *args,
312312
struct object_id fake_oid;
313313
int i;
314314

315-
oidcpy(&fake_oid, null_oid());
315+
oidcpy(&fake_oid, null_oid(the_hash_algo));
316316

317317
if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
318318
size_t len = args->baselen;

blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
255255
switch (st.st_mode & S_IFMT) {
256256
case S_IFREG:
257257
if (opt->flags.allow_textconv &&
258-
textconv_object(r, read_from, mode, null_oid(), 0, &buf_ptr, &buf_len))
258+
textconv_object(r, read_from, mode, null_oid(the_hash_algo), 0, &buf_ptr, &buf_len))
259259
strbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);
260260
else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
261261
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
@@ -633,7 +633,7 @@ void create_branch(struct repository *r,
633633
0, &err);
634634
if (!transaction ||
635635
ref_transaction_update(transaction, ref.buf,
636-
&oid, forcing ? NULL : null_oid(),
636+
&oid, forcing ? NULL : null_oid(the_hash_algo),
637637
NULL, NULL, flags, msg, &err) ||
638638
ref_transaction_commit(transaction, &err))
639639
die("%s", err.buf);

builtin/checkout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm
130130
int changed)
131131
{
132132
return run_hooks_l(the_repository, "post-checkout",
133-
oid_to_hex(old_commit ? &old_commit->object.oid : null_oid()),
134-
oid_to_hex(new_commit ? &new_commit->object.oid : null_oid()),
133+
oid_to_hex(old_commit ? &old_commit->object.oid : null_oid(the_hash_algo)),
134+
oid_to_hex(new_commit ? &new_commit->object.oid : null_oid(the_hash_algo)),
135135
changed ? "1" : "0", NULL);
136136
/* "new_commit" can be NULL when checking out from the index before
137137
a commit exists. */
@@ -710,7 +710,7 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
710710
opts.src_index = the_repository->index;
711711
opts.dst_index = the_repository->index;
712712
init_checkout_metadata(&opts.meta, info->refname,
713-
info->commit ? &info->commit->object.oid : null_oid(),
713+
info->commit ? &info->commit->object.oid : null_oid(the_hash_algo),
714714
NULL);
715715
if (parse_tree(tree) < 0)
716716
return 128;

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ static int checkout(int submodule_progress, int filter_submodules,
692692
if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
693693
die(_("unable to write new index file"));
694694

695-
err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid()),
695+
err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid(the_hash_algo)),
696696
oid_to_hex(&oid), "1", NULL);
697697

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

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
518518
{
519519
struct rev_info revs;
520520
struct strvec args = STRVEC_INIT;
521-
struct process_commit_data pcd = { *null_oid(), oid, dst, &revs};
521+
struct process_commit_data pcd = { *null_oid(the_hash_algo), oid, dst, &revs};
522522

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

builtin/diff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static void builtin_diff_b_f(struct rev_info *revs,
104104

105105
stuff_change(&revs->diffopt,
106106
blob[0]->mode, canon_mode(st.st_mode),
107-
&blob[0]->item->oid, null_oid(),
107+
&blob[0]->item->oid, null_oid(the_hash_algo),
108108
1, 0,
109109
blob[0]->path ? blob[0]->path : path,
110110
path);
@@ -498,7 +498,8 @@ int cmd_diff(int argc,
498498

499499
/* If this is a no-index diff, just run it and exit there. */
500500
if (no_index)
501-
exit(diff_no_index(&rev, no_index == DIFF_NO_INDEX_IMPLICIT,
501+
exit(diff_no_index(&rev, the_repository->hash_algo,
502+
no_index == DIFF_NO_INDEX_IMPLICIT,
502503
argc, argv));
503504

504505

builtin/fast-export.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ static void handle_tag(const char *name, struct tag *tag)
949949
p = rewrite_commit((struct commit *)tagged);
950950
if (!p) {
951951
printf("reset %s\nfrom %s\n\n",
952-
name, oid_to_hex(null_oid()));
952+
name, oid_to_hex(null_oid(the_hash_algo)));
953953
free(buf);
954954
return;
955955
}
@@ -963,7 +963,7 @@ static void handle_tag(const char *name, struct tag *tag)
963963

964964
if (tagged->type == OBJ_TAG) {
965965
printf("reset %s\nfrom %s\n\n",
966-
name, oid_to_hex(null_oid()));
966+
name, oid_to_hex(null_oid(the_hash_algo)));
967967
}
968968
skip_prefix(name, "refs/tags/", &name);
969969
printf("tag %s\n", name);
@@ -1103,7 +1103,7 @@ static void handle_tags_and_duplicates(struct string_list *extras)
11031103
* it.
11041104
*/
11051105
printf("reset %s\nfrom %s\n\n",
1106-
name, oid_to_hex(null_oid()));
1106+
name, oid_to_hex(null_oid(the_hash_algo)));
11071107
continue;
11081108
}
11091109

@@ -1122,7 +1122,7 @@ static void handle_tags_and_duplicates(struct string_list *extras)
11221122
if (!reference_excluded_commits) {
11231123
/* delete the ref */
11241124
printf("reset %s\nfrom %s\n\n",
1125-
name, oid_to_hex(null_oid()));
1125+
name, oid_to_hex(null_oid(the_hash_algo)));
11261126
continue;
11271127
}
11281128
/* set ref to commit using oid, not mark */
@@ -1233,7 +1233,7 @@ static void handle_deletes(void)
12331233
continue;
12341234

12351235
printf("reset %s\nfrom %s\n\n",
1236-
refspec->dst, oid_to_hex(null_oid()));
1236+
refspec->dst, oid_to_hex(null_oid(the_hash_algo)));
12371237
}
12381238
}
12391239

builtin/fast-import.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static void start_packfile(void)
770770
p->pack_fd = pack_fd;
771771
p->do_not_close = 1;
772772
p->repo = the_repository;
773-
pack_file = hashfd(pack_fd, p->pack_name);
773+
pack_file = hashfd(the_repository->hash_algo, pack_fd, p->pack_name);
774774

775775
pack_data = p;
776776
pack_size = write_pack_header(pack_file, 0);
@@ -798,7 +798,7 @@ static const char *create_index(void)
798798
if (c != last)
799799
die("internal consistency error creating the index");
800800

801-
tmpfile = write_idx_file(the_hash_algo, NULL, idx, object_count,
801+
tmpfile = write_idx_file(the_repository, NULL, idx, object_count,
802802
&pack_idx_opts, pack_data->hash);
803803
free(idx);
804804
return tmpfile;
@@ -2021,7 +2021,7 @@ static void parse_and_store_blob(
20212021
static struct strbuf buf = STRBUF_INIT;
20222022
uintmax_t len;
20232023

2024-
if (parse_data(&buf, big_file_threshold, &len))
2024+
if (parse_data(&buf, repo_settings_get_big_file_threshold(the_repository), &len))
20252025
store_object(OBJ_BLOB, &buf, last, oidout, mark);
20262026
else {
20272027
if (last) {
@@ -3425,7 +3425,7 @@ static int parse_one_option(const char *option)
34253425
unsigned long v;
34263426
if (!git_parse_ulong(option, &v))
34273427
return 0;
3428-
big_file_threshold = v;
3428+
repo_settings_set_big_file_threshold(the_repository, v);
34293429
} else if (skip_prefix(option, "depth=", &option)) {
34303430
option_depth(option);
34313431
} else if (skip_prefix(option, "active-branches=", &option)) {

0 commit comments

Comments
 (0)