git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkout: refer to other-worktree branch, not ref
@ 2024-10-09 17:27 Kristoffer Haugsbakk
  2024-10-09 17:36 ` Kristoffer Haugsbakk
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-09 17:27 UTC (permalink / raw)
  To: git; +Cc: Kristoffer Haugsbakk, Kristoffer Haugsbakk

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] checkout: refer to other-worktree branch, not ref
  2024-10-09 17:27 [PATCH] checkout: refer to other-worktree branch, not ref Kristoffer Haugsbakk
@ 2024-10-09 17:36 ` Kristoffer Haugsbakk
  2024-10-09 18:46 ` Junio C Hamano
  2024-10-10 18:39 ` [PATCH v2] " kristofferhaugsbakk
  2 siblings, 0 replies; 5+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-09 17:36 UTC (permalink / raw)
  To: git; +Cc: Kristoffer Haugsbakk

On Wed, Oct 9, 2024, at 19:27, Kristoffer Haugsbakk wrote:
> From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
>
> From: Kristoffer Haugsbakk <code@khaugsbakk.name>

I did the format-patch + send-email mistake again.

https://lore.kernel.org/git/b41ce281-d3b8-43c3-8b27-f5dc59601ca7@app.fastmail.com/

-- 
Kristoffer



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] checkout: refer to other-worktree branch, not ref
  2024-10-09 17:27 [PATCH] checkout: refer to other-worktree branch, not ref Kristoffer Haugsbakk
  2024-10-09 17:36 ` Kristoffer Haugsbakk
@ 2024-10-09 18:46 ` Junio C Hamano
  2024-10-10 18:23   ` Kristoffer Haugsbakk
  2024-10-10 18:39 ` [PATCH v2] " kristofferhaugsbakk
  2 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2024-10-09 18:46 UTC (permalink / raw)
  To: Kristoffer Haugsbakk; +Cc: git, Kristoffer Haugsbakk

Kristoffer Haugsbakk <code@khaugsbakk.name> writes:

> 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.

Good to see an update is done with such an attention to detail.

A branch "in use" includes, but is not limited to, being checked
out.  For example, "git rebase" may first detach the HEAD when it
goes to work, but it fully intends to switch back to the branch it
rebased when it is done.  It does not want somebody else mucking
with the branch from other worktrees, so "checkout" or "switch"
would consider such a branch is "in use".

>  --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.

As you are updating the usage string, we may want to unify the use
of the same word, just like the original said "be held" here to
match "is holding" over there.  Perhaps

	... branch is already checked out or otherwise in use by
	another worktree. ... the branch can be in use by more than
	one worktree.

or something?

>  --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")),

Good.

>  		OPT_END()
>  	};
>  	struct option *newopts = parse_options_concat(prevopts, options);

Thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] checkout: refer to other-worktree branch, not ref
  2024-10-09 18:46 ` Junio C Hamano
@ 2024-10-10 18:23   ` Kristoffer Haugsbakk
  0 siblings, 0 replies; 5+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-10 18:23 UTC (permalink / raw)
  To: Junio C Hamano, Kristoffer Haugsbakk; +Cc: git

On Wed, Oct 9, 2024, at 20:46, Junio C Hamano wrote:
> A branch "in use" includes, but is not limited to, being checked
> out.  For example, "git rebase" may first detach the HEAD when it
> goes to work, but it fully intends to switch back to the branch it
> rebased when it is done.  It does not want somebody else mucking
> with the branch from other worktrees, so "checkout" or "switch"
> would consider such a branch is "in use".

I did not know that checkout and friends respect branches which are
preocuppied with (e.g.) a rebase.  But I’m glad to learn that they
do. :)

>
>>  --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.
>
> As you are updating the usage string, we may want to unify the use
> of the same word, just like the original said "be held" here to
> match "is holding" over there.  Perhaps
>
> 	... branch is already checked out or otherwise in use by
> 	another worktree. ... the branch can be in use by more than
> 	one worktree.
>
> or something?

Nice. I like it.

-- 
Kristoffer Haugsbakk


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] checkout: refer to other-worktree branch, not ref
  2024-10-09 17:27 [PATCH] checkout: refer to other-worktree branch, not ref Kristoffer Haugsbakk
  2024-10-09 17:36 ` Kristoffer Haugsbakk
  2024-10-09 18:46 ` Junio C Hamano
@ 2024-10-10 18:39 ` kristofferhaugsbakk
  2 siblings, 0 replies; 5+ messages in thread
From: kristofferhaugsbakk @ 2024-10-10 18:39 UTC (permalink / raw)
  To: git; +Cc: Kristoffer Haugsbakk, gitster

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.

Also replace “be held” with “in use”.  Further, “in use” is not
restricted to a branch being checked out (e.g. the branch could be busy
on a rebase), hence generalize to “or otherwise in use” in the option
description.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---

Notes (series):
    v2:
    • Commit to replacing “be held” with “in use”
      • Also mention “in use” in the commit message
    • Add “or otherwise in use”
    • Flow/format `--ignore-other-worktrees` paragraph since a line was
      getting long
    
    ❦
    
    (from v1)
    
    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 | 8 ++++----
 builtin/checkout.c             | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 8bdfa54ab09..bf26655764f 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -290,10 +290,10 @@ 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
-	worktree.
+	`git checkout` refuses when the wanted branch is already checked
+	out or otherwise in use by another worktree. This option makes
+	it check the branch out anyway. In other words, the branch can
+	be in use by more than one worktree.
 
 --overwrite-ignore::
 --no-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);

Interdiff against v1:
  diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
  index b00b375dd27..bf26655764f 100644
  --- a/Documentation/git-checkout.txt
  +++ b/Documentation/git-checkout.txt
  @@ -291,9 +291,9 @@ Note that this option uses the no overlay mode by default (see also
   
   --ignore-other-worktrees::
   	`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.
  +	out or otherwise in use by another worktree. This option makes
  +	it check the branch out anyway. In other words, the branch can
  +	be in use by more than one worktree.
   
   --overwrite-ignore::
   --no-overwrite-ignore::
-- 
2.46.1.641.g54e7913fcb6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-10 18:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09 17:27 [PATCH] checkout: refer to other-worktree branch, not ref Kristoffer Haugsbakk
2024-10-09 17:36 ` Kristoffer Haugsbakk
2024-10-09 18:46 ` Junio C Hamano
2024-10-10 18:23   ` Kristoffer Haugsbakk
2024-10-10 18:39 ` [PATCH v2] " kristofferhaugsbakk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).