Merge branch 'bc/object-id' into base
authorMichael Haggerty <mhagger@alum.mit.edu>
Sat, 28 Oct 2017 07:27:15 +0000 (09:27 +0200)
committerMichael Haggerty <mhagger@alum.mit.edu>
Sat, 28 Oct 2017 07:27:15 +0000 (09:27 +0200)
1  2 
builtin/branch.c
builtin/show-branch.c
builtin/tag.c
refs/files-backend.c
sequencer.c
diff --combined builtin/branch.c
index 79dc9181fd6c0008d4b8c3b841f35cc1223d6d74,c5f88b59efb531681583dc610e25c0624269343f..b1ed649300db7d803cf0107561a72e3e57a21658
@@@ -93,7 -93,7 +93,7 @@@ static int git_branch_config(const cha
                        return config_error_nonbool(var);
                return color_parse(value, branch_colors[slot]);
        }
 -      return git_default_config(var, value, cb);
 +      return git_color_default_config(var, value, cb);
  }
  
  static const char *branch_get_color(enum color_branch ix)
@@@ -125,7 -125,7 +125,7 @@@ static int branch_merged(int kind, cons
                if (upstream &&
                    (reference_name = reference_name_to_free =
                     resolve_refdup(upstream, RESOLVE_REF_READING,
-                                   oid.hash, NULL)) != NULL)
+                                   &oid, NULL)) != NULL)
                        reference_rev = lookup_commit_reference(&oid);
        }
        if (!reference_rev)
