]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/checkout.c
cache: convert struct cache_entry to use struct object_id
[thirdparty/git.git] / builtin / checkout.c
index 48661115226b32ed6e98477ee49eea1278685def..a9523ffa2463c7d0d02961ec650ce83103921def 100644 (file)
@@ -76,7 +76,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
 
        len = base->len + strlen(pathname);
        ce = xcalloc(1, cache_entry_size(len));
-       hashcpy(ce->sha1, sha1);
+       hashcpy(ce->oid.hash, sha1);
        memcpy(ce->name, base->buf, base->len);
        memcpy(ce->name + base->len, pathname, len - base->len);
        ce->ce_flags = create_ce_flags(0) | CE_UPDATE;
@@ -92,7 +92,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
        if (pos >= 0) {
                struct cache_entry *old = active_cache[pos];
                if (ce->ce_mode == old->ce_mode &&
-                   !hashcmp(ce->sha1, old->sha1)) {
+                   !oidcmp(&ce->oid, &old->oid)) {
                        old->ce_flags |= CE_UPDATE;
                        free(ce);
                        return 0;
@@ -186,7 +186,7 @@ static int checkout_merged(int pos, struct checkout *state)
                stage = ce_stage(ce);
                if (!stage || strcmp(path, ce->name))
                        break;
-               hashcpy(threeway[stage - 1], ce->sha1);
+               hashcpy(threeway[stage - 1], ce->oid.hash);
                if (stage == 2)
                        mode = create_ce_mode(ce->ce_mode);
                pos++;
@@ -658,7 +658,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
                update_ref(msg.buf, "HEAD", new->commit->object.oid.hash, NULL,
                           REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
                if (!opts->quiet) {
-                       if (old->path && advice_detached_head)
+                       if (old->path &&
+                           advice_detached_head && !opts->force_detach)
                                detach_advice(new->name);
                        describe_detached_head(_("HEAD is now at"), new->commit);
                }