提交 ae077771 编写于 作者: B brian m. carlson 提交者: Junio C Hamano

refs: convert update_ref and refs_update_ref to use struct object_id

Convert update_ref, refs_update_ref, and write_pseudoref to use struct
object_id.  Update the existing callers as well.  Remove update_ref_oid,
as it is no longer needed.
Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 2616a5e5
...@@ -685,11 +685,12 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout) ...@@ -685,11 +685,12 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
char bisect_rev_hex[GIT_MAX_HEXSZ + 1]; char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1); memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);
update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR); update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
argv_checkout[2] = bisect_rev_hex; argv_checkout[2] = bisect_rev_hex;
if (no_checkout) { if (no_checkout) {
update_ref(NULL, "BISECT_HEAD", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR); update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0,
UPDATE_REFS_DIE_ON_ERR);
} else { } else {
int res; int res;
res = run_command_v_opt(argv_checkout, RUN_GIT_CMD); res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);
......
...@@ -1068,7 +1068,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, ...@@ -1068,7 +1068,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
if (!get_oid("HEAD", &curr_head)) { if (!get_oid("HEAD", &curr_head)) {
write_state_text(state, "abort-safety", oid_to_hex(&curr_head)); write_state_text(state, "abort-safety", oid_to_hex(&curr_head));
if (!state->rebasing) if (!state->rebasing)
update_ref_oid("am", "ORIG_HEAD", &curr_head, NULL, 0, update_ref("am", "ORIG_HEAD", &curr_head, NULL, 0,
UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
} else { } else {
write_state_text(state, "abort-safety", ""); write_state_text(state, "abort-safety", "");
...@@ -1686,7 +1686,7 @@ static void do_commit(const struct am_state *state) ...@@ -1686,7 +1686,7 @@ static void do_commit(const struct am_state *state)
strbuf_addf(&sb, "%s: %.*s", reflog_msg, linelen(state->msg), strbuf_addf(&sb, "%s: %.*s", reflog_msg, linelen(state->msg),
state->msg); state->msg);
update_ref_oid(sb.buf, "HEAD", &commit, old_oid, 0, update_ref(sb.buf, "HEAD", &commit, old_oid, 0,
UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
if (state->rebasing) { if (state->rebasing) {
...@@ -2147,7 +2147,7 @@ static void am_abort(struct am_state *state) ...@@ -2147,7 +2147,7 @@ static void am_abort(struct am_state *state)
clean_index(&curr_head, &orig_head); clean_index(&curr_head, &orig_head);
if (has_orig_head) if (has_orig_head)
update_ref_oid("am --abort", "HEAD", &orig_head, update_ref("am --abort", "HEAD", &orig_head,
has_curr_head ? &curr_head : NULL, 0, has_curr_head ? &curr_head : NULL, 0,
UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
else if (curr_branch) else if (curr_branch)
......
...@@ -664,7 +664,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts, ...@@ -664,7 +664,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) { if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
/* Nothing to do. */ /* Nothing to do. */
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */ } else if (opts->force_detach || !new->path) { /* No longer on any branch. */
update_ref(msg.buf, "HEAD", new->commit->object.oid.hash, NULL, update_ref(msg.buf, "HEAD", &new->commit->object.oid, NULL,
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR); REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
if (!opts->quiet) { if (!opts->quiet) {
if (old->path && if (old->path &&
......
...@@ -610,8 +610,8 @@ static void write_followtags(const struct ref *refs, const char *msg) ...@@ -610,8 +610,8 @@ static void write_followtags(const struct ref *refs, const char *msg)
continue; continue;
if (!has_object_file(&ref->old_oid)) if (!has_object_file(&ref->old_oid))
continue; continue;
update_ref(msg, ref->name, ref->old_oid.hash, update_ref(msg, ref->name, &ref->old_oid, NULL, 0,
NULL, 0, UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
} }
} }
...@@ -682,23 +682,23 @@ static void update_head(const struct ref *our, const struct ref *remote, ...@@ -682,23 +682,23 @@ static void update_head(const struct ref *our, const struct ref *remote,
if (create_symref("HEAD", our->name, NULL) < 0) if (create_symref("HEAD", our->name, NULL) < 0)
die(_("unable to update HEAD")); die(_("unable to update HEAD"));
if (!option_bare) { if (!option_bare) {
update_ref(msg, "HEAD", our->old_oid.hash, NULL, 0, update_ref(msg, "HEAD", &our->old_oid, NULL, 0,
UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
install_branch_config(0, head, option_origin, our->name); install_branch_config(0, head, option_origin, our->name);
} }
} else if (our) { } else if (our) {
struct commit *c = lookup_commit_reference(&our->old_oid); struct commit *c = lookup_commit_reference(&our->old_oid);
/* --branch specifies a non-branch (i.e. tags), detach HEAD */ /* --branch specifies a non-branch (i.e. tags), detach HEAD */
update_ref(msg, "HEAD", c->object.oid.hash, update_ref(msg, "HEAD", &c->object.oid, NULL, REF_NODEREF,
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
} else if (remote) { } else if (remote) {
/* /*
* We know remote HEAD points to a non-branch, or * We know remote HEAD points to a non-branch, or
* HEAD points to a branch but we don't know which one. * HEAD points to a branch but we don't know which one.
* Detach HEAD in all these cases. * Detach HEAD in all these cases.
*/ */
update_ref(msg, "HEAD", remote->old_oid.hash, update_ref(msg, "HEAD", &remote->old_oid, NULL, REF_NODEREF,
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
} }
} }
......
...@@ -405,9 +405,8 @@ static void finish(struct commit *head_commit, ...@@ -405,9 +405,8 @@ static void finish(struct commit *head_commit,
printf(_("No merge message -- not updating HEAD\n")); printf(_("No merge message -- not updating HEAD\n"));
else { else {
const char *argv_gc_auto[] = { "gc", "--auto", NULL }; const char *argv_gc_auto[] = { "gc", "--auto", NULL };
update_ref(reflog_message.buf, "HEAD", update_ref(reflog_message.buf, "HEAD", new_head, head,
new_head->hash, head->hash, 0, 0, UPDATE_REFS_DIE_ON_ERR);
UPDATE_REFS_DIE_ON_ERR);
/* /*
* We ignore errors in 'gc --auto', since the * We ignore errors in 'gc --auto', since the
* user should see them. * user should see them.
...@@ -1261,8 +1260,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) ...@@ -1261,8 +1260,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
die(_("Can merge only exactly one commit into empty head")); die(_("Can merge only exactly one commit into empty head"));
remote_head_oid = &remoteheads->item->object.oid; remote_head_oid = &remoteheads->item->object.oid;
read_empty(remote_head_oid->hash, 0); read_empty(remote_head_oid->hash, 0);
update_ref("initial pull", "HEAD", remote_head_oid->hash, update_ref("initial pull", "HEAD", remote_head_oid, NULL, 0,
NULL, 0, UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
goto done; goto done;
} }
...@@ -1357,8 +1356,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) ...@@ -1357,8 +1356,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
free(list); free(list);
} }
update_ref("updating ORIG_HEAD", "ORIG_HEAD", head_commit->object.oid.hash, update_ref("updating ORIG_HEAD", "ORIG_HEAD",
NULL, 0, UPDATE_REFS_DIE_ON_ERR); &head_commit->object.oid, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
if (remoteheads && !common) { if (remoteheads && !common) {
/* No common ancestors found. */ /* No common ancestors found. */
......
...@@ -736,8 +736,8 @@ static int merge_commit(struct notes_merge_options *o) ...@@ -736,8 +736,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, oid.hash, update_ref(msg.buf, o->local_ref, &oid,
is_null_oid(&parent_oid) ? NULL : parent_oid.hash, is_null_oid(&parent_oid) ? NULL : &parent_oid,
0, UPDATE_REFS_DIE_ON_ERR); 0, UPDATE_REFS_DIE_ON_ERR);
free_notes(t); free_notes(t);
...@@ -850,12 +850,12 @@ static int merge(int argc, const char **argv, const char *prefix) ...@@ -850,12 +850,12 @@ static int merge(int argc, const char **argv, const char *prefix)
if (result >= 0) /* Merge resulted (trivially) in result_oid */ if (result >= 0) /* Merge resulted (trivially) in result_oid */
/* Update default notes ref with new commit */ /* Update default notes ref with new commit */
update_ref(msg.buf, default_notes_ref(), result_oid.hash, NULL, update_ref(msg.buf, default_notes_ref(), &result_oid, NULL, 0,
0, UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
else { /* Merge has unresolved conflicts */ else { /* Merge has unresolved conflicts */
const struct worktree *wt; const struct worktree *wt;
/* Update .git/NOTES_MERGE_PARTIAL with partial merge result */ /* Update .git/NOTES_MERGE_PARTIAL with partial merge result */
update_ref(msg.buf, "NOTES_MERGE_PARTIAL", result_oid.hash, NULL, update_ref(msg.buf, "NOTES_MERGE_PARTIAL", &result_oid, NULL,
0, UPDATE_REFS_DIE_ON_ERR); 0, UPDATE_REFS_DIE_ON_ERR);
/* Store ref-to-be-updated into .git/NOTES_MERGE_REF */ /* Store ref-to-be-updated into .git/NOTES_MERGE_REF */
wt = find_shared_symref("NOTES_MERGE_REF", default_notes_ref()); wt = find_shared_symref("NOTES_MERGE_REF", default_notes_ref());
......
...@@ -544,7 +544,7 @@ static int pull_into_void(const struct object_id *merge_head, ...@@ -544,7 +544,7 @@ static int pull_into_void(const struct object_id *merge_head,
if (checkout_fast_forward(&empty_tree_oid, merge_head, 0)) if (checkout_fast_forward(&empty_tree_oid, merge_head, 0))
return 1; return 1;
if (update_ref("initial pull", "HEAD", merge_head->hash, curr_head->hash, 0, UPDATE_REFS_DIE_ON_ERR)) if (update_ref("initial pull", "HEAD", merge_head, curr_head, 0, UPDATE_REFS_DIE_ON_ERR))
return 1; return 1;
return 0; return 0;
......
...@@ -266,12 +266,12 @@ static int reset_refs(const char *rev, const struct object_id *oid) ...@@ -266,12 +266,12 @@ static int reset_refs(const char *rev, const struct object_id *oid)
if (!get_oid("HEAD", &oid_orig)) { if (!get_oid("HEAD", &oid_orig)) {
orig = &oid_orig; orig = &oid_orig;
set_reflog_message(&msg, "updating ORIG_HEAD", NULL); set_reflog_message(&msg, "updating ORIG_HEAD", NULL);
update_ref_oid(msg.buf, "ORIG_HEAD", orig, old_orig, 0, update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0,
UPDATE_REFS_MSG_ON_ERR); UPDATE_REFS_MSG_ON_ERR);
} else if (old_orig) } else if (old_orig)
delete_ref(NULL, "ORIG_HEAD", old_orig, 0); delete_ref(NULL, "ORIG_HEAD", old_orig, 0);
set_reflog_message(&msg, "updating HEAD", rev); set_reflog_message(&msg, "updating HEAD", rev);
update_ref_status = update_ref_oid(msg.buf, "HEAD", oid, orig, 0, update_ref_status = update_ref(msg.buf, "HEAD", oid, orig, 0,
UPDATE_REFS_MSG_ON_ERR); UPDATE_REFS_MSG_ON_ERR);
strbuf_release(&msg); strbuf_release(&msg);
return update_ref_status; return update_ref_status;
......
...@@ -437,7 +437,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) ...@@ -437,7 +437,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
(oldval && !is_null_oid(&oldoid)) ? &oldoid : NULL, (oldval && !is_null_oid(&oldoid)) ? &oldoid : NULL,
flags); flags);
else else
return update_ref(msg, refname, oid.hash, oldval ? oldoid.hash : NULL, return update_ref(msg, refname, &oid, oldval ? &oldoid : NULL,
flags | create_reflog_flag, flags | create_reflog_flag,
UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
} }
...@@ -59,7 +59,7 @@ int notes_cache_write(struct notes_cache *c) ...@@ -59,7 +59,7 @@ int notes_cache_write(struct notes_cache *c)
if (commit_tree(c->validity, strlen(c->validity), tree_oid.hash, NULL, if (commit_tree(c->validity, strlen(c->validity), tree_oid.hash, NULL,
commit_oid.hash, NULL, NULL) < 0) commit_oid.hash, NULL, NULL) < 0)
return -1; return -1;
if (update_ref("update notes cache", c->tree.update_ref, commit_oid.hash, if (update_ref("update notes cache", c->tree.update_ref, &commit_oid,
NULL, 0, UPDATE_REFS_QUIET_ON_ERR) < 0) NULL, 0, UPDATE_REFS_QUIET_ON_ERR) < 0)
return -1; return -1;
......
...@@ -49,7 +49,7 @@ void commit_notes(struct notes_tree *t, const char *msg) ...@@ -49,7 +49,7 @@ void commit_notes(struct notes_tree *t, const char *msg)
create_notes_commit(t, NULL, buf.buf, buf.len, commit_oid.hash); create_notes_commit(t, NULL, buf.buf, buf.len, commit_oid.hash);
strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */ strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */
update_ref(buf.buf, t->update_ref, commit_oid.hash, NULL, 0, update_ref(buf.buf, t->update_ref, &commit_oid, NULL, 0,
UPDATE_REFS_DIE_ON_ERR); UPDATE_REFS_DIE_ON_ERR);
strbuf_release(&buf); strbuf_release(&buf);
......
...@@ -574,8 +574,8 @@ long get_files_ref_lock_timeout_ms(void) ...@@ -574,8 +574,8 @@ long get_files_ref_lock_timeout_ms(void)
return timeout_ms; return timeout_ms;
} }
static int write_pseudoref(const char *pseudoref, const unsigned char *sha1, static int write_pseudoref(const char *pseudoref, const struct object_id *oid,
const unsigned char *old_sha1, struct strbuf *err) const struct object_id *old_oid, struct strbuf *err)
{ {
const char *filename; const char *filename;
int fd; int fd;
...@@ -583,7 +583,7 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1, ...@@ -583,7 +583,7 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,
struct strbuf buf = STRBUF_INIT; struct strbuf buf = STRBUF_INIT;
int ret = -1; int ret = -1;
strbuf_addf(&buf, "%s\n", sha1_to_hex(sha1)); strbuf_addf(&buf, "%s\n", oid_to_hex(oid));
filename = git_path("%s", pseudoref); filename = git_path("%s", pseudoref);
fd = hold_lock_file_for_update_timeout(&lock, filename, fd = hold_lock_file_for_update_timeout(&lock, filename,
...@@ -595,12 +595,12 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1, ...@@ -595,12 +595,12 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,
goto done; goto done;
} }
if (old_sha1) { if (old_oid) {
unsigned char actual_old_sha1[20]; struct object_id actual_old_oid;
if (read_ref(pseudoref, actual_old_sha1)) if (read_ref(pseudoref, actual_old_oid.hash))
die("could not read ref '%s'", pseudoref); die("could not read ref '%s'", pseudoref);
if (hashcmp(actual_old_sha1, old_sha1)) { if (oidcmp(&actual_old_oid, old_oid)) {
strbuf_addf(err, "unexpected sha1 when writing '%s'", pseudoref); strbuf_addf(err, "unexpected sha1 when writing '%s'", pseudoref);
rollback_lock_file(&lock); rollback_lock_file(&lock);
goto done; goto done;
...@@ -985,17 +985,9 @@ int ref_transaction_verify(struct ref_transaction *transaction, ...@@ -985,17 +985,9 @@ int ref_transaction_verify(struct ref_transaction *transaction,
flags, NULL, err); flags, NULL, err);
} }
int update_ref_oid(const char *msg, const char *refname,
const struct object_id *new_oid, const struct object_id *old_oid,
unsigned int flags, enum action_on_err onerr)
{
return update_ref(msg, refname, new_oid ? new_oid->hash : NULL,
old_oid ? old_oid->hash : NULL, flags, onerr);
}
int refs_update_ref(struct ref_store *refs, const char *msg, int refs_update_ref(struct ref_store *refs, const char *msg,
const char *refname, const unsigned char *new_sha1, const char *refname, const struct object_id *new_oid,
const unsigned char *old_sha1, unsigned int flags, const struct object_id *old_oid, unsigned int flags,
enum action_on_err onerr) enum action_on_err onerr)
{ {
struct ref_transaction *t = NULL; struct ref_transaction *t = NULL;
...@@ -1004,11 +996,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg, ...@@ -1004,11 +996,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
if (ref_type(refname) == REF_TYPE_PSEUDOREF) { if (ref_type(refname) == REF_TYPE_PSEUDOREF) {
assert(refs == get_main_ref_store()); assert(refs == get_main_ref_store());
ret = write_pseudoref(refname, new_sha1, old_sha1, &err); ret = write_pseudoref(refname, new_oid, old_oid, &err);
} else { } else {
t = ref_store_transaction_begin(refs, &err); t = ref_store_transaction_begin(refs, &err);
if (!t || if (!t ||
ref_transaction_update(t, refname, new_sha1, old_sha1, ref_transaction_update(t, refname, new_oid ? new_oid->hash : NULL,
old_oid ? old_oid->hash : NULL,
flags, msg, &err) || flags, msg, &err) ||
ref_transaction_commit(t, &err)) { ref_transaction_commit(t, &err)) {
ret = 1; ret = 1;
...@@ -1038,12 +1031,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg, ...@@ -1038,12 +1031,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
} }
int update_ref(const char *msg, const char *refname, int update_ref(const char *msg, const char *refname,
const unsigned char *new_sha1, const struct object_id *new_oid,
const unsigned char *old_sha1, const struct object_id *old_oid,
unsigned int flags, enum action_on_err onerr) unsigned int flags, enum action_on_err onerr)
{ {
return refs_update_ref(get_main_ref_store(), msg, refname, new_sha1, return refs_update_ref(get_main_ref_store(), msg, refname, new_oid,
old_sha1, flags, onerr); old_oid, flags, onerr);
} }
char *shorten_unambiguous_ref(const char *refname, int strict) char *shorten_unambiguous_ref(const char *refname, int strict)
......
...@@ -643,12 +643,9 @@ void ref_transaction_free(struct ref_transaction *transaction); ...@@ -643,12 +643,9 @@ void ref_transaction_free(struct ref_transaction *transaction);
* argument. * argument.
*/ */
int refs_update_ref(struct ref_store *refs, const char *msg, const char *refname, int refs_update_ref(struct ref_store *refs, const char *msg, const char *refname,
const unsigned char *new_sha1, const unsigned char *old_sha1, const struct object_id *new_oid, const struct object_id *old_oid,
unsigned int flags, enum action_on_err onerr); unsigned int flags, enum action_on_err onerr);
int update_ref(const char *msg, const char *refname, int update_ref(const char *msg, const char *refname,
const unsigned char *new_sha1, const unsigned char *old_sha1,
unsigned int flags, enum action_on_err onerr);
int update_ref_oid(const char *msg, const char *refname,
const struct object_id *new_oid, const struct object_id *old_oid, const struct object_id *new_oid, const struct object_id *old_oid,
unsigned int flags, enum action_on_err onerr); unsigned int flags, enum action_on_err onerr);
......
...@@ -1115,11 +1115,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, ...@@ -1115,11 +1115,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
* write it at all. * write it at all.
*/ */
if (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1) && if (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1) &&
update_ref(NULL, "CHERRY_PICK_HEAD", commit->object.oid.hash, NULL, update_ref(NULL, "CHERRY_PICK_HEAD", &commit->object.oid, NULL,
REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))
res = -1; res = -1;
if (command == TODO_REVERT && ((opts->no_commit && res == 0) || res == 1) && if (command == TODO_REVERT && ((opts->no_commit && res == 0) || res == 1) &&
update_ref(NULL, "REVERT_HEAD", commit->object.oid.hash, NULL, update_ref(NULL, "REVERT_HEAD", &commit->object.oid, NULL,
REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) REF_NODEREF, UPDATE_REFS_MSG_ON_ERR))
res = -1; res = -1;
...@@ -2124,7 +2124,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) ...@@ -2124,7 +2124,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
} }
msg = reflog_message(opts, "finish", "%s onto %s", msg = reflog_message(opts, "finish", "%s onto %s",
head_ref.buf, buf.buf); head_ref.buf, buf.buf);
if (update_ref(msg, head_ref.buf, head.hash, orig.hash, if (update_ref(msg, head_ref.buf, &head, &orig,
REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) { REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) {
res = error(_("could not update %s"), res = error(_("could not update %s"),
head_ref.buf); head_ref.buf);
......
...@@ -233,15 +233,15 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv) ...@@ -233,15 +233,15 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv)
const char *new_sha1_buf = notnull(*argv++, "old-sha1"); const char *new_sha1_buf = notnull(*argv++, "old-sha1");
const char *old_sha1_buf = notnull(*argv++, "old-sha1"); const char *old_sha1_buf = notnull(*argv++, "old-sha1");
unsigned int flags = arg_flags(*argv++, "flags"); unsigned int flags = arg_flags(*argv++, "flags");
unsigned char old_sha1[20]; struct object_id old_oid;
unsigned char new_sha1[20]; struct object_id new_oid;
if (get_sha1_hex(old_sha1_buf, old_sha1) || if (get_oid_hex(old_sha1_buf, &old_oid) ||
get_sha1_hex(new_sha1_buf, new_sha1)) get_oid_hex(new_sha1_buf, &new_oid))
die("not sha-1"); die("not sha-1");
return refs_update_ref(refs, msg, refname, return refs_update_ref(refs, msg, refname,
new_sha1, old_sha1, &new_oid, &old_oid,
flags, UPDATE_REFS_DIE_ON_ERR); flags, UPDATE_REFS_DIE_ON_ERR);
} }
......
...@@ -795,7 +795,8 @@ static int push_update_refs_status(struct helper_data *data, ...@@ -795,7 +795,8 @@ static int push_update_refs_status(struct helper_data *data,
private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name); private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
if (!private) if (!private)
continue; continue;
update_ref("update by helper", private, ref->new_oid.hash, NULL, 0, 0); update_ref("update by helper", private, &ref->new_oid, NULL,
0, 0);
free(private); free(private);
} }
strbuf_release(&buf); strbuf_release(&buf);
......
...@@ -305,8 +305,8 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v ...@@ -305,8 +305,8 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int v
if (ref->deletion) { if (ref->deletion) {
delete_ref(NULL, rs.dst, NULL, 0); delete_ref(NULL, rs.dst, NULL, 0);
} else } else
update_ref("update by push", rs.dst, update_ref("update by push", rs.dst, &ref->new_oid,
ref->new_oid.hash, NULL, 0, 0); NULL, 0, 0);
free(rs.dst); free(rs.dst);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册