Git fork

hash: stop depending on `the_repository` in `null_oid()`

The `null_oid()` function returns the object ID that only consists of
zeroes. Naturally, this ID also depends on the hash algorithm used, as
the number of zeroes is different between SHA1 and SHA256. Consequently,
the function returns the hash-algorithm-specific null object ID.

This is currently done by depending on `the_hash_algo`, which implicitly
makes us depend on `the_repository`. Refactor the function to instead
pass in the hash algorithm for which we want to retrieve the null object
ID. Adapt callsites accordingly by passing in `the_repository`, thus
bubbling up the dependency on that global variable by one layer.

There are a couple of trivial exceptions for subsystems that already got
rid of `the_repository`. These subsystems instead use the repository
that is available via the calling context:

- "builtin/grep.c"
- "grep.c"
- "refs/debug.c"

There are also two non-trivial exceptions:

- "diff-no-index.c": Here we know that we may not have a repository
initialized at all, so we cannot rely on `the_repository`. Instead,
we adapt `diff_no_index()` to get a `struct git_hash_algo` as
parameter. The only caller is located in "builtin/diff.c", where we
know to call `repo_set_hash_algo()` in case we're running outside of
a Git repository. Consequently, it is fine to continue passing
`the_repository->hash_algo` even in this case.

- "builtin/ls-files.c": There is an in-flight patch series that drops
`USE_THE_REPOSITORY_VARIABLE` in this file, which causes a semantic
conflict because we use `null_oid()` in `show_submodule()`. The
value is passed to `repo_submodule_init()`, which may use the object
ID to resolve a tree-ish in the superproject from which we want to
read the submodule config. As such, the object ID should refer to an
object in the superproject, and consequently we need to use its hash
algorithm.

This means that we could in theory just not bother about this edge
case at all and just use `the_repository` in "diff-no-index.c". But
doing so would feel misdesigned.

Remove the `USE_THE_REPOSITORY_VARIABLE` preprocessor define in
"hash.c".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
7d70b29c 8ca9fa60

