Convert remaining callers of resolve_refdup to object_id
There are a few leaf functions in various files that call resolve_refdup. Convert these functions to use struct object_id internally to prepare for transitioning resolve_refdup itself. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
52684310ba
commit
2928325fc0
@ -693,7 +693,7 @@ static int merge_abort(struct notes_merge_options *o)
|
|||||||
static int merge_commit(struct notes_merge_options *o)
|
static int merge_commit(struct notes_merge_options *o)
|
||||||
{
|
{
|
||||||
struct strbuf msg = STRBUF_INIT;
|
struct strbuf msg = STRBUF_INIT;
|
||||||
unsigned char sha1[20], parent_sha1[20];
|
struct object_id oid, parent_oid;
|
||||||
struct notes_tree *t;
|
struct notes_tree *t;
|
||||||
struct commit *partial;
|
struct commit *partial;
|
||||||
struct pretty_print_context pretty_ctx;
|
struct pretty_print_context pretty_ctx;
|
||||||
@ -705,27 +705,27 @@ static int merge_commit(struct notes_merge_options *o)
|
|||||||
* and target notes ref from .git/NOTES_MERGE_REF.
|
* and target notes ref from .git/NOTES_MERGE_REF.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (get_sha1("NOTES_MERGE_PARTIAL", sha1))
|
if (get_oid("NOTES_MERGE_PARTIAL", &oid))
|
||||||
die(_("failed to read ref NOTES_MERGE_PARTIAL"));
|
die(_("failed to read ref NOTES_MERGE_PARTIAL"));
|
||||||
else if (!(partial = lookup_commit_reference(sha1)))
|
else if (!(partial = lookup_commit_reference(oid.hash)))
|
||||||
die(_("could not find commit from NOTES_MERGE_PARTIAL."));
|
die(_("could not find commit from NOTES_MERGE_PARTIAL."));
|
||||||
else if (parse_commit(partial))
|
else if (parse_commit(partial))
|
||||||
die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
|
die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
|
||||||
|
|
||||||
if (partial->parents)
|
if (partial->parents)
|
||||||
hashcpy(parent_sha1, partial->parents->item->object.oid.hash);
|
oidcpy(&parent_oid, &partial->parents->item->object.oid);
|
||||||
else
|
else
|
||||||
hashclr(parent_sha1);
|
oidclr(&parent_oid);
|
||||||
|
|
||||||
t = xcalloc(1, sizeof(struct notes_tree));
|
t = xcalloc(1, sizeof(struct notes_tree));
|
||||||
init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
|
init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
|
||||||
|
|
||||||
o->local_ref = local_ref_to_free =
|
o->local_ref = local_ref_to_free =
|
||||||
resolve_refdup("NOTES_MERGE_REF", 0, sha1, NULL);
|
resolve_refdup("NOTES_MERGE_REF", 0, oid.hash, NULL);
|
||||||
if (!o->local_ref)
|
if (!o->local_ref)
|
||||||
die(_("failed to resolve NOTES_MERGE_REF"));
|
die(_("failed to resolve NOTES_MERGE_REF"));
|
||||||
|
|
||||||
if (notes_merge_commit(o, t, partial, sha1))
|
if (notes_merge_commit(o, t, partial, oid.hash))
|
||||||
die(_("failed to finalize notes merge"));
|
die(_("failed to finalize notes merge"));
|
||||||
|
|
||||||
/* Reuse existing commit message in reflog message */
|
/* Reuse existing commit message in reflog message */
|
||||||
@ -733,8 +733,8 @@ static int merge_commit(struct notes_merge_options *o)
|
|||||||
format_commit_message(partial, "%s", &msg, &pretty_ctx);
|
format_commit_message(partial, "%s", &msg, &pretty_ctx);
|
||||||
strbuf_trim(&msg);
|
strbuf_trim(&msg);
|
||||||
strbuf_insert(&msg, 0, "notes: ", 7);
|
strbuf_insert(&msg, 0, "notes: ", 7);
|
||||||
update_ref(msg.buf, o->local_ref, sha1,
|
update_ref(msg.buf, o->local_ref, oid.hash,
|
||||||
is_null_sha1(parent_sha1) ? NULL : parent_sha1,
|
is_null_oid(&parent_oid) ? NULL : parent_oid.hash,
|
||||||
0, UPDATE_REFS_DIE_ON_ERR);
|
0, UPDATE_REFS_DIE_ON_ERR);
|
||||||
|
|
||||||
free_notes(t);
|
free_notes(t);
|
||||||
|
@ -1414,7 +1414,7 @@ static void execute_commands(struct command *commands,
|
|||||||
{
|
{
|
||||||
struct check_connected_options opt = CHECK_CONNECTED_INIT;
|
struct check_connected_options opt = CHECK_CONNECTED_INIT;
|
||||||
struct command *cmd;
|
struct command *cmd;
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
struct iterate_data data;
|
struct iterate_data data;
|
||||||
struct async muxer;
|
struct async muxer;
|
||||||
int err_fd = 0;
|
int err_fd = 0;
|
||||||
@ -1471,7 +1471,7 @@ static void execute_commands(struct command *commands,
|
|||||||
check_aliased_updates(commands);
|
check_aliased_updates(commands);
|
||||||
|
|
||||||
free(head_name_to_free);
|
free(head_name_to_free);
|
||||||
head_name = head_name_to_free = resolve_refdup("HEAD", 0, sha1, NULL);
|
head_name = head_name_to_free = resolve_refdup("HEAD", 0, oid.hash, NULL);
|
||||||
|
|
||||||
if (use_atomic)
|
if (use_atomic)
|
||||||
execute_commands_atomic(commands, si);
|
execute_commands_atomic(commands, si);
|
||||||
|
@ -961,9 +961,9 @@ static void populate_value(struct ref_array_item *ref)
|
|||||||
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
|
ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
|
||||||
|
|
||||||
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
|
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
|
||||||
unsigned char unused1[20];
|
struct object_id unused1;
|
||||||
ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
|
ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
|
||||||
unused1, NULL);
|
unused1.hash, NULL);
|
||||||
if (!ref->symref)
|
if (!ref->symref)
|
||||||
ref->symref = "";
|
ref->symref = "";
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
|
|||||||
reflogs->ref = xstrdup(ref);
|
reflogs->ref = xstrdup(ref);
|
||||||
for_each_reflog_ent(ref, read_one_reflog, reflogs);
|
for_each_reflog_ent(ref, read_one_reflog, reflogs);
|
||||||
if (reflogs->nr == 0) {
|
if (reflogs->nr == 0) {
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
const char *name;
|
const char *name;
|
||||||
void *name_to_free;
|
void *name_to_free;
|
||||||
name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,
|
name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING,
|
||||||
sha1, NULL);
|
oid.hash, NULL);
|
||||||
if (name) {
|
if (name) {
|
||||||
for_each_reflog_ent(name, read_one_reflog, reflogs);
|
for_each_reflog_ent(name, read_one_reflog, reflogs);
|
||||||
free(name_to_free);
|
free(name_to_free);
|
||||||
@ -172,18 +172,18 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
|
|||||||
reflogs = item->util;
|
reflogs = item->util;
|
||||||
else {
|
else {
|
||||||
if (*branch == '\0') {
|
if (*branch == '\0') {
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
free(branch);
|
free(branch);
|
||||||
branch = resolve_refdup("HEAD", 0, sha1, NULL);
|
branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
|
||||||
if (!branch)
|
if (!branch)
|
||||||
die ("No current branch");
|
die ("No current branch");
|
||||||
|
|
||||||
}
|
}
|
||||||
reflogs = read_complete_reflog(branch);
|
reflogs = read_complete_reflog(branch);
|
||||||
if (!reflogs || reflogs->nr == 0) {
|
if (!reflogs || reflogs->nr == 0) {
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
char *b;
|
char *b;
|
||||||
if (dwim_log(branch, strlen(branch), sha1, &b) == 1) {
|
if (dwim_log(branch, strlen(branch), oid.hash, &b) == 1) {
|
||||||
if (reflogs) {
|
if (reflogs) {
|
||||||
free(reflogs->ref);
|
free(reflogs->ref);
|
||||||
free(reflogs);
|
free(reflogs);
|
||||||
|
@ -467,11 +467,11 @@ void transport_print_push_status(const char *dest, struct ref *refs,
|
|||||||
{
|
{
|
||||||
struct ref *ref;
|
struct ref *ref;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
unsigned char head_sha1[20];
|
struct object_id head_oid;
|
||||||
char *head;
|
char *head;
|
||||||
int summary_width = transport_summary_width(refs);
|
int summary_width = transport_summary_width(refs);
|
||||||
|
|
||||||
head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_sha1, NULL);
|
head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
for (ref = refs; ref; ref = ref->next)
|
for (ref = refs; ref; ref = ref->next)
|
||||||
|
@ -121,7 +121,7 @@ static void status_printf_more(struct wt_status *s, const char *color,
|
|||||||
|
|
||||||
void wt_status_prepare(struct wt_status *s)
|
void wt_status_prepare(struct wt_status *s)
|
||||||
{
|
{
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
|
|
||||||
memset(s, 0, sizeof(*s));
|
memset(s, 0, sizeof(*s));
|
||||||
memcpy(s->color_palette, default_wt_status_colors,
|
memcpy(s->color_palette, default_wt_status_colors,
|
||||||
@ -129,7 +129,7 @@ void wt_status_prepare(struct wt_status *s)
|
|||||||
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
|
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
|
||||||
s->use_color = -1;
|
s->use_color = -1;
|
||||||
s->relative_paths = 1;
|
s->relative_paths = 1;
|
||||||
s->branch = resolve_refdup("HEAD", 0, sha1, NULL);
|
s->branch = resolve_refdup("HEAD", 0, oid.hash, NULL);
|
||||||
s->reference = "HEAD";
|
s->reference = "HEAD";
|
||||||
s->fp = stdout;
|
s->fp = stdout;
|
||||||
s->index_file = get_index_file();
|
s->index_file = get_index_file();
|
||||||
|
Loading…
Reference in New Issue
Block a user