@@@ -241,7 -241,7 +241,7 @@@ static int delete_branches(int argc, co
                                        RESOLVE_REF_READING
                                        | RESOLVE_REF_NO_RECURSE
                                        | RESOLVE_REF_ALLOW_BAD_NAME,
-                                       oid.hash, &flags);
+                                       &oid, &flags);
                if (!target) {
                        error(remote_branch
                              ? _("remote-tracking branch '%s' not found.")
                        goto next;
                }
  
-               if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : oid.hash,
+               if (delete_ref(NULL, name, is_null_oid(&oid) ? NULL : &oid,
                               REF_NODEREF)) {
                        error(remote_branch
                              ? _("Error deleting remote-tracking branch '%s'")
@@@ -636,7 -636,7 +636,7 @@@ int cmd_branch(int argc, const char **a
  
        track = git_branch_track;
  
-       head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
+       head = resolve_refdup("HEAD", 0, &head_oid, NULL);
        if (!head)
                die(_("Failed to resolve HEAD as a valid ref."));
        if (!strcmp(head, "HEAD"))
diff --combined builtin/show-branch.c
index 6fa1f62a88ac2704abc6f274ed7a6170bd3a2f4c,8bf42e529db4ee888b749a476384f939573002b1..2e24b5c330e8eb17a8755e9b47fa3c66810981d3
@@@ -554,7 -554,7 +554,7 @@@ static int git_show_branch_config(cons
                return 0;
        }
  
 -      return git_default_config(var, value, cb);
 +      return git_color_default_config(var, value, cb);
  }
  
  static int omit_in_dense(struct commit *commit, struct commit **rev, int n)
@@@ -705,8 -705,8 +705,8 @@@ int cmd_show_branch(int ac, const char 
                        static const char *fake_av[2];
  
                        fake_av[0] = resolve_refdup("HEAD",
-                                                   RESOLVE_REF_READING,
-                                                   oid.hash, NULL);
+                                                   RESOLVE_REF_READING, &oid,
+                                                   NULL);
                        fake_av[1] = NULL;
                        av = fake_av;
                        ac = 1;
                        die(Q_("only %d entry can be shown at one time.",
                               "only %d entries can be shown at one time.",
                               MAX_REVS), MAX_REVS);
-               if (!dwim_ref(*av, strlen(*av), oid.hash, &ref))
+               if (!dwim_ref(*av, strlen(*av), &oid, &ref))
                        die(_("no such ref %s"), *av);
  
                /* Has the base been specified? */
                                /* Ah, that is a date spec... */
                                timestamp_t at;
                                at = approxidate(reflog_base);
-                               read_ref_at(ref, flags, at, -1, oid.hash, NULL,
+                               read_ref_at(ref, flags, at, -1, &oid, NULL,
                                            NULL, NULL, &base);
                        }
                }
                        timestamp_t timestamp;
                        int tz;
  
-                       if (read_ref_at(ref, flags, 0, base+i, oid.hash, &logmsg,
+                       if (read_ref_at(ref, flags, 0, base + i, &oid, &logmsg,
                                        &timestamp, &tz, NULL)) {
                                reflog = i;
                                break;
        }
  
        head = resolve_refdup("HEAD", RESOLVE_REF_READING,
-                             head_oid.hash, NULL);
+                             &head_oid, NULL);
  
        if (with_current_branch && head) {
                int has_head = 0;
diff --combined builtin/tag.c
index b38329b593b595edad3efde82aaf1ecb90a73141,8c458b96137c62f55dcf1b6bebe71cd35221deaf..a7e6a5b0f234a95fb45a71d7e9aa7f0baa2b47f8
@@@ -82,7 -82,7 +82,7 @@@ static int for_each_tag_name(const cha
        for (p = argv; *p; p++) {
                strbuf_reset(&ref);
                strbuf_addf(&ref, "refs/tags/%s", *p);
-               if (read_ref(ref.buf, oid.hash)) {
+               if (read_ref(ref.buf, &oid)) {
                        error(_("tag '%s' not found."), *p);
                        had_error = 1;
                        continue;
@@@ -97,7 -97,7 +97,7 @@@
  static int delete_tag(const char *name, const char *ref,
                      const struct object_id *oid, const void *cb_data)
  {
-       if (delete_ref(NULL, ref, oid->hash, 0))
+       if (delete_ref(NULL, ref, oid, 0))
                return 1;
        printf(_("Deleted tag '%s' (was %s)\n"), name, find_unique_abbrev(oid->hash, DEFAULT_ABBREV));
        return 0;
@@@ -158,7 -158,7 +158,7 @@@ static int git_tag_config(const char *v
  
        if (starts_with(var, "column."))
                return git_column_config(var, value, "tag", &colopts);
 -      return git_default_config(var, value, cb);
 +      return git_color_default_config(var, value, cb);
  }
  
  static void write_tag_body(int fd, const struct object_id *oid)
@@@ -518,7 -518,7 +518,7 @@@ int cmd_tag(int argc, const char **argv
        if (strbuf_check_tag_ref(&ref, tag))
                die(_("'%s' is not a valid tag name."), tag);
  
-       if (read_ref(ref.buf, prev.hash))
+       if (read_ref(ref.buf, &prev))
                oidclr(&prev);
        else if (!force)
                die(_("tag '%s' already exists"), tag);
  
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
-           ref_transaction_update(transaction, ref.buf, object.hash, prev.hash,
+           ref_transaction_update(transaction, ref.buf, &object, &prev,
                                   create_reflog ? REF_FORCE_CREATE_REFLOG : 0,
                                   reflog_msg.buf, &err) ||
            ref_transaction_commit(transaction, &err))
diff --combined refs/files-backend.c
index 8cc1e07fdb7204d13c99826304317c66d4249cf5,b7b9e767de8262f3c44873e454f9aebf5610e0cc..2bd54e11aedf0e081072dbb58d327b969d0948bc
@@@ -189,7 -189,7 +189,7 @@@ static void loose_fill_ref_dir(struct r
                        if (!refs_resolve_ref_unsafe(&refs->base,
                                                     refname.buf,
                                                     RESOLVE_REF_READING,
-                                                    oid.hash, &flag)) {
+                                                    &oid, &flag)) {
                                oidclr(&oid);
                                flag |= REF_ISBROKEN;
                        } else if (is_null_oid(&oid)) {
@@@ -261,7 -261,7 +261,7 @@@ static struct ref_cache *get_loose_ref_
  }
  
  static int files_read_raw_ref(struct ref_store *ref_store,
-                             const char *refname, unsigned char *sha1,
+                             const char *refname, struct object_id *oid,
                              struct strbuf *referent, unsigned int *type)
  {
        struct files_ref_store *refs =
        struct strbuf sb_path = STRBUF_INIT;
        const char *path;
        const char *buf;
+       const char *p;
        struct stat st;
        int fd;
        int ret = -1;
@@@ -304,7 -305,7 +305,7 @@@ stat_ref
                if (errno != ENOENT)
                        goto out;
                if (refs_read_raw_ref(refs->packed_ref_store, refname,
-                                     sha1, referent, type)) {
+                                     oid, referent, type)) {
                        errno = ENOENT;
                        goto out;
                }
                 * packed ref:
                 */
                if (refs_read_raw_ref(refs->packed_ref_store, refname,
-                                     sha1, referent, type)) {
+                                     oid, referent, type)) {
                        errno = EISDIR;
                        goto out;
                }
         * Please note that FETCH_HEAD has additional
         * data after the sha.
         */
-       if (get_sha1_hex(buf, sha1) ||
-           (buf[40] != '\0' && !isspace(buf[40]))) {
+       if (parse_oid_hex(buf, oid, &p) ||
+           (*p != '\0' && !isspace(*p))) {
                *type |= REF_ISBROKEN;
                errno = EINVAL;
                goto out;
@@@ -545,7 -546,7 +546,7 @@@ retry
         */
  
        if (files_read_raw_ref(&refs->base, refname,
-                              lock->old_oid.hash, referent, type)) {
+                              &lock->old_oid, referent, type)) {
                if (errno == ENOENT) {
                        if (mustexist) {
                                /* Garden variety missing reference. */
@@@ -769,21 -770,21 +770,21 @@@ static struct ref_iterator *files_ref_i
  }
  
  /*
-  * Verify that the reference locked by lock has the value old_sha1.
-  * Fail if the reference doesn't exist and mustexist is set. Return 0
-  * on success. On error, write an error message to err, set errno, and
-  * return a negative value.
+  * Verify that the reference locked by lock has the value old_oid
+  * (unless it is NULL).  Fail if the reference doesn't exist and
+  * mustexist is set. Return 0 on success. On error, write an error
+  * message to err, set errno, and return a negative value.
   */
  static int verify_lock(struct ref_store *ref_store, struct ref_lock *lock,
-                      const unsigned char *old_sha1, int mustexist,
+                      const struct object_id *old_oid, int mustexist,
                       struct strbuf *err)
  {
        assert(err);
  
        if (refs_read_ref_full(ref_store, lock->ref_name,
                               mustexist ? RESOLVE_REF_READING : 0,
-                              lock->old_oid.hash, NULL)) {
-               if (old_sha1) {
+                              &lock->old_oid, NULL)) {
+               if (old_oid) {
                        int save_errno = errno;
                        strbuf_addf(err, "can't verify ref '%s'", lock->ref_name);
                        errno = save_errno;
                        return 0;
                }
        }
-       if (old_sha1 && hashcmp(lock->old_oid.hash, old_sha1)) {
+       if (old_oid && oidcmp(&lock->old_oid, old_oid)) {
                strbuf_addf(err, "ref '%s' is at %s but expected %s",
                            lock->ref_name,
                            oid_to_hex(&lock->old_oid),
-                           sha1_to_hex(old_sha1));
+                           oid_to_hex(old_oid));
                errno = EBUSY;
                return -1;
        }
@@@ -827,22 -828,22 +828,22 @@@ static int create_reflock(const char *p
   * Locks a ref returning the lock on success and NULL on failure.
   * On failure errno is set to something meaningful.
   */
- static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
-                                           const char *refname,
-                                           const unsigned char *old_sha1,
-                                           const struct string_list *extras,
-                                           const struct string_list *skip,
-                                           unsigned int flags, int *type,
-                                           struct strbuf *err)
+ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,
+                                          const char *refname,
+                                          const struct object_id *old_oid,
+                                          const struct string_list *extras,
+                                          const struct string_list *skip,
+                                          unsigned int flags, int *type,
+                                          struct strbuf *err)
  {
        struct strbuf ref_file = STRBUF_INIT;
        struct ref_lock *lock;
        int last_errno = 0;
-       int mustexist = (old_sha1 && !is_null_sha1(old_sha1));
+       int mustexist = (old_oid && !is_null_oid(old_oid));
        int resolve_flags = RESOLVE_REF_NO_RECURSE;
        int resolved;
  
-       files_assert_main_repository(refs, "lock_ref_sha1_basic");
+       files_assert_main_repository(refs, "lock_ref_oid_basic");
        assert(err);
  
        lock = xcalloc(1, sizeof(struct ref_lock));
        files_ref_path(refs, &ref_file, refname);
        resolved = !!refs_resolve_ref_unsafe(&refs->base,
                                             refname, resolve_flags,
-                                            lock->old_oid.hash, type);
+                                            &lock->old_oid, type);
        if (!resolved && errno == EISDIR) {
                /*
                 * we are trying to lock foo but we used to
                }
                resolved = !!refs_resolve_ref_unsafe(&refs->base,
                                                     refname, resolve_flags,
-                                                    lock->old_oid.hash, type);
+                                                    &lock->old_oid, type);
        }
        if (!resolved) {
                last_errno = errno;
                goto error_return;
        }
  
-       if (verify_lock(&refs->base, lock, old_sha1, mustexist, err)) {
+       if (verify_lock(&refs->base, lock, old_oid, mustexist, err)) {
                last_errno = errno;
                goto error_return;
        }
  
  struct ref_to_prune {
        struct ref_to_prune *next;
-       unsigned char sha1[20];
+       struct object_id oid;
        char name[FLEX_ARRAY];
  };
  
@@@ -994,7 -995,7 +995,7 @@@ static void prune_ref(struct files_ref_
  
        transaction = ref_store_transaction_begin(&refs->base, &err);
        if (!transaction ||
-           ref_transaction_delete(transaction, r->name, r->sha1,
+           ref_transaction_delete(transaction, r->name, &r->oid,
                                   REF_ISPRUNING | REF_NODEREF, NULL, &err) ||
            ref_transaction_commit(transaction, &err)) {
                ref_transaction_free(transaction);
@@@ -1079,7 -1080,7 +1080,7 @@@ static int files_pack_refs(struct ref_s
                 * packed-refs transaction:
                 */
                if (ref_transaction_update(transaction, iter->refname,
-                                          iter->oid->hash, NULL,
+                                          iter->oid, NULL,
                                           REF_NODEREF, NULL, &err))
                        die("failure preparing to create packed reference %s: %s",
                            iter->refname, err.buf);
                if ((flags & PACK_REFS_PRUNE)) {
                        struct ref_to_prune *n;
                        FLEX_ALLOC_STR(n, name, iter->refname);
-                       hashcpy(n->sha1, iter->oid->hash);
+                       oidcpy(&n->oid, iter->oid);
                        n->next = refs_to_prune;
                        refs_to_prune = n;
                }
@@@ -1251,7 -1252,7 +1252,7 @@@ static int files_copy_or_rename_ref(str
  
        if (!refs_resolve_ref_unsafe(&refs->base, oldrefname,
                                     RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
-                               orig_oid.hash, &flag)) {
+                               &orig_oid, &flag)) {
                ret = error("refname %s not found", oldrefname);
                goto out;
        }
        }
  
        if (!copy && refs_delete_ref(&refs->base, logmsg, oldrefname,
-                           orig_oid.hash, REF_NODEREF)) {
+                           &orig_oid, REF_NODEREF)) {
                error("unable to delete old %s", oldrefname);
                goto rollback;
        }
         */
        if (!copy && !refs_read_ref_full(&refs->base, newrefname,
                                RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
-                               oid.hash, NULL) &&
+                               &oid, NULL) &&
            refs_delete_ref(&refs->base, NULL, newrefname,
                            NULL, REF_NODEREF)) {
                if (errno == EISDIR) {
  
        logmoved = log;
  
-       lock = lock_ref_sha1_basic(refs, newrefname, NULL, NULL, NULL,
-                                  REF_NODEREF, NULL, &err);
+       lock = lock_ref_oid_basic(refs, newrefname, NULL, NULL, NULL,
+                                 REF_NODEREF, NULL, &err);
        if (!lock) {
                if (copy)
                        error("unable to copy '%s' to '%s': %s", oldrefname, newrefname, err.buf);
        goto out;
  
   rollback:
-       lock = lock_ref_sha1_basic(refs, oldrefname, NULL, NULL, NULL,
-                                  REF_NODEREF, NULL, &err);
+       lock = lock_ref_oid_basic(refs, oldrefname, NULL, NULL, NULL,
+                                 REF_NODEREF, NULL, &err);
        if (!lock) {
                error("unable to lock %s for rollback: %s", oldrefname, err.buf);
                strbuf_release(&err);
@@@ -1721,7 -1722,7 +1722,7 @@@ static void update_symref_reflog(struc
        struct object_id new_oid;
        if (logmsg &&
            !refs_read_ref_full(&refs->base, target,
-                               RESOLVE_REF_READING, new_oid.hash, NULL) &&
+                               RESOLVE_REF_READING, &new_oid, NULL) &&
            files_log_ref_write(refs, refname, &lock->old_oid,
                                &new_oid, logmsg, 0, &err)) {
                error("%s", err.buf);
@@@ -1762,9 -1763,9 +1763,9 @@@ static int files_create_symref(struct r
        struct ref_lock *lock;
        int ret;
  
-       lock = lock_ref_sha1_basic(refs, refname, NULL,
-                                  NULL, NULL, REF_NODEREF, NULL,
-                                  &err);
+       lock = lock_ref_oid_basic(refs, refname, NULL,
+                                 NULL, NULL, REF_NODEREF, NULL,
+                                 &err);
        if (!lock) {
                error("%s", err.buf);
                strbuf_release(&err);
@@@ -2010,7 -2011,7 +2011,7 @@@ static int files_reflog_iterator_advanc
  
                if (refs_read_ref_full(iter->ref_store,
                                       diter->relative_path, 0,
-                                      iter->oid.hash, &flags)) {
+                                      &iter->oid, &flags)) {
                        error("bad ref for %s", diter->path.buf);
                        continue;
                }
@@@ -2148,7 -2149,7 +2149,7 @@@ static int split_head_update(struct ref
        new_update = ref_transaction_add_update(
                        transaction, "HEAD",
                        update->flags | REF_LOG_ONLY | REF_NODEREF,
-                       update->new_oid.hash, update->old_oid.hash,
+                       &update->new_oid, &update->old_oid,
                        update->msg);
  
        /*
@@@ -2212,7 -2213,7 +2213,7 @@@ static int split_symref_update(struct f
  
        new_update = ref_transaction_add_update(
                        transaction, referent, new_flags,
-                       update->new_oid.hash, update->old_oid.hash,
+                       &update->new_oid, &update->old_oid,
                        update->msg);
  
        new_update->parent_update = update;
@@@ -2347,7 -2348,7 +2348,7 @@@ static int lock_ref_for_update(struct f
                         */
                        if (refs_read_ref_full(&refs->base,
                                               referent.buf, 0,
-                                              lock->old_oid.hash, NULL)) {
+                                              &lock->old_oid, NULL)) {
                                if (update->flags & REF_HAVE_OLD) {
                                        strbuf_addf(err, "cannot lock ref '%s': "
                                                    "error reading reference",
@@@ -2570,7 -2571,7 +2571,7 @@@ static int files_transaction_prepare(st
                ret = lock_ref_for_update(refs, update, transaction,
                                          head_ref, &affected_refnames, err);
                if (ret)
 -                      break;
 +                      goto cleanup;
  
                if (update->flags & REF_DELETING &&
                    !(update->flags & REF_LOG_ONLY) &&
                        ref_transaction_add_update(
                                        packed_transaction, update->refname,
                                        update->flags & ~REF_HAVE_OLD,
-                                       update->new_oid.hash, update->old_oid.hash,
+                                       &update->new_oid, &update->old_oid,
                                        NULL);
                }
        }
@@@ -2847,7 -2848,7 +2848,7 @@@ static int files_initial_transaction_co
                 */
                ref_transaction_add_update(packed_transaction, update->refname,
                                           update->flags & ~REF_HAVE_OLD,
-                                          update->new_oid.hash, update->old_oid.hash,
+                                          &update->new_oid, &update->old_oid,
                                           NULL);
        }
  
@@@ -2908,7 -2909,7 +2909,7 @@@ static int expire_reflog_ent(struct obj
  }
  
  static int files_reflog_expire(struct ref_store *ref_store,
-                              const char *refname, const unsigned char *sha1,
+                              const char *refname, const struct object_id *oid,
                               unsigned int flags,
                               reflog_expiry_prepare_fn prepare_fn,
                               reflog_expiry_should_prune_fn should_prune_fn,
        int status = 0;
        int type;
        struct strbuf err = STRBUF_INIT;
-       struct object_id oid;
  
        memset(&cb, 0, sizeof(cb));
        cb.flags = flags;
         * reference itself, plus we might need to update the
         * reference if --updateref was specified:
         */
-       lock = lock_ref_sha1_basic(refs, refname, sha1,
-                                  NULL, NULL, REF_NODEREF,
-                                  &type, &err);
+       lock = lock_ref_oid_basic(refs, refname, oid,
+                                 NULL, NULL, REF_NODEREF,
+                                 &type, &err);
        if (!lock) {
                error("cannot lock ref '%s': %s", refname, err.buf);
                strbuf_release(&err);
                }
        }
  
-       hashcpy(oid.hash, sha1);
-       (*prepare_fn)(refname, &oid, cb.policy_cb);
+       (*prepare_fn)(refname, oid, cb.policy_cb);
        refs_for_each_reflog_ent(ref_store, refname, expire_reflog_ent, &cb);
        (*cleanup_fn)(cb.policy_cb);
  
diff --combined sequencer.c
index f2a10cc4f24c10adf072eb26ba427f00037b3c79,0d20ac760a3e2b0a16794ee33f496ff179d1bf5a..64abaad0e81027cf2a37545ea77f0f4aa0189be9
@@@ -393,7 -393,7 +393,7 @@@ static int fast_forward_to(const struc
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
            ref_transaction_update(transaction, "HEAD",
-                                  to->hash, unborn ? null_sha1 : from->hash,
+                                  to, unborn ? &null_oid : from,
                                   0, sb.buf, &err) ||
            ref_transaction_commit(transaction, &err)) {
                ref_transaction_free(transaction);
@@@ -489,7 -489,7 +489,7 @@@ static int is_index_unchanged(void
        struct object_id head_oid;
        struct commit *head_commit;
  
-       if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
+       if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL))
                return error(_("could not resolve HEAD commit\n"));
  
        head_commit = lookup_commit(&head_oid);
@@@ -1115,11 -1115,11 +1115,11 @@@ static int do_pick_commit(enum todo_com
         * write it at all.
         */
        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))
                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))
                res = -1;
  
@@@ -1630,7 -1630,7 +1630,7 @@@ static int rollback_single_pick(void
        if (!file_exists(git_path_cherry_pick_head()) &&
            !file_exists(git_path_revert_head()))
                return error(_("no cherry-pick or revert in progress"));
-       if (read_ref_full("HEAD", 0, head_oid.hash, NULL))
+       if (read_ref_full("HEAD", 0, &head_oid, NULL))
                return error(_("cannot resolve HEAD"));
        if (is_null_oid(&head_oid))
                return error(_("cannot abort from a branch yet to be born"));
@@@ -2124,8 -2124,8 +2124,8 @@@ cleanup_head_ref
                        }
                        msg = reflog_message(opts, "finish", "%s onto %s",
                                head_ref.buf, buf.buf);
-                       if (update_ref(msg, head_ref.buf, head.hash, orig.hash,
-                                       REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) {
+                       if (update_ref(msg, head_ref.buf, &head, &orig,
+                                      REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) {
                                res = error(_("could not update %s"),
                                        head_ref.buf);
                                goto cleanup_head_ref;
@@@ -2948,9 -2948,9 +2948,9 @@@ int rearrange_squash(void
                if (fd < 0)
                        res = error_errno(_("could not open '%s'"), todo_file);
                else if (write(fd, buf.buf, buf.len) < 0)
 -                      res = error_errno(_("could not read '%s'."), todo_file);
 +                      res = error_errno(_("could not write to '%s'"), todo_file);
                else if (ftruncate(fd, buf.len) < 0)
 -                      res = error_errno(_("could not finish '%s'"),
 +                      res = error_errno(_("could not truncate '%s'"),
                                           todo_file);
                close(fd);
                strbuf_release(&buf);