+136 -136
+1 -1
archive.c
··· 312 312 struct object_id fake_oid; 313 313 int i; 314 314 315 - oidcpy(&fake_oid, null_oid()); 315 + oidcpy(&fake_oid, null_oid(the_hash_algo)); 316 316 317 317 if (args->baselen > 0 && args->base[args->baselen - 1] == '/') { 318 318 size_t len = args->baselen;
+1 -1
blame.c
··· 255 255 switch (st.st_mode & S_IFMT) { 256 256 case S_IFREG: 257 257 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)) 259 259 strbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1); 260 260 else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size) 261 261 die_errno("cannot open or read '%s'", read_from);
+1 -1
branch.c
··· 633 633 0, &err); 634 634 if (!transaction || 635 635 ref_transaction_update(transaction, ref.buf, 636 - &oid, forcing ? NULL : null_oid(), 636 + &oid, forcing ? NULL : null_oid(the_hash_algo), 637 637 NULL, NULL, flags, msg, &err) || 638 638 ref_transaction_commit(transaction, &err)) 639 639 die("%s", err.buf);
+3 -3
builtin/checkout.c
··· 130 130 int changed) 131 131 { 132 132 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)), 135 135 changed ? "1" : "0", NULL); 136 136 /* "new_commit" can be NULL when checking out from the index before 137 137 a commit exists. */ ··· 710 710 opts.src_index = the_repository->index; 711 711 opts.dst_index = the_repository->index; 712 712 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), 714 714 NULL); 715 715 if (parse_tree(tree) < 0) 716 716 return 128;
+1 -1
builtin/clone.c
··· 690 690 if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK)) 691 691 die(_("unable to write new index file")); 692 692 693 - err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid()), 693 + err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid(the_hash_algo)), 694 694 oid_to_hex(&oid), "1", NULL); 695 695 696 696 if (!err && (option_recurse_submodules.nr > 0)) {
+1 -1
builtin/describe.c
··· 518 518 { 519 519 struct rev_info revs; 520 520 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}; 522 522 523 523 strvec_pushl(&args, "internal: The first arg is not parsed", 524 524 "--objects", "--in-commit-order", "--reverse", "HEAD",
+3 -2
builtin/diff.c
··· 104 104 105 105 stuff_change(&revs->diffopt, 106 106 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), 108 108 1, 0, 109 109 blob[0]->path ? blob[0]->path : path, 110 110 path); ··· 498 498 499 499 /* If this is a no-index diff, just run it and exit there. */ 500 500 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, 502 503 argc, argv)); 503 504 504 505
+5 -5
builtin/fast-export.c
··· 869 869 p = rewrite_commit((struct commit *)tagged); 870 870 if (!p) { 871 871 printf("reset %s\nfrom %s\n\n", 872 - name, oid_to_hex(null_oid())); 872 + name, oid_to_hex(null_oid(the_hash_algo))); 873 873 free(buf); 874 874 return; 875 875 } ··· 883 883 884 884 if (tagged->type == OBJ_TAG) { 885 885 printf("reset %s\nfrom %s\n\n", 886 - name, oid_to_hex(null_oid())); 886 + name, oid_to_hex(null_oid(the_hash_algo))); 887 887 } 888 888 skip_prefix(name, "refs/tags/", &name); 889 889 printf("tag %s\n", name); ··· 1023 1023 * it. 1024 1024 */ 1025 1025 printf("reset %s\nfrom %s\n\n", 1026 - name, oid_to_hex(null_oid())); 1026 + name, oid_to_hex(null_oid(the_hash_algo))); 1027 1027 continue; 1028 1028 } 1029 1029 ··· 1042 1042 if (!reference_excluded_commits) { 1043 1043 /* delete the ref */ 1044 1044 printf("reset %s\nfrom %s\n\n", 1045 - name, oid_to_hex(null_oid())); 1045 + name, oid_to_hex(null_oid(the_hash_algo))); 1046 1046 continue; 1047 1047 } 1048 1048 /* set ref to commit using oid, not mark */ ··· 1153 1153 continue; 1154 1154 1155 1155 printf("reset %s\nfrom %s\n\n", 1156 - refspec->dst, oid_to_hex(null_oid())); 1156 + refspec->dst, oid_to_hex(null_oid(the_hash_algo))); 1157 1157 } 1158 1158 } 1159 1159
+1 -1
builtin/fsck.c
··· 625 625 void *contents = NULL; 626 626 int eaten; 627 627 struct object_info oi = OBJECT_INFO_INIT; 628 - struct object_id real_oid = *null_oid(); 628 + struct object_id real_oid = *null_oid(the_hash_algo); 629 629 int err = 0; 630 630 631 631 strbuf_reset(&cb_data->obj_type);
+1 -1
builtin/grep.c
··· 453 453 return 0; 454 454 455 455 subrepo = xmalloc(sizeof(*subrepo)); 456 - if (repo_submodule_init(subrepo, superproject, path, null_oid())) { 456 + if (repo_submodule_init(subrepo, superproject, path, null_oid(opt->repo->hash_algo))) { 457 457 free(subrepo); 458 458 return 0; 459 459 }
+2 -1
builtin/ls-files.c
··· 234 234 { 235 235 struct repository subrepo; 236 236 237 - if (repo_submodule_init(&subrepo, superproject, path, null_oid())) 237 + if (repo_submodule_init(&subrepo, superproject, path, 238 + null_oid(superproject->hash_algo))) 238 239 return; 239 240 240 241 if (repo_read_index(&subrepo) < 0)
+1 -1
builtin/rebase.c
··· 925 925 options->orig_head, &merge_bases) < 0) 926 926 exit(128); 927 927 if (!merge_bases || merge_bases->next) 928 - oidcpy(branch_base, null_oid()); 928 + oidcpy(branch_base, null_oid(the_hash_algo)); 929 929 else 930 930 oidcpy(branch_base, &merge_bases->item->object.oid); 931 931
+1 -1
builtin/receive-pack.c
··· 363 363 strvec_clear(&excludes_vector); 364 364 365 365 if (!sent_capabilities) 366 - show_ref("capabilities^{}", null_oid()); 366 + show_ref("capabilities^{}", null_oid(the_hash_algo)); 367 367 368 368 advertise_shallow_grafts(1); 369 369
+18 -18
builtin/submodule--helper.c
··· 78 78 int ret; 79 79 80 80 if (repo_submodule_init(&subrepo, the_repository, module_path, 81 - null_oid()) < 0) 81 + null_oid(the_hash_algo)) < 0) 82 82 return die_message(_("could not get a repository handle for submodule '%s'"), 83 83 module_path); 84 84 ret = repo_get_default_remote(&subrepo, default_remote); ··· 308 308 displaypath = get_submodule_displaypath(path, info->prefix, 309 309 info->super_prefix); 310 310 311 - sub = submodule_from_path(the_repository, null_oid(), path); 311 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 312 312 313 313 if (!sub) 314 314 die(_("No url found for submodule path '%s' in .gitmodules"), ··· 468 468 469 469 displaypath = get_submodule_displaypath(path, prefix, super_prefix); 470 470 471 - sub = submodule_from_path(the_repository, null_oid(), path); 471 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 472 472 473 473 if (!sub) 474 474 die(_("No url found for submodule path '%s' in .gitmodules"), ··· 645 645 if (validate_submodule_path(path) < 0) 646 646 exit(128); 647 647 648 - if (!submodule_from_path(the_repository, null_oid(), path)) 648 + if (!submodule_from_path(the_repository, null_oid(the_hash_algo), path)) 649 649 die(_("no submodule mapping found in .gitmodules for path '%s'"), 650 650 path); 651 651 652 652 displaypath = get_submodule_displaypath(path, prefix, super_prefix); 653 653 654 654 if ((CE_STAGEMASK & ce_flags) >> CE_STAGESHIFT) { 655 - print_status(flags, 'U', path, null_oid(), displaypath); 655 + print_status(flags, 'U', path, null_oid(the_hash_algo), displaypath); 656 656 goto cleanup; 657 657 } 658 658 ··· 912 912 struct strbuf errmsg = STRBUF_INIT; 913 913 int total_commits = -1; 914 914 915 - if (!info->cached && oideq(&p->oid_dst, null_oid())) { 915 + if (!info->cached && oideq(&p->oid_dst, null_oid(the_hash_algo))) { 916 916 if (S_ISGITLINK(p->mod_dst)) { 917 917 struct ref_store *refs = repo_get_submodule_ref_store(the_repository, 918 918 p->sm_path); ··· 1051 1051 1052 1052 if (info->for_status && p->status != 'A' && 1053 1053 (sub = submodule_from_path(the_repository, 1054 - null_oid(), p->sm_path))) { 1054 + null_oid(the_hash_algo), p->sm_path))) { 1055 1055 char *config_key = NULL; 1056 1056 const char *value; 1057 1057 int ignore_all = 0; ··· 1259 1259 if (validate_submodule_path(path) < 0) 1260 1260 exit(128); 1261 1261 1262 - sub = submodule_from_path(the_repository, null_oid(), path); 1262 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 1263 1263 1264 1264 if (sub && sub->url) { 1265 1265 if (starts_with_dot_dot_slash(sub->url) || ··· 1404 1404 if (validate_submodule_path(path) < 0) 1405 1405 exit(128); 1406 1406 1407 - sub = submodule_from_path(the_repository, null_oid(), path); 1407 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 1408 1408 1409 1409 if (!sub || !sub->name) 1410 1410 goto cleanup; ··· 1929 1929 enum submodule_update_type update, 1930 1930 struct submodule_update_strategy *out) 1931 1931 { 1932 - const struct submodule *sub = submodule_from_path(r, null_oid(), path); 1932 + const struct submodule *sub = submodule_from_path(r, null_oid(the_hash_algo), path); 1933 1933 char *key; 1934 1934 const char *val; 1935 1935 int ret; ··· 2089 2089 goto cleanup; 2090 2090 } 2091 2091 2092 - sub = submodule_from_path(the_repository, null_oid(), ce->name); 2092 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), ce->name); 2093 2093 2094 2094 if (!sub) { 2095 2095 next_submodule_warn_missing(suc, out, displaypath); ··· 2485 2485 char *key; 2486 2486 *branch = NULL; 2487 2487 2488 - sub = submodule_from_path(the_repository, null_oid(), path); 2488 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 2489 2489 if (!sub) 2490 2490 return die_message(_("could not initialize submodule at path '%s'"), 2491 2491 path); ··· 2531 2531 const char *cw; 2532 2532 struct repository subrepo; 2533 2533 2534 - if (repo_submodule_init(&subrepo, the_repository, path, null_oid())) 2534 + if (repo_submodule_init(&subrepo, the_repository, path, null_oid(the_hash_algo))) 2535 2535 return die_message(_("could not get a repository handle for submodule '%s'"), 2536 2536 path); 2537 2537 ··· 2644 2644 return ret; 2645 2645 2646 2646 if (update_data->just_cloned) 2647 - oidcpy(&update_data->suboid, null_oid()); 2647 + oidcpy(&update_data->suboid, null_oid(the_hash_algo)); 2648 2648 else if (repo_resolve_gitlink_ref(the_repository, update_data->sm_path, 2649 2649 "HEAD", &update_data->suboid)) 2650 2650 return die_message(_("Unable to find current revision in submodule path '%s'"), ··· 2697 2697 struct update_data next = *update_data; 2698 2698 2699 2699 next.prefix = NULL; 2700 - oidcpy(&next.oid, null_oid()); 2701 - oidcpy(&next.suboid, null_oid()); 2700 + oidcpy(&next.oid, null_oid(the_hash_algo)); 2701 + oidcpy(&next.suboid, null_oid(the_hash_algo)); 2702 2702 2703 2703 cp.dir = update_data->sm_path; 2704 2704 cp.git_cmd = 1; ··· 3057 3057 if (argc != 2 || !(path = argv[0]) || !(newurl = argv[1])) 3058 3058 usage_with_options(usage, options); 3059 3059 3060 - sub = submodule_from_path(the_repository, null_oid(), path); 3060 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 3061 3061 3062 3062 if (!sub) 3063 3063 die(_("no submodule mapping found in .gitmodules for path '%s'"), ··· 3113 3113 if (argc != 1 || !(path = argv[0])) 3114 3114 usage_with_options(usage, options); 3115 3115 3116 - sub = submodule_from_path(the_repository, null_oid(), path); 3116 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 3117 3117 3118 3118 if (!sub) 3119 3119 die(_("no submodule mapping found in .gitmodules for path '%s'"),
+1 -1
builtin/unpack-objects.c
··· 505 505 * has not been resolved yet. 506 506 */ 507 507 oidclr(&obj_list[nr].oid, the_repository->hash_algo); 508 - add_delta_to_list(nr, null_oid(), base_offset, 508 + add_delta_to_list(nr, null_oid(the_hash_algo), base_offset, 509 509 delta_data, delta_size); 510 510 return; 511 511 }
+1 -1
builtin/update-ref.c
··· 500 500 */ 501 501 old_target = parse_next_refname(&next); 502 502 if (!old_target) 503 - oidcpy(&old_oid, null_oid()); 503 + oidcpy(&old_oid, null_oid(the_hash_algo)); 504 504 505 505 if (*next != line_termination) 506 506 die("symref-verify %s: extra input: %s", refname, next);
+1 -1
builtin/worktree.c
··· 578 578 579 579 strvec_pushl(&opt.env, "GIT_DIR", "GIT_WORK_TREE", NULL); 580 580 strvec_pushl(&opt.args, 581 - oid_to_hex(null_oid()), 581 + oid_to_hex(null_oid(the_hash_algo)), 582 582 oid_to_hex(&commit->object.oid), 583 583 "1", 584 584 NULL);
+1 -1
combine-diff.c
··· 1066 1066 &result_size, NULL, NULL); 1067 1067 } else if (textconv) { 1068 1068 struct diff_filespec *df = alloc_filespec(elem->path); 1069 - fill_filespec(df, null_oid(), 0, st.st_mode); 1069 + fill_filespec(df, null_oid(the_hash_algo), 0, st.st_mode); 1070 1070 result_size = fill_textconv(opt->repo, textconv, df, &result); 1071 1071 free_filespec(df); 1072 1072 } else if (0 <= (fd = open(elem->path, O_RDONLY))) {
+5 -5
diff-lib.c
··· 172 172 * these from (stage - 2). 173 173 */ 174 174 dpath = combine_diff_path_new(ce->name, ce_namelen(ce), 175 - wt_mode, null_oid(), 2); 175 + wt_mode, null_oid(the_hash_algo), 2); 176 176 177 177 while (i < entries) { 178 178 struct cache_entry *nce = istate->cache[i]; ··· 257 257 ce_intent_to_add(ce)) { 258 258 newmode = ce_mode_from_stat(ce, st.st_mode); 259 259 diff_addremove(&revs->diffopt, '+', newmode, 260 - null_oid(), 0, ce->name, 0); 260 + null_oid(the_hash_algo), 0, ce->name, 0); 261 261 continue; 262 262 } 263 263 ··· 274 274 } 275 275 oldmode = ce->ce_mode; 276 276 old_oid = &ce->oid; 277 - new_oid = changed ? null_oid() : &ce->oid; 277 + new_oid = changed ? null_oid(the_hash_algo) : &ce->oid; 278 278 diff_change(&revs->diffopt, oldmode, newmode, 279 279 old_oid, new_oid, 280 280 !is_null_oid(old_oid), ··· 330 330 0, dirty_submodule); 331 331 if (changed) { 332 332 mode = ce_mode_from_stat(ce, st.st_mode); 333 - oid = null_oid(); 333 + oid = null_oid(the_hash_algo); 334 334 } 335 335 } 336 336 ··· 402 402 403 403 p = combine_diff_path_new(new_entry->name, 404 404 ce_namelen(new_entry), 405 - mode, null_oid(), 2); 405 + mode, null_oid(the_hash_algo), 2); 406 406 p->parent[0].status = DIFF_STATUS_MODIFIED; 407 407 p->parent[0].mode = new_entry->ce_mode; 408 408 oidcpy(&p->parent[0].oid, &new_entry->oid);
+14 -14
diff-no-index.c
··· 113 113 populate_common(s, &buf); 114 114 } 115 115 116 - static struct diff_filespec *noindex_filespec(const char *name, int mode, 116 + static struct diff_filespec *noindex_filespec(const struct git_hash_algo *algop, 117 + const char *name, int mode, 117 118 enum special special) 118 119 { 119 120 struct diff_filespec *s; ··· 121 122 if (!name) 122 123 name = "/dev/null"; 123 124 s = alloc_filespec(name); 124 - fill_filespec(s, null_oid(), 0, mode); 125 + fill_filespec(s, null_oid(algop), 0, mode); 125 126 if (special == SPECIAL_STDIN) 126 127 populate_from_stdin(s); 127 128 else if (special == SPECIAL_PIPE) ··· 129 130 return s; 130 131 } 131 132 132 - static int queue_diff(struct diff_options *o, 133 + static int queue_diff(struct diff_options *o, const struct git_hash_algo *algop, 133 134 const char *name1, const char *name2, int recursing) 134 135 { 135 136 int mode1 = 0, mode2 = 0; ··· 145 146 146 147 if (S_ISDIR(mode1)) { 147 148 /* 2 is file that is created */ 148 - d1 = noindex_filespec(NULL, 0, SPECIAL_NONE); 149 - d2 = noindex_filespec(name2, mode2, special2); 149 + d1 = noindex_filespec(algop, NULL, 0, SPECIAL_NONE); 150 + d2 = noindex_filespec(algop, name2, mode2, special2); 150 151 name2 = NULL; 151 152 mode2 = 0; 152 153 } else { 153 154 /* 1 is file that is deleted */ 154 - d1 = noindex_filespec(name1, mode1, special1); 155 - d2 = noindex_filespec(NULL, 0, SPECIAL_NONE); 155 + d1 = noindex_filespec(algop, name1, mode1, special1); 156 + d2 = noindex_filespec(algop, NULL, 0, SPECIAL_NONE); 156 157 name1 = NULL; 157 158 mode1 = 0; 158 159 } ··· 217 218 n2 = buffer2.buf; 218 219 } 219 220 220 - ret = queue_diff(o, n1, n2, 1); 221 + ret = queue_diff(o, algop, n1, n2, 1); 221 222 } 222 223 string_list_clear(&p1, 0); 223 224 string_list_clear(&p2, 0); ··· 234 235 SWAP(special1, special2); 235 236 } 236 237 237 - d1 = noindex_filespec(name1, mode1, special1); 238 - d2 = noindex_filespec(name2, mode2, special2); 238 + d1 = noindex_filespec(algop, name1, mode1, special1); 239 + d2 = noindex_filespec(algop, name2, mode2, special2); 239 240 diff_queue(&diff_queued_diff, d1, d2); 240 241 return 0; 241 242 } ··· 297 298 NULL 298 299 }; 299 300 300 - int diff_no_index(struct rev_info *revs, 301 - int implicit_no_index, 302 - int argc, const char **argv) 301 + int diff_no_index(struct rev_info *revs, const struct git_hash_algo *algop, 302 + int implicit_no_index, int argc, const char **argv) 303 303 { 304 304 int i, no_index; 305 305 int ret = 1; ··· 354 354 setup_diff_pager(&revs->diffopt); 355 355 revs->diffopt.flags.exit_with_status = 1; 356 356 357 - if (queue_diff(&revs->diffopt, paths[0], paths[1], 0)) 357 + if (queue_diff(&revs->diffopt, algop, paths[0], paths[1], 0)) 358 358 goto out; 359 359 diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/"); 360 360 diffcore_std(&revs->diffopt);
+4 -4
diff.c
··· 4346 4346 die_errno("readlink(%s)", one->path); 4347 4347 prep_temp_blob(r->index, one->path, temp, sb.buf, sb.len, 4348 4348 (one->oid_valid ? 4349 - &one->oid : null_oid()), 4349 + &one->oid : null_oid(the_hash_algo)), 4350 4350 (one->oid_valid ? 4351 4351 one->mode : S_IFLNK)); 4352 4352 strbuf_release(&sb); ··· 4355 4355 /* we can borrow from the file in the work tree */ 4356 4356 temp->name = one->path; 4357 4357 if (!one->oid_valid) 4358 - oid_to_hex_r(temp->hex, null_oid()); 4358 + oid_to_hex_r(temp->hex, null_oid(the_hash_algo)); 4359 4359 else 4360 4360 oid_to_hex_r(temp->hex, &one->oid); 4361 4361 /* Even though we may sometimes borrow the ··· 6649 6649 6650 6650 one = alloc_filespec(e->key); 6651 6651 two = alloc_filespec(e->key); 6652 - fill_filespec(one, null_oid(), 0, 0); 6653 - fill_filespec(two, null_oid(), 0, 0); 6652 + fill_filespec(one, null_oid(the_hash_algo), 0, 0); 6653 + fill_filespec(two, null_oid(the_hash_algo), 0, 0); 6654 6654 p = diff_queue(q, one, two); 6655 6655 p->status = DIFF_STATUS_MODIFIED; 6656 6656 }
+1 -1
diff.h
··· 656 656 657 657 int diff_result_code(struct rev_info *); 658 658 659 - int diff_no_index(struct rev_info *, 659 + int diff_no_index(struct rev_info *, const struct git_hash_algo *algop, 660 660 int implicit_no_index, int, const char **); 661 661 662 662 int index_differs_from(struct repository *r, const char *def,
+1 -1
dir.c
··· 4035 4035 */ 4036 4036 i++; 4037 4037 4038 - sub = submodule_from_path(&subrepo, null_oid(), ce->name); 4038 + sub = submodule_from_path(&subrepo, null_oid(the_hash_algo), ce->name); 4039 4039 if (!sub || !is_submodule_active(&subrepo, ce->name)) 4040 4040 /* .gitmodules broken or inactive sub */ 4041 4041 continue;
+1 -1
grep.c
··· 1517 1517 fill_filespec(df, gs->identifier, 1, 0100644); 1518 1518 break; 1519 1519 case GREP_SOURCE_FILE: 1520 - fill_filespec(df, null_oid(), 0, 0100644); 1520 + fill_filespec(df, null_oid(r->hash_algo), 0, 0100644); 1521 1521 break; 1522 1522 default: 1523 1523 BUG("attempt to textconv something without a path?");
+2 -4
hash.c
··· 1 - #define USE_THE_REPOSITORY_VARIABLE 2 - 3 1 #include "git-compat-util.h" 4 2 #include "hash.h" 5 3 #include "hex.h" ··· 232 230 } 233 231 }; 234 232 235 - const struct object_id *null_oid(void) 233 + const struct object_id *null_oid(const struct git_hash_algo *algop) 236 234 { 237 - return the_hash_algo->null_oid; 235 + return algop->null_oid; 238 236 } 239 237 240 238 const char *empty_tree_oid_hex(const struct git_hash_algo *algop)
+1 -1
hash.h
··· 340 340 341 341 const struct git_hash_algo *unsafe_hash_algo(const struct git_hash_algo *algop); 342 342 343 - const struct object_id *null_oid(void); 343 + const struct object_id *null_oid(const struct git_hash_algo *algop); 344 344 345 345 static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop) 346 346 {
+1 -1
log-tree.c
··· 499 499 { 500 500 struct strbuf headers = STRBUF_INIT; 501 501 const char *name = oid_to_hex(opt->zero_commit ? 502 - null_oid() : &commit->object.oid); 502 + null_oid(the_hash_algo) : &commit->object.oid); 503 503 504 504 *need_8bit_cte_p = 0; /* unknown */ 505 505
+13 -13
merge-ort.c
··· 1817 1817 BUG("submodule deleted on one side; this should be handled outside of merge_submodule()"); 1818 1818 1819 1819 if ((sub_not_initialized = repo_submodule_init(&subrepo, 1820 - opt->repo, path, null_oid()))) { 1820 + opt->repo, path, null_oid(the_hash_algo)))) { 1821 1821 path_msg(opt, CONFLICT_SUBMODULE_NOT_INITIALIZED, 0, 1822 1822 path, NULL, NULL, NULL, 1823 1823 _("Failed to merge submodule %s (not checked out)"), ··· 2199 2199 two_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode)); 2200 2200 2201 2201 merge_status = merge_3way(opt, path, 2202 - two_way ? null_oid() : &o->oid, 2202 + two_way ? null_oid(the_hash_algo) : &o->oid, 2203 2203 &a->oid, &b->oid, 2204 2204 pathnames, extra_marker_size, 2205 2205 &result_buf); ··· 2231 2231 } else if (S_ISGITLINK(a->mode)) { 2232 2232 int two_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode)); 2233 2233 clean = merge_submodule(opt, pathnames[0], 2234 - two_way ? null_oid() : &o->oid, 2234 + two_way ? null_oid(the_hash_algo) : &o->oid, 2235 2235 &a->oid, &b->oid, &result->oid); 2236 2236 if (clean < 0) 2237 2237 return -1; ··· 2739 2739 assert(!new_ci->match_mask); 2740 2740 new_ci->dirmask = 0; 2741 2741 new_ci->stages[1].mode = 0; 2742 - oidcpy(&new_ci->stages[1].oid, null_oid()); 2742 + oidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo)); 2743 2743 2744 2744 /* 2745 2745 * Now that we have the file information in new_ci, make sure ··· 2752 2752 continue; 2753 2753 /* zero out any entries related to files */ 2754 2754 ci->stages[i].mode = 0; 2755 - oidcpy(&ci->stages[i].oid, null_oid()); 2755 + oidcpy(&ci->stages[i].oid, null_oid(the_hash_algo)); 2756 2756 } 2757 2757 2758 2758 /* Now we want to focus on new_ci, so reassign ci to it. */ ··· 3122 3122 if (type_changed) { 3123 3123 /* rename vs. typechange */ 3124 3124 /* Mark the original as resolved by removal */ 3125 - memcpy(&oldinfo->stages[0].oid, null_oid(), 3125 + memcpy(&oldinfo->stages[0].oid, null_oid(the_hash_algo), 3126 3126 sizeof(oldinfo->stages[0].oid)); 3127 3127 oldinfo->stages[0].mode = 0; 3128 3128 oldinfo->filemask &= 0x06; ··· 3994 3994 if (ci->filemask & (1 << i)) 3995 3995 continue; 3996 3996 ci->stages[i].mode = 0; 3997 - oidcpy(&ci->stages[i].oid, null_oid()); 3997 + oidcpy(&ci->stages[i].oid, null_oid(the_hash_algo)); 3998 3998 } 3999 3999 } else if (ci->df_conflict && ci->merged.result.mode != 0) { 4000 4000 /* ··· 4041 4041 continue; 4042 4042 /* zero out any entries related to directories */ 4043 4043 new_ci->stages[i].mode = 0; 4044 - oidcpy(&new_ci->stages[i].oid, null_oid()); 4044 + oidcpy(&new_ci->stages[i].oid, null_oid(the_hash_algo)); 4045 4045 } 4046 4046 4047 4047 /* ··· 4163 4163 new_ci->merged.result.mode = ci->stages[2].mode; 4164 4164 oidcpy(&new_ci->merged.result.oid, &ci->stages[2].oid); 4165 4165 new_ci->stages[1].mode = 0; 4166 - oidcpy(&new_ci->stages[1].oid, null_oid()); 4166 + oidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo)); 4167 4167 new_ci->filemask = 5; 4168 4168 if ((S_IFMT & b_mode) != (S_IFMT & o_mode)) { 4169 4169 new_ci->stages[0].mode = 0; 4170 - oidcpy(&new_ci->stages[0].oid, null_oid()); 4170 + oidcpy(&new_ci->stages[0].oid, null_oid(the_hash_algo)); 4171 4171 new_ci->filemask = 4; 4172 4172 } 4173 4173 ··· 4175 4175 ci->merged.result.mode = ci->stages[1].mode; 4176 4176 oidcpy(&ci->merged.result.oid, &ci->stages[1].oid); 4177 4177 ci->stages[2].mode = 0; 4178 - oidcpy(&ci->stages[2].oid, null_oid()); 4178 + oidcpy(&ci->stages[2].oid, null_oid(the_hash_algo)); 4179 4179 ci->filemask = 3; 4180 4180 if ((S_IFMT & a_mode) != (S_IFMT & o_mode)) { 4181 4181 ci->stages[0].mode = 0; 4182 - oidcpy(&ci->stages[0].oid, null_oid()); 4182 + oidcpy(&ci->stages[0].oid, null_oid(the_hash_algo)); 4183 4183 ci->filemask = 2; 4184 4184 } 4185 4185 ··· 4304 4304 /* Deleted on both sides */ 4305 4305 ci->merged.is_null = 1; 4306 4306 ci->merged.result.mode = 0; 4307 - oidcpy(&ci->merged.result.oid, null_oid()); 4307 + oidcpy(&ci->merged.result.oid, null_oid(the_hash_algo)); 4308 4308 assert(!ci->df_conflict); 4309 4309 ci->merged.clean = !ci->path_conflict; 4310 4310 }
+6 -6
merge-recursive.c
··· 502 502 503 503 ret = get_tree_entry(r, tree, path, &dfs->oid, &dfs->mode); 504 504 if (S_ISDIR(dfs->mode)) { 505 - oidcpy(&dfs->oid, null_oid()); 505 + oidcpy(&dfs->oid, null_oid(the_hash_algo)); 506 506 dfs->mode = 0; 507 507 } 508 508 return ret; ··· 1238 1238 if (is_null_oid(b)) 1239 1239 return 0; 1240 1240 1241 - if (repo_submodule_init(&subrepo, opt->repo, path, null_oid())) { 1241 + if (repo_submodule_init(&subrepo, opt->repo, path, null_oid(the_hash_algo))) { 1242 1242 output(opt, 1, _("Failed to merge submodule %s (not checked out)"), path); 1243 1243 return 0; 1244 1244 } ··· 1698 1698 1699 1699 /* Store things in diff_filespecs for functions that need it */ 1700 1700 null.path = (char *)collide_path; 1701 - oidcpy(&null.oid, null_oid()); 1701 + oidcpy(&null.oid, null_oid(the_hash_algo)); 1702 1702 null.mode = 0; 1703 1703 1704 1704 if (merge_mode_and_contents(opt, &null, a, b, collide_path, ··· 2897 2897 dst_other.mode = ren1->dst_entry->stages[other_stage].mode; 2898 2898 try_merge = 0; 2899 2899 2900 - if (oideq(&src_other.oid, null_oid()) && 2900 + if (oideq(&src_other.oid, null_oid(the_hash_algo)) && 2901 2901 ren1->dir_rename_original_type == 'A') { 2902 2902 setup_rename_conflict_info(RENAME_VIA_DIR, 2903 2903 opt, ren1, NULL); 2904 2904 } else if (renamed_to_self) { 2905 2905 setup_rename_conflict_info(RENAME_NORMAL, 2906 2906 opt, ren1, NULL); 2907 - } else if (oideq(&src_other.oid, null_oid())) { 2907 + } else if (oideq(&src_other.oid, null_oid(the_hash_algo))) { 2908 2908 setup_rename_conflict_info(RENAME_DELETE, 2909 2909 opt, ren1, NULL); 2910 2910 } else if ((dst_other.mode == ren1->pair->two->mode) && ··· 2923 2923 1, /* update_cache */ 2924 2924 0 /* update_wd */)) 2925 2925 clean_merge = -1; 2926 - } else if (!oideq(&dst_other.oid, null_oid())) { 2926 + } else if (!oideq(&dst_other.oid, null_oid(the_hash_algo))) { 2927 2927 /* 2928 2928 * Probably not a clean merge, but it's 2929 2929 * premature to set clean_merge to 0 here,
+1 -1
notes-merge.c
··· 617 617 if (repo_get_merge_bases(the_repository, local, remote, &bases) < 0) 618 618 exit(128); 619 619 if (!bases) { 620 - base_oid = null_oid(); 620 + base_oid = null_oid(the_hash_algo); 621 621 base_tree_oid = the_hash_algo->empty_tree; 622 622 if (o->verbosity >= 4) 623 623 printf("No merge base found; doing history-less merge\n");
+1 -1
notes.c
··· 1353 1353 if (note) 1354 1354 return add_note(t, to_obj, note, combine_notes); 1355 1355 else if (existing_note) 1356 - return add_note(t, to_obj, null_oid(), combine_notes); 1356 + return add_note(t, to_obj, null_oid(the_hash_algo), combine_notes); 1357 1357 1358 1358 return 0; 1359 1359 }
+1 -1
object-file.c
··· 2405 2405 2406 2406 opts.strict = 1; 2407 2407 opts.error_func = hash_format_check_report; 2408 - if (fsck_buffer(null_oid(), type, buf, size, &opts)) 2408 + if (fsck_buffer(null_oid(the_hash_algo), type, buf, size, &opts)) 2409 2409 die(_("refusing to create malformed object")); 2410 2410 fsck_finish(&opts); 2411 2411 }
+1 -1
parse-options-cb.c
··· 145 145 struct object_id *target = opt->value; 146 146 147 147 if (unset) { 148 - oidcpy(target, null_oid()); 148 + oidcpy(target, null_oid(the_hash_algo)); 149 149 return 0; 150 150 } 151 151 if (!arg)
+1 -1
range-diff.c
··· 467 467 { 468 468 struct diff_filespec *spec = alloc_filespec(name); 469 469 470 - fill_filespec(spec, null_oid(), 0, 0100644); 470 + fill_filespec(spec, null_oid(the_hash_algo), 0, 0100644); 471 471 spec->data = (char *)p; 472 472 spec->size = strlen(p); 473 473 spec->should_munmap = 0;
+1 -1
read-cache.c
··· 1735 1735 end = (unsigned char *)hdr + size; 1736 1736 start = end - the_hash_algo->rawsz; 1737 1737 oidread(&oid, start, the_repository->hash_algo); 1738 - if (oideq(&oid, null_oid())) 1738 + if (oideq(&oid, null_oid(the_hash_algo))) 1739 1739 return 0; 1740 1740 1741 1741 the_hash_algo->init_fn(&c);
+6 -6
refs.c
··· 1377 1377 return 1; 1378 1378 } 1379 1379 return ref_transaction_update(transaction, refname, new_oid, 1380 - null_oid(), new_target, NULL, flags, 1380 + null_oid(the_hash_algo), new_target, NULL, flags, 1381 1381 msg, err); 1382 1382 } 1383 1383 ··· 1396 1396 if (old_target && !(flags & REF_NO_DEREF)) 1397 1397 BUG("delete cannot operate on symrefs with deref mode"); 1398 1398 return ref_transaction_update(transaction, refname, 1399 - null_oid(), old_oid, 1399 + null_oid(the_hash_algo), old_oid, 1400 1400 NULL, old_target, flags, 1401 1401 msg, err); 1402 1402 } ··· 2160 2160 subrepo = xmalloc(sizeof(*subrepo)); 2161 2161 2162 2162 if (repo_submodule_init(subrepo, repo, submodule, 2163 - null_oid())) { 2163 + null_oid(the_hash_algo))) { 2164 2164 free(subrepo); 2165 2165 goto done; 2166 2166 } ··· 2345 2345 strbuf_reset(&buf); 2346 2346 2347 2347 if (!(update->flags & REF_HAVE_OLD)) 2348 - strbuf_addf(&buf, "%s ", oid_to_hex(null_oid())); 2348 + strbuf_addf(&buf, "%s ", oid_to_hex(null_oid(the_hash_algo))); 2349 2349 else if (update->old_target) 2350 2350 strbuf_addf(&buf, "ref:%s ", update->old_target); 2351 2351 else 2352 2352 strbuf_addf(&buf, "%s ", oid_to_hex(&update->old_oid)); 2353 2353 2354 2354 if (!(update->flags & REF_HAVE_NEW)) 2355 - strbuf_addf(&buf, "%s ", oid_to_hex(null_oid())); 2355 + strbuf_addf(&buf, "%s ", oid_to_hex(null_oid(the_hash_algo))); 2356 2356 else if (update->new_target) 2357 2357 strbuf_addf(&buf, "ref:%s ", update->new_target); 2358 2358 else ··· 2794 2794 if (ret < 0) 2795 2795 goto done; 2796 2796 2797 - ret = ref_transaction_update(data->transaction, refname, NULL, null_oid(), 2797 + ret = ref_transaction_update(data->transaction, refname, NULL, null_oid(the_hash_algo), 2798 2798 symref_target.buf, NULL, 2799 2799 REF_SKIP_CREATE_REFLOG | REF_NO_DEREF, NULL, data->errbuf); 2800 2800 if (ret < 0)
+1 -1
refs/debug.c
··· 217 217 struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store; 218 218 int res = 0; 219 219 220 - oidcpy(oid, null_oid()); 220 + oidcpy(oid, null_oid(ref_store->repo->hash_algo)); 221 221 res = drefs->refs->be->read_raw_ref(drefs->refs, refname, oid, referent, 222 222 type, failure_errno); 223 223
+1 -1
refs/files-backend.c
··· 1270 1270 ref_transaction_add_update( 1271 1271 transaction, r->name, 1272 1272 REF_NO_DEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_IS_PRUNING, 1273 - null_oid(), &r->oid, NULL, NULL, NULL, NULL); 1273 + null_oid(the_hash_algo), &r->oid, NULL, NULL, NULL, NULL); 1274 1274 if (ref_transaction_commit(transaction, &err)) 1275 1275 goto cleanup; 1276 1276
+1 -1
reset.c
··· 80 80 } 81 81 if (!ret && run_hook) 82 82 run_hooks_l(the_repository, "post-checkout", 83 - oid_to_hex(head ? head : null_oid()), 83 + oid_to_hex(head ? head : null_oid(the_hash_algo)), 84 84 oid_to_hex(oid), "1", NULL); 85 85 strbuf_release(&msg); 86 86 return ret;
+5 -5
sequencer.c
··· 265 265 266 266 CALLOC_ARRAY(rec, 1); 267 267 268 - oidcpy(&rec->before, null_oid()); 269 - oidcpy(&rec->after, null_oid()); 268 + oidcpy(&rec->before, null_oid(the_hash_algo)); 269 + oidcpy(&rec->after, null_oid(the_hash_algo)); 270 270 271 271 /* This may fail, but that's fine, we will keep the null OID. */ 272 272 refs_read_ref(get_main_ref_store(the_repository), ref, &rec->before); ··· 667 667 if (!transaction || 668 668 ref_transaction_update(transaction, "HEAD", 669 669 to, unborn && !is_rebase_i(opts) ? 670 - null_oid() : from, NULL, NULL, 670 + null_oid(the_hash_algo) : from, NULL, NULL, 671 671 0, sb.buf, &err) || 672 672 ref_transaction_commit(transaction, &err)) { 673 673 ref_transaction_free(transaction); ··· 1301 1301 0, err); 1302 1302 if (!transaction || 1303 1303 ref_transaction_update(transaction, "HEAD", new_head, 1304 - old_head ? &old_head->object.oid : null_oid(), 1304 + old_head ? &old_head->object.oid : null_oid(the_hash_algo), 1305 1305 NULL, NULL, 0, sb.buf, err) || 1306 1306 ref_transaction_commit(transaction, err)) { 1307 1307 ret = -1; ··· 4683 4683 write_file(path, "%s", oid_to_hex(&oid)); 4684 4684 } else { 4685 4685 refs_update_ref(get_main_ref_store(r), "", refname, 4686 - &oid, null_oid(), 0, UPDATE_REFS_DIE_ON_ERR); 4686 + &oid, null_oid(the_hash_algo), 0, UPDATE_REFS_DIE_ON_ERR); 4687 4687 } 4688 4688 4689 4689 printf(_("Created autostash: %s\n"), buf.buf);
+1 -1
submodule-config.c
··· 831 831 832 832 parameter.cache = repo->submodule_cache; 833 833 parameter.treeish_name = NULL; 834 - parameter.gitmodules_oid = null_oid(); 834 + parameter.gitmodules_oid = null_oid(the_hash_algo); 835 835 parameter.overwrite = 1; 836 836 837 837 return parse_config(var, value, ctx, &parameter);
+14 -14
submodule.c
··· 124 124 if (is_gitmodules_unmerged(the_repository->index)) 125 125 die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first")); 126 126 127 - submodule = submodule_from_path(the_repository, null_oid(), oldpath); 127 + submodule = submodule_from_path(the_repository, null_oid(the_hash_algo), oldpath); 128 128 if (!submodule || !submodule->name) { 129 129 warning(_("Could not find section in .gitmodules where path=%s"), oldpath); 130 130 return -1; ··· 153 153 if (is_gitmodules_unmerged(the_repository->index)) 154 154 die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first")); 155 155 156 - submodule = submodule_from_path(the_repository, null_oid(), path); 156 + submodule = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 157 157 if (!submodule || !submodule->name) { 158 158 warning(_("Could not find section in .gitmodules where path=%s"), path); 159 159 return -1; ··· 204 204 const char *path) 205 205 { 206 206 const struct submodule *submodule = submodule_from_path(the_repository, 207 - null_oid(), 207 + null_oid(the_hash_algo), 208 208 path); 209 209 if (submodule) { 210 210 const char *ignore; ··· 312 312 313 313 int is_submodule_active(struct repository *repo, const char *path) 314 314 { 315 - return is_tree_submodule_active(repo, null_oid(), path); 315 + return is_tree_submodule_active(repo, null_oid(the_hash_algo), path); 316 316 } 317 317 318 318 int is_submodule_populated_gently(const char *path, int *return_error_code) ··· 778 778 if (!should_update_submodules()) 779 779 return NULL; 780 780 781 - return submodule_from_path(the_repository, null_oid(), ce->name); 781 + return submodule_from_path(the_repository, null_oid(the_hash_algo), ce->name); 782 782 } 783 783 784 784 ··· 1062 1062 const char *path, 1063 1063 struct oid_array *commits) 1064 1064 { 1065 - if (!submodule_has_commits(r, path, null_oid(), commits)) 1065 + if (!submodule_has_commits(r, path, null_oid(the_hash_algo), commits)) 1066 1066 /* 1067 1067 * NOTE: We do consider it safe to return "no" here. The 1068 1068 * correct answer would be "We do not know" instead of ··· 1126 1126 const struct submodule *submodule; 1127 1127 const char *path = NULL; 1128 1128 1129 - submodule = submodule_from_name(r, null_oid(), name->string); 1129 + submodule = submodule_from_name(r, null_oid(the_hash_algo), name->string); 1130 1130 if (submodule) 1131 1131 path = submodule->path; 1132 1132 else ··· 1351 1351 const struct submodule *submodule; 1352 1352 const char *path = NULL; 1353 1353 1354 - submodule = submodule_from_name(r, null_oid(), name->string); 1354 + submodule = submodule_from_name(r, null_oid(the_hash_algo), name->string); 1355 1355 if (submodule) 1356 1356 path = submodule->path; 1357 1357 else ··· 1360 1360 if (!path) 1361 1361 continue; 1362 1362 1363 - if (submodule_has_commits(r, path, null_oid(), &cs_data->new_commits)) { 1363 + if (submodule_has_commits(r, path, null_oid(the_hash_algo), &cs_data->new_commits)) { 1364 1364 changed_submodule_data_clear(cs_data); 1365 1365 *name->string = '\0'; 1366 1366 } ··· 1602 1602 if (!S_ISGITLINK(ce->ce_mode)) 1603 1603 continue; 1604 1604 1605 - task = fetch_task_create(spf, ce->name, null_oid()); 1605 + task = fetch_task_create(spf, ce->name, null_oid(the_hash_algo)); 1606 1606 if (!task) 1607 1607 continue; 1608 1608 ··· 2166 2166 if (old_head && !is_submodule_populated_gently(path, error_code_ptr)) 2167 2167 return 0; 2168 2168 2169 - sub = submodule_from_path(the_repository, null_oid(), path); 2169 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 2170 2170 2171 2171 if (!sub) 2172 2172 BUG("could not get submodule information for '%s'", path); ··· 2376 2376 2377 2377 real_old_git_dir = real_pathdup(old_git_dir, 1); 2378 2378 2379 - sub = submodule_from_path(the_repository, null_oid(), path); 2379 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 2380 2380 if (!sub) 2381 2381 die(_("could not lookup name for submodule '%s'"), path); 2382 2382 ··· 2462 2462 * superproject did not rewrite the git file links yet, 2463 2463 * fix it now. 2464 2464 */ 2465 - sub = submodule_from_path(the_repository, null_oid(), path); 2465 + sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path); 2466 2466 if (!sub) 2467 2467 die(_("could not lookup name for submodule '%s'"), path); 2468 2468 submodule_name_to_gitdir(&sub_gitdir, the_repository, sub->name); ··· 2594 2594 strbuf_addstr(buf, git_dir); 2595 2595 } 2596 2596 if (!is_git_directory(buf->buf)) { 2597 - sub = submodule_from_path(repo, null_oid(), submodule); 2597 + sub = submodule_from_path(repo, null_oid(the_hash_algo), submodule); 2598 2598 if (!sub) { 2599 2599 ret = -1; 2600 2600 goto cleanup;
+1 -1
t/helper/test-ref-store.c
··· 179 179 180 180 static int cmd_resolve_ref(struct ref_store *refs, const char **argv) 181 181 { 182 - struct object_id oid = *null_oid(); 182 + struct object_id oid = *null_oid(the_hash_algo); 183 183 const char *refname = notnull(*argv++, "refname"); 184 184 int resolve_flags = arg_flags(*argv++, "resolve-flags", empty_flags); 185 185 int flags;
+1 -1
t/helper/test-submodule-nested-repo-config.c
··· 21 21 22 22 setup_git_directory(); 23 23 24 - if (repo_submodule_init(&subrepo, the_repository, argv[1], null_oid())) { 24 + if (repo_submodule_init(&subrepo, the_repository, argv[1], null_oid(the_hash_algo))) { 25 25 die_usage(argv, "Submodule not found."); 26 26 } 27 27
+2 -2
tree-diff.c
··· 181 181 182 182 strbuf_add(base, path, pathlen); 183 183 p = combine_diff_path_new(base->buf, base->len, mode, 184 - oid ? oid : null_oid(), 184 + oid ? oid : null_oid(the_hash_algo), 185 185 nparent); 186 186 strbuf_setlen(base, old_baselen); 187 187 ··· 206 206 mode_i = tp[i].entry.mode; 207 207 } 208 208 else { 209 - oid_i = null_oid(); 209 + oid_i = null_oid(the_hash_algo); 210 210 mode_i = 0; 211 211 } 212 212
+1 -1
upload-pack.c
··· 1449 1449 for_each_namespaced_ref_1(send_ref, &data); 1450 1450 if (!data.sent_capabilities) { 1451 1451 const char *refname = "capabilities^{}"; 1452 - write_v0_ref(&data, refname, refname, null_oid()); 1452 + write_v0_ref(&data, refname, refname, null_oid(the_hash_algo)); 1453 1453 } 1454 1454 /* 1455 1455 * fflush stdout before calling advertise_shallow_grafts because send_ref
+2 -2
wt-status.c
··· 1824 1824 if (!sequencer_get_last_command(r, &action)) { 1825 1825 if (action == REPLAY_PICK && !state->cherry_pick_in_progress) { 1826 1826 state->cherry_pick_in_progress = 1; 1827 - oidcpy(&state->cherry_pick_head_oid, null_oid()); 1827 + oidcpy(&state->cherry_pick_head_oid, null_oid(the_hash_algo)); 1828 1828 } else if (action == REPLAY_REVERT && !state->revert_in_progress) { 1829 1829 state->revert_in_progress = 1; 1830 - oidcpy(&state->revert_head_oid, null_oid()); 1830 + oidcpy(&state->revert_head_oid, null_oid(the_hash_algo)); 1831 1831 } 1832 1832 } 1833 1833 if (get_detached_from)
+1 -1
xdiff-interface.c
··· 181 181 unsigned long size; 182 182 enum object_type type; 183 183 184 - if (oideq(oid, null_oid())) { 184 + if (oideq(oid, null_oid(the_hash_algo))) { 185 185 ptr->ptr = xstrdup(""); 186 186 ptr->size = 0; 187 187 return;