git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] checkout: refer to other-worktree branch, not ref

From
Kristoffer Haugsbakk <code@khaugsbakk.name>
Date
Oct 9, 2024, 17:27 UTC
Message-ID
<259fcbb61f13873421d50df77f151130fdbf0166.1728494795.git.code@khaugsbakk.name>
From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>

We can only check out commits or branches, not refs in general. And the problem here is if another worktree is using the branch that we want to check out.

Let’s be more direct and just talk about branches instead of refs.
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
Notes (series):
    I also change “is holding” to “is using”.  This has plenty of
    precedence:
    
    1. The code ultimately calls
      `builtin/checkout.c:die_if_switching_to_a_branch_in_use` which says
      that we die if the branch is “in use” by another worktree, just like
      we do here for the new description string on
      `--ignore-other-worktrees` (c.f. “holding the given ref”).
    2. `man git checkout` uses the phrase “in use by” when talking about the
       branch being checked out in another worktree.
 Documentation/git-checkout.txt | 6 +++---
 builtin/checkout.c             | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 8bdfa54ab09..b00b375dd27 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -290,9 +290,9 @@ Note that this option uses the no overlay mode by default (see also
 `--overlay`), and currently doesn't support overlay mode.
 
 --ignore-other-worktrees::
-	`git checkout` refuses when the wanted ref is already checked
-	out by another worktree. This option makes it check the ref
-	out anyway. In other words, the ref can be held by more than one
+	`git checkout` refuses when the wanted branch is already checked
+	out by another worktree. This option makes it check the branch
+	out anyway. In other words, the branch can be held by more than one
 	worktree.
 
 --overwrite-ignore::
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 9c30000d3af..c449558e663 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1716,7 +1716,7 @@ static struct option *add_common_switch_branch_options(
 			   N_("update ignored files (default)"),
 			   PARSE_OPT_NOCOMPLETE),
 		OPT_BOOL(0, "ignore-other-worktrees", &opts->ignore_other_worktrees,
-			 N_("do not check if another worktree is holding the given ref")),
+			 N_("do not check if another worktree is using this branch")),
 		OPT_END()
 	};
 	struct option *newopts = parse_options_concat(prevopts, options);
-- 
2.46.1.641.g54e7913fcb6
Next: Kristoffer Haugsbakk
Message 1 of 5 in “checkout: refer to other-worktree branch, not ref”
  1. checkout: refer to other-worktree branch, not refKristoffer Haugsbakk, Oct 9, 2024
  2. Kristoffer HaugsbakkOct 9, 2024
  3. Junio C HamanoOct 9, 2024
  4. Kristoffer HaugsbakkOct 10, 2024
  5. checkout: refer to other-worktree branch, not refkristofferhaugsbakk@fastmail.com, Oct 10, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.