struct object_id fake_oid;
int i;
- oidcpy(&fake_oid, null_oid());
+ oidcpy(&fake_oid, null_oid(the_hash_algo));
if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
size_t len = args->baselen;
switch (st.st_mode & S_IFMT) {
case S_IFREG:
if (opt->flags.allow_textconv &&
- textconv_object(r, read_from, mode, null_oid(), 0, &buf_ptr, &buf_len))
+ textconv_object(r, read_from, mode, null_oid(the_hash_algo), 0, &buf_ptr, &buf_len))
strbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);
else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
die_errno("cannot open or read '%s'", read_from);
0, &err);
if (!transaction ||
ref_transaction_update(transaction, ref.buf,
- &oid, forcing ? NULL : null_oid(),
+ &oid, forcing ? NULL : null_oid(the_hash_algo),
NULL, NULL, flags, msg, &err) ||
ref_transaction_commit(transaction, &err))
die("%s", err.buf);
int changed)
{
return run_hooks_l(the_repository, "post-checkout",
- oid_to_hex(old_commit ? &old_commit->object.oid : null_oid()),
- oid_to_hex(new_commit ? &new_commit->object.oid : null_oid()),
+ oid_to_hex(old_commit ? &old_commit->object.oid : null_oid(the_hash_algo)),
+ oid_to_hex(new_commit ? &new_commit->object.oid : null_oid(the_hash_algo)),
changed ? "1" : "0", NULL);
/* "new_commit" can be NULL when checking out from the index before
a commit exists. */
opts.src_index = the_repository->index;
opts.dst_index = the_repository->index;
init_checkout_metadata(&opts.meta, info->refname,
- info->commit ? &info->commit->object.oid : null_oid(),
+ info->commit ? &info->commit->object.oid : null_oid(the_hash_algo),
NULL);
if (parse_tree(tree) < 0)
return 128;
if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
die(_("unable to write new index file"));
- err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid()),
+ err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid(the_hash_algo)),
oid_to_hex(&oid), "1", NULL);
if (!err && (option_recurse_submodules.nr > 0)) {
{
struct rev_info revs;
struct strvec args = STRVEC_INIT;
- struct process_commit_data pcd = { *null_oid(), oid, dst, &revs};
+ struct process_commit_data pcd = { *null_oid(the_hash_algo), oid, dst, &revs};
strvec_pushl(&args, "internal: The first arg is not parsed",
"--objects", "--in-commit-order", "--reverse", "HEAD",
stuff_change(&revs->diffopt,
blob[0]->mode, canon_mode(st.st_mode),
- &blob[0]->item->oid, null_oid(),
+ &blob[0]->item->oid, null_oid(the_hash_algo),
1, 0,
blob[0]->path ? blob[0]->path : path,
path);
/* If this is a no-index diff, just run it and exit there. */
if (no_index)
- exit(diff_no_index(&rev, no_index == DIFF_NO_INDEX_IMPLICIT,
+ exit(diff_no_index(&rev, the_repository->hash_algo,
+ no_index == DIFF_NO_INDEX_IMPLICIT,
argc, argv));
p = rewrite_commit((struct commit *)tagged);
if (!p) {
printf("reset %s\nfrom %s\n\n",
- name, oid_to_hex(null_oid()));
+ name, oid_to_hex(null_oid(the_hash_algo)));
free(buf);
return;
}
if (tagged->type == OBJ_TAG) {
printf("reset %s\nfrom %s\n\n",
- name, oid_to_hex(null_oid()));
+ name, oid_to_hex(null_oid(the_hash_algo)));
}
skip_prefix(name, "refs/tags/", &name);
printf("tag %s\n", name);
* it.
*/
printf("reset %s\nfrom %s\n\n",
- name, oid_to_hex(null_oid()));
+ name, oid_to_hex(null_oid(the_hash_algo)));
continue;
}
if (!reference_excluded_commits) {
/* delete the ref */
printf("reset %s\nfrom %s\n\n",
- name, oid_to_hex(null_oid()));
+ name, oid_to_hex(null_oid(the_hash_algo)));
continue;
}
/* set ref to commit using oid, not mark */
continue;
printf("reset %s\nfrom %s\n\n",
- refspec->dst, oid_to_hex(null_oid()));
+ refspec->dst, oid_to_hex(null_oid(the_hash_algo)));
}
}
void *contents = NULL;
int eaten;
struct object_info oi = OBJECT_INFO_INIT;
- struct object_id real_oid = *null_oid();
+ struct object_id real_oid = *null_oid(the_hash_algo);
int err = 0;
strbuf_reset(&cb_data->obj_type);
return 0;
subrepo = xmalloc(sizeof(*subrepo));
- if (repo_submodule_init(subrepo, superproject, path, null_oid())) {
+ if (repo_submodule_init(subrepo, superproject, path, null_oid(opt->repo->hash_algo))) {
free(subrepo);
return 0;
}
{
struct repository subrepo;
- if (repo_submodule_init(&subrepo, superproject, path, null_oid()))
+ if (repo_submodule_init(&subrepo, superproject, path,
+ null_oid(superproject->hash_algo)))
return;
if (repo_read_index(&subrepo) < 0)
options->orig_head, &merge_bases) < 0)
exit(128);
if (!merge_bases || merge_bases->next)
- oidcpy(branch_base, null_oid());
+ oidcpy(branch_base, null_oid(the_hash_algo));
else
oidcpy(branch_base, &merge_bases->item->object.oid);
strvec_clear(&excludes_vector);
if (!sent_capabilities)
- show_ref("capabilities^{}", null_oid());
+ show_ref("capabilities^{}", null_oid(the_hash_algo));
advertise_shallow_grafts(1);
int ret;
if (repo_submodule_init(&subrepo, the_repository, module_path,
- null_oid()) < 0)
+ null_oid(the_hash_algo)) < 0)
return die_message(_("could not get a repository handle for submodule '%s'"),
module_path);
ret = repo_get_default_remote(&subrepo, default_remote);
displaypath = get_submodule_displaypath(path, info->prefix,
info->super_prefix);
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub)
die(_("No url found for submodule path '%s' in .gitmodules"),
displaypath = get_submodule_displaypath(path, prefix, super_prefix);
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub)
die(_("No url found for submodule path '%s' in .gitmodules"),
if (validate_submodule_path(path) < 0)
exit(128);
- if (!submodule_from_path(the_repository, null_oid(), path))
+ if (!submodule_from_path(the_repository, null_oid(the_hash_algo), path))
die(_("no submodule mapping found in .gitmodules for path '%s'"),
path);
displaypath = get_submodule_displaypath(path, prefix, super_prefix);
if ((CE_STAGEMASK & ce_flags) >> CE_STAGESHIFT) {
- print_status(flags, 'U', path, null_oid(), displaypath);
+ print_status(flags, 'U', path, null_oid(the_hash_algo), displaypath);
goto cleanup;
}
struct strbuf errmsg = STRBUF_INIT;
int total_commits = -1;
- if (!info->cached && oideq(&p->oid_dst, null_oid())) {
+ if (!info->cached && oideq(&p->oid_dst, null_oid(the_hash_algo))) {
if (S_ISGITLINK(p->mod_dst)) {
struct ref_store *refs = repo_get_submodule_ref_store(the_repository,
p->sm_path);
if (info->for_status && p->status != 'A' &&
(sub = submodule_from_path(the_repository,
- null_oid(), p->sm_path))) {
+ null_oid(the_hash_algo), p->sm_path))) {
char *config_key = NULL;
const char *value;
int ignore_all = 0;
if (validate_submodule_path(path) < 0)
exit(128);
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (sub && sub->url) {
if (starts_with_dot_dot_slash(sub->url) ||
if (validate_submodule_path(path) < 0)
exit(128);
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub || !sub->name)
goto cleanup;
enum submodule_update_type update,
struct submodule_update_strategy *out)
{
- const struct submodule *sub = submodule_from_path(r, null_oid(), path);
+ const struct submodule *sub = submodule_from_path(r, null_oid(the_hash_algo), path);
char *key;
const char *val;
int ret;
goto cleanup;
}
- sub = submodule_from_path(the_repository, null_oid(), ce->name);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), ce->name);
if (!sub) {
next_submodule_warn_missing(suc, out, displaypath);
char *key;
*branch = NULL;
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub)
return die_message(_("could not initialize submodule at path '%s'"),
path);
const char *cw;
struct repository subrepo;
- if (repo_submodule_init(&subrepo, the_repository, path, null_oid()))
+ if (repo_submodule_init(&subrepo, the_repository, path, null_oid(the_hash_algo)))
return die_message(_("could not get a repository handle for submodule '%s'"),
path);
return ret;
if (update_data->just_cloned)
- oidcpy(&update_data->suboid, null_oid());
+ oidcpy(&update_data->suboid, null_oid(the_hash_algo));
else if (repo_resolve_gitlink_ref(the_repository, update_data->sm_path,
"HEAD", &update_data->suboid))
return die_message(_("Unable to find current revision in submodule path '%s'"),
struct update_data next = *update_data;
next.prefix = NULL;
- oidcpy(&next.oid, null_oid());
- oidcpy(&next.suboid, null_oid());
+ oidcpy(&next.oid, null_oid(the_hash_algo));
+ oidcpy(&next.suboid, null_oid(the_hash_algo));
cp.dir = update_data->sm_path;
cp.git_cmd = 1;
if (argc != 2 || !(path = argv[0]) || !(newurl = argv[1]))
usage_with_options(usage, options);
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub)
die(_("no submodule mapping found in .gitmodules for path '%s'"),
if (argc != 1 || !(path = argv[0]))
usage_with_options(usage, options);
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub)
die(_("no submodule mapping found in .gitmodules for path '%s'"),
* has not been resolved yet.
*/
oidclr(&obj_list[nr].oid, the_repository->hash_algo);
- add_delta_to_list(nr, null_oid(), base_offset,
+ add_delta_to_list(nr, null_oid(the_hash_algo), base_offset,
delta_data, delta_size);
return;
}
*/
old_target = parse_next_refname(&next);
if (!old_target)
- oidcpy(&old_oid, null_oid());
+ oidcpy(&old_oid, null_oid(the_hash_algo));
if (*next != line_termination)
die("symref-verify %s: extra input: %s", refname, next);
strvec_pushl(&opt.env, "GIT_DIR", "GIT_WORK_TREE", NULL);
strvec_pushl(&opt.args,
- oid_to_hex(null_oid()),
+ oid_to_hex(null_oid(the_hash_algo)),
oid_to_hex(&commit->object.oid),
"1",
NULL);
&result_size, NULL, NULL);
} else if (textconv) {
struct diff_filespec *df = alloc_filespec(elem->path);
- fill_filespec(df, null_oid(), 0, st.st_mode);
+ fill_filespec(df, null_oid(the_hash_algo), 0, st.st_mode);
result_size = fill_textconv(opt->repo, textconv, df, &result);
free_filespec(df);
} else if (0 <= (fd = open(elem->path, O_RDONLY))) {
* these from (stage - 2).
*/
dpath = combine_diff_path_new(ce->name, ce_namelen(ce),
- wt_mode, null_oid(), 2);
+ wt_mode, null_oid(the_hash_algo), 2);
while (i < entries) {
struct cache_entry *nce = istate->cache[i];
ce_intent_to_add(ce)) {
newmode = ce_mode_from_stat(ce, st.st_mode);
diff_addremove(&revs->diffopt, '+', newmode,
- null_oid(), 0, ce->name, 0);
+ null_oid(the_hash_algo), 0, ce->name, 0);
continue;
}
}
oldmode = ce->ce_mode;
old_oid = &ce->oid;
- new_oid = changed ? null_oid() : &ce->oid;
+ new_oid = changed ? null_oid(the_hash_algo) : &ce->oid;
diff_change(&revs->diffopt, oldmode, newmode,
old_oid, new_oid,
!is_null_oid(old_oid),
0, dirty_submodule);
if (changed) {
mode = ce_mode_from_stat(ce, st.st_mode);
- oid = null_oid();
+ oid = null_oid(the_hash_algo);
}
}
p = combine_diff_path_new(new_entry->name,
ce_namelen(new_entry),
- mode, null_oid(), 2);
+ mode, null_oid(the_hash_algo), 2);
p->parent[0].status = DIFF_STATUS_MODIFIED;
p->parent[0].mode = new_entry->ce_mode;
oidcpy(&p->parent[0].oid, &new_entry->oid);
populate_common(s, &buf);
}
-static struct diff_filespec *noindex_filespec(const char *name, int mode,
+static struct diff_filespec *noindex_filespec(const struct git_hash_algo *algop,
+ const char *name, int mode,
enum special special)
{
struct diff_filespec *s;
if (!name)
name = "/dev/null";
s = alloc_filespec(name);
- fill_filespec(s, null_oid(), 0, mode);
+ fill_filespec(s, null_oid(algop), 0, mode);
if (special == SPECIAL_STDIN)
populate_from_stdin(s);
else if (special == SPECIAL_PIPE)
return s;
}
-static int queue_diff(struct diff_options *o,
+static int queue_diff(struct diff_options *o, const struct git_hash_algo *algop,
const char *name1, const char *name2, int recursing)
{
int mode1 = 0, mode2 = 0;
if (S_ISDIR(mode1)) {
/* 2 is file that is created */
- d1 = noindex_filespec(NULL, 0, SPECIAL_NONE);
- d2 = noindex_filespec(name2, mode2, special2);
+ d1 = noindex_filespec(algop, NULL, 0, SPECIAL_NONE);
+ d2 = noindex_filespec(algop, name2, mode2, special2);
name2 = NULL;
mode2 = 0;
} else {
/* 1 is file that is deleted */
- d1 = noindex_filespec(name1, mode1, special1);
- d2 = noindex_filespec(NULL, 0, SPECIAL_NONE);
+ d1 = noindex_filespec(algop, name1, mode1, special1);
+ d2 = noindex_filespec(algop, NULL, 0, SPECIAL_NONE);
name1 = NULL;
mode1 = 0;
}
n2 = buffer2.buf;
}
- ret = queue_diff(o, n1, n2, 1);
+ ret = queue_diff(o, algop, n1, n2, 1);
}
string_list_clear(&p1, 0);
string_list_clear(&p2, 0);
SWAP(special1, special2);
}
- d1 = noindex_filespec(name1, mode1, special1);
- d2 = noindex_filespec(name2, mode2, special2);
+ d1 = noindex_filespec(algop, name1, mode1, special1);
+ d2 = noindex_filespec(algop, name2, mode2, special2);
diff_queue(&diff_queued_diff, d1, d2);
return 0;
}
NULL
};
-int diff_no_index(struct rev_info *revs,
- int implicit_no_index,
- int argc, const char **argv)
+int diff_no_index(struct rev_info *revs, const struct git_hash_algo *algop,
+ int implicit_no_index, int argc, const char **argv)
{
int i, no_index;
int ret = 1;
setup_diff_pager(&revs->diffopt);
revs->diffopt.flags.exit_with_status = 1;
- if (queue_diff(&revs->diffopt, paths[0], paths[1], 0))
+ if (queue_diff(&revs->diffopt, algop, paths[0], paths[1], 0))
goto out;
diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/");
diffcore_std(&revs->diffopt);
die_errno("readlink(%s)", one->path);
prep_temp_blob(r->index, one->path, temp, sb.buf, sb.len,
(one->oid_valid ?
- &one->oid : null_oid()),
+ &one->oid : null_oid(the_hash_algo)),
(one->oid_valid ?
one->mode : S_IFLNK));
strbuf_release(&sb);
/* we can borrow from the file in the work tree */
temp->name = one->path;
if (!one->oid_valid)
- oid_to_hex_r(temp->hex, null_oid());
+ oid_to_hex_r(temp->hex, null_oid(the_hash_algo));
else
oid_to_hex_r(temp->hex, &one->oid);
/* Even though we may sometimes borrow the
one = alloc_filespec(e->key);
two = alloc_filespec(e->key);
- fill_filespec(one, null_oid(), 0, 0);
- fill_filespec(two, null_oid(), 0, 0);
+ fill_filespec(one, null_oid(the_hash_algo), 0, 0);
+ fill_filespec(two, null_oid(the_hash_algo), 0, 0);
p = diff_queue(q, one, two);
p->status = DIFF_STATUS_MODIFIED;
}
int diff_result_code(struct rev_info *);
-int diff_no_index(struct rev_info *,
+int diff_no_index(struct rev_info *, const struct git_hash_algo *algop,
int implicit_no_index, int, const char **);
int index_differs_from(struct repository *r, const char *def,
*/
i++;
- sub = submodule_from_path(&subrepo, null_oid(), ce->name);
+ sub = submodule_from_path(&subrepo, null_oid(the_hash_algo), ce->name);
if (!sub || !is_submodule_active(&subrepo, ce->name))
/* .gitmodules broken or inactive sub */
continue;
fill_filespec(df, gs->identifier, 1, 0100644);
break;
case GREP_SOURCE_FILE:
- fill_filespec(df, null_oid(), 0, 0100644);
+ fill_filespec(df, null_oid(r->hash_algo), 0, 0100644);
break;
default:
BUG("attempt to textconv something without a path?");
-#define USE_THE_REPOSITORY_VARIABLE
-
#include "git-compat-util.h"
#include "hash.h"
#include "hex.h"
}
};
-const struct object_id *null_oid(void)
+const struct object_id *null_oid(const struct git_hash_algo *algop)
{
- return the_hash_algo->null_oid;
+ return algop->null_oid;
}
const char *empty_tree_oid_hex(const struct git_hash_algo *algop)
const struct git_hash_algo *unsafe_hash_algo(const struct git_hash_algo *algop);
-const struct object_id *null_oid(void);
+const struct object_id *null_oid(const struct git_hash_algo *algop);
static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
{
{
struct strbuf headers = STRBUF_INIT;
const char *name = oid_to_hex(opt->zero_commit ?
- null_oid() : &commit->object.oid);
+ null_oid(the_hash_algo) : &commit->object.oid);
*need_8bit_cte_p = 0; /* unknown */
BUG("submodule deleted on one side; this should be handled outside of merge_submodule()");
if ((sub_not_initialized = repo_submodule_init(&subrepo,
- opt->repo, path, null_oid()))) {
+ opt->repo, path, null_oid(the_hash_algo)))) {
path_msg(opt, CONFLICT_SUBMODULE_NOT_INITIALIZED, 0,
path, NULL, NULL, NULL,
_("Failed to merge submodule %s (not checked out)"),
two_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode));
merge_status = merge_3way(opt, path,
- two_way ? null_oid() : &o->oid,
+ two_way ? null_oid(the_hash_algo) : &o->oid,
&a->oid, &b->oid,
pathnames, extra_marker_size,
&result_buf);
} else if (S_ISGITLINK(a->mode)) {
int two_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode));
clean = merge_submodule(opt, pathnames[0],
- two_way ? null_oid() : &o->oid,
+ two_way ? null_oid(the_hash_algo) : &o->oid,
&a->oid, &b->oid, &result->oid);
if (clean < 0)
return -1;
assert(!new_ci->match_mask);
new_ci->dirmask = 0;
new_ci->stages[1].mode = 0;
- oidcpy(&new_ci->stages[1].oid, null_oid());
+ oidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo));
/*
* Now that we have the file information in new_ci, make sure
continue;
/* zero out any entries related to files */
ci->stages[i].mode = 0;
- oidcpy(&ci->stages[i].oid, null_oid());
+ oidcpy(&ci->stages[i].oid, null_oid(the_hash_algo));
}
/* Now we want to focus on new_ci, so reassign ci to it. */
if (type_changed) {
/* rename vs. typechange */
/* Mark the original as resolved by removal */
- memcpy(&oldinfo->stages[0].oid, null_oid(),
+ memcpy(&oldinfo->stages[0].oid, null_oid(the_hash_algo),
sizeof(oldinfo->stages[0].oid));
oldinfo->stages[0].mode = 0;
oldinfo->filemask &= 0x06;
if (ci->filemask & (1 << i))
continue;
ci->stages[i].mode = 0;
- oidcpy(&ci->stages[i].oid, null_oid());
+ oidcpy(&ci->stages[i].oid, null_oid(the_hash_algo));
}
} else if (ci->df_conflict && ci->merged.result.mode != 0) {
/*
continue;
/* zero out any entries related to directories */
new_ci->stages[i].mode = 0;
- oidcpy(&new_ci->stages[i].oid, null_oid());
+ oidcpy(&new_ci->stages[i].oid, null_oid(the_hash_algo));
}
/*
new_ci->merged.result.mode = ci->stages[2].mode;
oidcpy(&new_ci->merged.result.oid, &ci->stages[2].oid);
new_ci->stages[1].mode = 0;
- oidcpy(&new_ci->stages[1].oid, null_oid());
+ oidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo));
new_ci->filemask = 5;
if ((S_IFMT & b_mode) != (S_IFMT & o_mode)) {
new_ci->stages[0].mode = 0;
- oidcpy(&new_ci->stages[0].oid, null_oid());
+ oidcpy(&new_ci->stages[0].oid, null_oid(the_hash_algo));
new_ci->filemask = 4;
}
ci->merged.result.mode = ci->stages[1].mode;
oidcpy(&ci->merged.result.oid, &ci->stages[1].oid);
ci->stages[2].mode = 0;
- oidcpy(&ci->stages[2].oid, null_oid());
+ oidcpy(&ci->stages[2].oid, null_oid(the_hash_algo));
ci->filemask = 3;
if ((S_IFMT & a_mode) != (S_IFMT & o_mode)) {
ci->stages[0].mode = 0;
- oidcpy(&ci->stages[0].oid, null_oid());
+ oidcpy(&ci->stages[0].oid, null_oid(the_hash_algo));
ci->filemask = 2;
}
/* Deleted on both sides */
ci->merged.is_null = 1;
ci->merged.result.mode = 0;
- oidcpy(&ci->merged.result.oid, null_oid());
+ oidcpy(&ci->merged.result.oid, null_oid(the_hash_algo));
assert(!ci->df_conflict);
ci->merged.clean = !ci->path_conflict;
}
ret = get_tree_entry(r, tree, path, &dfs->oid, &dfs->mode);
if (S_ISDIR(dfs->mode)) {
- oidcpy(&dfs->oid, null_oid());
+ oidcpy(&dfs->oid, null_oid(the_hash_algo));
dfs->mode = 0;
}
return ret;
if (is_null_oid(b))
return 0;
- if (repo_submodule_init(&subrepo, opt->repo, path, null_oid())) {
+ if (repo_submodule_init(&subrepo, opt->repo, path, null_oid(the_hash_algo))) {
output(opt, 1, _("Failed to merge submodule %s (not checked out)"), path);
return 0;
}
/* Store things in diff_filespecs for functions that need it */
null.path = (char *)collide_path;
- oidcpy(&null.oid, null_oid());
+ oidcpy(&null.oid, null_oid(the_hash_algo));
null.mode = 0;
if (merge_mode_and_contents(opt, &null, a, b, collide_path,
dst_other.mode = ren1->dst_entry->stages[other_stage].mode;
try_merge = 0;
- if (oideq(&src_other.oid, null_oid()) &&
+ if (oideq(&src_other.oid, null_oid(the_hash_algo)) &&
ren1->dir_rename_original_type == 'A') {
setup_rename_conflict_info(RENAME_VIA_DIR,
opt, ren1, NULL);
} else if (renamed_to_self) {
setup_rename_conflict_info(RENAME_NORMAL,
opt, ren1, NULL);
- } else if (oideq(&src_other.oid, null_oid())) {
+ } else if (oideq(&src_other.oid, null_oid(the_hash_algo))) {
setup_rename_conflict_info(RENAME_DELETE,
opt, ren1, NULL);
} else if ((dst_other.mode == ren1->pair->two->mode) &&
1, /* update_cache */
0 /* update_wd */))
clean_merge = -1;
- } else if (!oideq(&dst_other.oid, null_oid())) {
+ } else if (!oideq(&dst_other.oid, null_oid(the_hash_algo))) {
/*
* Probably not a clean merge, but it's
* premature to set clean_merge to 0 here,
if (repo_get_merge_bases(the_repository, local, remote, &bases) < 0)
exit(128);
if (!bases) {
- base_oid = null_oid();
+ base_oid = null_oid(the_hash_algo);
base_tree_oid = the_hash_algo->empty_tree;
if (o->verbosity >= 4)
printf("No merge base found; doing history-less merge\n");
if (note)
return add_note(t, to_obj, note, combine_notes);
else if (existing_note)
- return add_note(t, to_obj, null_oid(), combine_notes);
+ return add_note(t, to_obj, null_oid(the_hash_algo), combine_notes);
return 0;
}
opts.strict = 1;
opts.error_func = hash_format_check_report;
- if (fsck_buffer(null_oid(), type, buf, size, &opts))
+ if (fsck_buffer(null_oid(the_hash_algo), type, buf, size, &opts))
die(_("refusing to create malformed object"));
fsck_finish(&opts);
}
struct object_id *target = opt->value;
if (unset) {
- oidcpy(target, null_oid());
+ oidcpy(target, null_oid(the_hash_algo));
return 0;
}
if (!arg)
{
struct diff_filespec *spec = alloc_filespec(name);
- fill_filespec(spec, null_oid(), 0, 0100644);
+ fill_filespec(spec, null_oid(the_hash_algo), 0, 0100644);
spec->data = (char *)p;
spec->size = strlen(p);
spec->should_munmap = 0;
end = (unsigned char *)hdr + size;
start = end - the_hash_algo->rawsz;
oidread(&oid, start, the_repository->hash_algo);
- if (oideq(&oid, null_oid()))
+ if (oideq(&oid, null_oid(the_hash_algo)))
return 0;
the_hash_algo->init_fn(&c);
return 1;
}
return ref_transaction_update(transaction, refname, new_oid,
- null_oid(), new_target, NULL, flags,
+ null_oid(the_hash_algo), new_target, NULL, flags,
msg, err);
}
if (old_target && !(flags & REF_NO_DEREF))
BUG("delete cannot operate on symrefs with deref mode");
return ref_transaction_update(transaction, refname,
- null_oid(), old_oid,
+ null_oid(the_hash_algo), old_oid,
NULL, old_target, flags,
msg, err);
}
subrepo = xmalloc(sizeof(*subrepo));
if (repo_submodule_init(subrepo, repo, submodule,
- null_oid())) {
+ null_oid(the_hash_algo))) {
free(subrepo);
goto done;
}
strbuf_reset(&buf);
if (!(update->flags & REF_HAVE_OLD))
- strbuf_addf(&buf, "%s ", oid_to_hex(null_oid()));
+ strbuf_addf(&buf, "%s ", oid_to_hex(null_oid(the_hash_algo)));
else if (update->old_target)
strbuf_addf(&buf, "ref:%s ", update->old_target);
else
strbuf_addf(&buf, "%s ", oid_to_hex(&update->old_oid));
if (!(update->flags & REF_HAVE_NEW))
- strbuf_addf(&buf, "%s ", oid_to_hex(null_oid()));
+ strbuf_addf(&buf, "%s ", oid_to_hex(null_oid(the_hash_algo)));
else if (update->new_target)
strbuf_addf(&buf, "ref:%s ", update->new_target);
else
if (ret < 0)
goto done;
- ret = ref_transaction_update(data->transaction, refname, NULL, null_oid(),
+ ret = ref_transaction_update(data->transaction, refname, NULL, null_oid(the_hash_algo),
symref_target.buf, NULL,
REF_SKIP_CREATE_REFLOG | REF_NO_DEREF, NULL, data->errbuf);
if (ret < 0)
struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
int res = 0;
- oidcpy(oid, null_oid());
+ oidcpy(oid, null_oid(ref_store->repo->hash_algo));
res = drefs->refs->be->read_raw_ref(drefs->refs, refname, oid, referent,
type, failure_errno);
ref_transaction_add_update(
transaction, r->name,
REF_NO_DEREF | REF_HAVE_NEW | REF_HAVE_OLD | REF_IS_PRUNING,
- null_oid(), &r->oid, NULL, NULL, NULL, NULL);
+ null_oid(the_hash_algo), &r->oid, NULL, NULL, NULL, NULL);
if (ref_transaction_commit(transaction, &err))
goto cleanup;
}
if (!ret && run_hook)
run_hooks_l(the_repository, "post-checkout",
- oid_to_hex(head ? head : null_oid()),
+ oid_to_hex(head ? head : null_oid(the_hash_algo)),
oid_to_hex(oid), "1", NULL);
strbuf_release(&msg);
return ret;
CALLOC_ARRAY(rec, 1);
- oidcpy(&rec->before, null_oid());
- oidcpy(&rec->after, null_oid());
+ oidcpy(&rec->before, null_oid(the_hash_algo));
+ oidcpy(&rec->after, null_oid(the_hash_algo));
/* This may fail, but that's fine, we will keep the null OID. */
refs_read_ref(get_main_ref_store(the_repository), ref, &rec->before);
if (!transaction ||
ref_transaction_update(transaction, "HEAD",
to, unborn && !is_rebase_i(opts) ?
- null_oid() : from, NULL, NULL,
+ null_oid(the_hash_algo) : from, NULL, NULL,
0, sb.buf, &err) ||
ref_transaction_commit(transaction, &err)) {
ref_transaction_free(transaction);
0, err);
if (!transaction ||
ref_transaction_update(transaction, "HEAD", new_head,
- old_head ? &old_head->object.oid : null_oid(),
+ old_head ? &old_head->object.oid : null_oid(the_hash_algo),
NULL, NULL, 0, sb.buf, err) ||
ref_transaction_commit(transaction, err)) {
ret = -1;
write_file(path, "%s", oid_to_hex(&oid));
} else {
refs_update_ref(get_main_ref_store(r), "", refname,
- &oid, null_oid(), 0, UPDATE_REFS_DIE_ON_ERR);
+ &oid, null_oid(the_hash_algo), 0, UPDATE_REFS_DIE_ON_ERR);
}
printf(_("Created autostash: %s\n"), buf.buf);
parameter.cache = repo->submodule_cache;
parameter.treeish_name = NULL;
- parameter.gitmodules_oid = null_oid();
+ parameter.gitmodules_oid = null_oid(the_hash_algo);
parameter.overwrite = 1;
return parse_config(var, value, ctx, ¶meter);
if (is_gitmodules_unmerged(the_repository->index))
die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first"));
- submodule = submodule_from_path(the_repository, null_oid(), oldpath);
+ submodule = submodule_from_path(the_repository, null_oid(the_hash_algo), oldpath);
if (!submodule || !submodule->name) {
warning(_("Could not find section in .gitmodules where path=%s"), oldpath);
return -1;
if (is_gitmodules_unmerged(the_repository->index))
die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first"));
- submodule = submodule_from_path(the_repository, null_oid(), path);
+ submodule = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!submodule || !submodule->name) {
warning(_("Could not find section in .gitmodules where path=%s"), path);
return -1;
const char *path)
{
const struct submodule *submodule = submodule_from_path(the_repository,
- null_oid(),
+ null_oid(the_hash_algo),
path);
if (submodule) {
const char *ignore;
int is_submodule_active(struct repository *repo, const char *path)
{
- return is_tree_submodule_active(repo, null_oid(), path);
+ return is_tree_submodule_active(repo, null_oid(the_hash_algo), path);
}
int is_submodule_populated_gently(const char *path, int *return_error_code)
if (!should_update_submodules())
return NULL;
- return submodule_from_path(the_repository, null_oid(), ce->name);
+ return submodule_from_path(the_repository, null_oid(the_hash_algo), ce->name);
}
const char *path,
struct oid_array *commits)
{
- if (!submodule_has_commits(r, path, null_oid(), commits))
+ if (!submodule_has_commits(r, path, null_oid(the_hash_algo), commits))
/*
* NOTE: We do consider it safe to return "no" here. The
* correct answer would be "We do not know" instead of
const struct submodule *submodule;
const char *path = NULL;
- submodule = submodule_from_name(r, null_oid(), name->string);
+ submodule = submodule_from_name(r, null_oid(the_hash_algo), name->string);
if (submodule)
path = submodule->path;
else
const struct submodule *submodule;
const char *path = NULL;
- submodule = submodule_from_name(r, null_oid(), name->string);
+ submodule = submodule_from_name(r, null_oid(the_hash_algo), name->string);
if (submodule)
path = submodule->path;
else
if (!path)
continue;
- if (submodule_has_commits(r, path, null_oid(), &cs_data->new_commits)) {
+ if (submodule_has_commits(r, path, null_oid(the_hash_algo), &cs_data->new_commits)) {
changed_submodule_data_clear(cs_data);
*name->string = '\0';
}
if (!S_ISGITLINK(ce->ce_mode))
continue;
- task = fetch_task_create(spf, ce->name, null_oid());
+ task = fetch_task_create(spf, ce->name, null_oid(the_hash_algo));
if (!task)
continue;
if (old_head && !is_submodule_populated_gently(path, error_code_ptr))
return 0;
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub)
BUG("could not get submodule information for '%s'", path);
real_old_git_dir = real_pathdup(old_git_dir, 1);
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub)
die(_("could not lookup name for submodule '%s'"), path);
* superproject did not rewrite the git file links yet,
* fix it now.
*/
- sub = submodule_from_path(the_repository, null_oid(), path);
+ sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
if (!sub)
die(_("could not lookup name for submodule '%s'"), path);
submodule_name_to_gitdir(&sub_gitdir, the_repository, sub->name);
strbuf_addstr(buf, git_dir);
}
if (!is_git_directory(buf->buf)) {
- sub = submodule_from_path(repo, null_oid(), submodule);
+ sub = submodule_from_path(repo, null_oid(the_hash_algo), submodule);
if (!sub) {
ret = -1;
goto cleanup;
static int cmd_resolve_ref(struct ref_store *refs, const char **argv)
{
- struct object_id oid = *null_oid();
+ struct object_id oid = *null_oid(the_hash_algo);
const char *refname = notnull(*argv++, "refname");
int resolve_flags = arg_flags(*argv++, "resolve-flags", empty_flags);
int flags;
setup_git_directory();
- if (repo_submodule_init(&subrepo, the_repository, argv[1], null_oid())) {
+ if (repo_submodule_init(&subrepo, the_repository, argv[1], null_oid(the_hash_algo))) {
die_usage(argv, "Submodule not found.");
}
strbuf_add(base, path, pathlen);
p = combine_diff_path_new(base->buf, base->len, mode,
- oid ? oid : null_oid(),
+ oid ? oid : null_oid(the_hash_algo),
nparent);
strbuf_setlen(base, old_baselen);
mode_i = tp[i].entry.mode;
}
else {
- oid_i = null_oid();
+ oid_i = null_oid(the_hash_algo);
mode_i = 0;
}
for_each_namespaced_ref_1(send_ref, &data);
if (!data.sent_capabilities) {
const char *refname = "capabilities^{}";
- write_v0_ref(&data, refname, refname, null_oid());
+ write_v0_ref(&data, refname, refname, null_oid(the_hash_algo));
}
/*
* fflush stdout before calling advertise_shallow_grafts because send_ref
if (!sequencer_get_last_command(r, &action)) {
if (action == REPLAY_PICK && !state->cherry_pick_in_progress) {
state->cherry_pick_in_progress = 1;
- oidcpy(&state->cherry_pick_head_oid, null_oid());
+ oidcpy(&state->cherry_pick_head_oid, null_oid(the_hash_algo));
} else if (action == REPLAY_REVERT && !state->revert_in_progress) {
state->revert_in_progress = 1;
- oidcpy(&state->revert_head_oid, null_oid());
+ oidcpy(&state->revert_head_oid, null_oid(the_hash_algo));
}
}
if (get_detached_from)
unsigned long size;
enum object_type type;
- if (oideq(oid, null_oid())) {
+ if (oideq(oid, null_oid(the_hash_algo))) {
ptr->ptr = xstrdup("");
ptr->size = 0;
return;