diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/cat-file.c | 5 | ||||
-rw-r--r-- | builtin/checkout.c | 13 |
2 files changed, 17 insertions, 1 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 545fed4..6ecc8ee 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -42,7 +42,10 @@ static int filter_object(const char *path, unsigned mode, oid_to_hex(oid), path); if ((type == OBJ_BLOB) && S_ISREG(mode)) { struct strbuf strbuf = STRBUF_INIT; - if (convert_to_working_tree(&the_index, path, *buf, *size, &strbuf, NULL)) { + struct checkout_metadata meta; + + init_checkout_metadata(&meta, NULL, NULL, oid); + if (convert_to_working_tree(&the_index, path, *buf, *size, &strbuf, &meta)) { free(*buf); *size = strbuf.len; *buf = strbuf_detach(&strbuf, NULL); diff --git a/builtin/checkout.c b/builtin/checkout.c index 8a28f48..1bdb70d 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -92,6 +92,8 @@ struct branch_info { const char *name; /* The short name used */ const char *path; /* The full name of a real branch */ struct commit *commit; /* The named commit */ + char *refname; /* The full name of the ref being checked out. */ + struct object_id oid; /* The object ID of the commit being checked out. */ /* * if not null the branch is detached because it's already * checked out in this checkout @@ -360,6 +362,10 @@ static int checkout_worktree(const struct checkout_opts *opts, state.refresh_cache = 1; state.istate = &the_index; + init_checkout_metadata(&state.meta, info->refname, + info->commit ? &info->commit->object.oid : &info->oid, + NULL); + enable_delayed_checkout(&state); for (pos = 0; pos < active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; @@ -636,6 +642,13 @@ static void setup_branch_path(struct branch_info *branch) { struct strbuf buf = STRBUF_INIT; + /* + * If this is a ref, resolve it; otherwise, look up the OID for our + * expression. Failure here is okay. + */ + if (!dwim_ref(branch->name, strlen(branch->name), &branch->oid, &branch->refname)) + repo_get_oid_committish(the_repository, branch->name, &branch->oid); + strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL); if (strcmp(buf.buf, branch->name)) branch->name = xstrdup(buf.buf); |