diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2016-04-22 20:01:27 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-22 14:09:37 -0700 |
commit | d3b9ac07eb44974bb619d71fc6c81c9f2036b96c (patch) | |
tree | ff18f60eb58addac7e2a2008d4d9f1aa43ad3b30 /branch.c | |
parent | 69dfe3b9420eb2a7f479a0a4cad663111af2b1f9 (diff) | |
download | git-d3b9ac07eb44974bb619d71fc6c81c9f2036b96c.tar.gz |
worktree.c: make find_shared_symref() return struct worktree *
This gives the caller more information and they can answer things like,
"is it the main worktree" or "is it the current worktree". The latter
question is needed for the "checkout a rebase branch" case later.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'branch.c')
-rw-r--r-- | branch.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -336,13 +336,14 @@ void remove_branch_state(void) void die_if_checked_out(const char *branch) { - char *existing; + const struct worktree *wt; - existing = find_shared_symref("HEAD", branch); - if (existing) { - skip_prefix(branch, "refs/heads/", &branch); - die(_("'%s' is already checked out at '%s'"), branch, existing); - } + wt = find_shared_symref("HEAD", branch); + if (!wt) + return; + skip_prefix(branch, "refs/heads/", &branch); + die(_("'%s' is already checked out at '%s'"), + branch, wt->path); } int replace_each_worktree_head_symref(const char *oldref, const char *newref) |