{"thread":{"id":"62297","subject":"[PATCH] checkout: refer to other-worktree branch, not ref","startedAt":"2024-10-09T17:28:31Z","lastAt":"2024-10-10T18:39:45Z","messageCount":5,"participants":["Kristoffer Haugsbakk","Junio C Hamano","kristofferhaugsbakk@fastmail.com"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"504610","messageId":"259fcbb61f13873421d50df77f151130fdbf0166.1728494795.git.code@khaugsbakk.name","threadId":"62297","inReplyTo":null,"subject":"[PATCH] checkout: refer to other-worktree branch, not ref","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2024-10-09T17:27:58Z","receivedAt":"2024-10-09T17:28:31Z","isPatch":true,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>\n\nFrom: Kristoffer Haugsbakk <code@khaugsbakk.name>\n\nWe can only check out commits or branches, not refs in general.  And the\nproblem here is if another worktree is using the branch that we want to\ncheck out.\n\nLet’s be more direct and just talk about branches instead of refs.\n\nSigned-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>\n---\n\nNotes (series):\n    I also change “is holding” to “is using”.  This has plenty of\n    precedence:\n    \n    1. The code ultimately calls\n      `builtin/checkout.c:die_if_switching_to_a_branch_in_use` which says\n      that we die if the branch is “in use” by another worktree, just like\n      we do here for the new description string on\n      `--ignore-other-worktrees` (c.f. “holding the given ref”).\n    2. `man git checkout` uses the phrase “in use by” when talking about the\n       branch being checked out in another worktree.\n\n Documentation/git-checkout.txt | 6 +++---\n builtin/checkout.c             | 2 +-\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\nindex 8bdfa54ab09..b00b375dd27 100644\n--- a/Documentation/git-checkout.txt\n+++ b/Documentation/git-checkout.txt\n@@ -290,9 +290,9 @@ Note that this option uses the no overlay mode by default (see also\n `--overlay`), and currently doesn't support overlay mode.\n \n --ignore-other-worktrees::\n-\t`git checkout` refuses when the wanted ref is already checked\n-\tout by another worktree. This option makes it check the ref\n-\tout anyway. In other words, the ref can be held by more than one\n+\t`git checkout` refuses when the wanted branch is already checked\n+\tout by another worktree. This option makes it check the branch\n+\tout anyway. In other words, the branch can be held by more than one\n \tworktree.\n \n --overwrite-ignore::\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 9c30000d3af..c449558e663 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1716,7 +1716,7 @@ static struct option *add_common_switch_branch_options(\n \t\t\t   N_(\"update ignored files (default)\"),\n \t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"ignore-other-worktrees\", &opts->ignore_other_worktrees,\n-\t\t\t N_(\"do not check if another worktree is holding the given ref\")),\n+\t\t\t N_(\"do not check if another worktree is using this branch\")),\n \t\tOPT_END()\n \t};\n \tstruct option *newopts = parse_options_concat(prevopts, options);\n-- \n2.46.1.641.g54e7913fcb6\n\n"},{"id":"504614","messageId":"203447e2-5305-4367-adb9-3cdf16c32f27@app.fastmail.com","threadId":"62297","inReplyTo":"259fcbb61f13873421d50df77f151130fdbf0166.1728494795.git.code@khaugsbakk.name","subject":"Re: [PATCH] checkout: refer to other-worktree branch, not ref","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-10-09T17:36:30Z","receivedAt":"2024-10-09T17:37:08Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Oct 9, 2024, at 19:27, Kristoffer Haugsbakk wrote:\n> From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>\n>\n> From: Kristoffer Haugsbakk <code@khaugsbakk.name>\n\nI did the format-patch + send-email mistake again.\n\nhttps://lore.kernel.org/git/b41ce281-d3b8-43c3-8b27-f5dc59601ca7@app.fastmail.com/\n\n-- \nKristoffer\n\n\n"},{"id":"504627","messageId":"xmqqh69lru6e.fsf@gitster.g","threadId":"62297","inReplyTo":"259fcbb61f13873421d50df77f151130fdbf0166.1728494795.git.code@khaugsbakk.name","subject":"Re: [PATCH] checkout: refer to other-worktree branch, not ref","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-10-09T18:46:17Z","receivedAt":"2024-10-09T18:46:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kristoffer Haugsbakk <code@khaugsbakk.name> writes:\n\n> Notes (series):\n>     I also change “is holding” to “is using”.  This has plenty of\n>     precedence:\n>     \n>     1. The code ultimately calls\n>       `builtin/checkout.c:die_if_switching_to_a_branch_in_use` which says\n>       that we die if the branch is “in use” by another worktree, just like\n>       we do here for the new description string on\n>       `--ignore-other-worktrees` (c.f. “holding the given ref”).\n>     2. `man git checkout` uses the phrase “in use by” when talking about the\n>        branch being checked out in another worktree.\n\nGood to see an update is done with such an attention to detail.\n\nA branch \"in use\" includes, but is not limited to, being checked\nout.  For example, \"git rebase\" may first detach the HEAD when it\ngoes to work, but it fully intends to switch back to the branch it\nrebased when it is done.  It does not want somebody else mucking\nwith the branch from other worktrees, so \"checkout\" or \"switch\"\nwould consider such a branch is \"in use\".\n\n>  --ignore-other-worktrees::\n> -\t`git checkout` refuses when the wanted ref is already checked\n> -\tout by another worktree. This option makes it check the ref\n> -\tout anyway. In other words, the ref can be held by more than one\n> +\t`git checkout` refuses when the wanted branch is already checked\n> +\tout by another worktree. This option makes it check the branch\n> +\tout anyway. In other words, the branch can be held by more than one\n>  \tworktree.\n\nAs you are updating the usage string, we may want to unify the use\nof the same word, just like the original said \"be held\" here to\nmatch \"is holding\" over there.  Perhaps\n\n\t... branch is already checked out or otherwise in use by\n\tanother worktree. ... the branch can be in use by more than\n\tone worktree.\n\nor something?\n\n>  --overwrite-ignore::\n> diff --git a/builtin/checkout.c b/builtin/checkout.c\n> index 9c30000d3af..c449558e663 100644\n> --- a/builtin/checkout.c\n> +++ b/builtin/checkout.c\n> @@ -1716,7 +1716,7 @@ static struct option *add_common_switch_branch_options(\n>  \t\t\t   N_(\"update ignored files (default)\"),\n>  \t\t\t   PARSE_OPT_NOCOMPLETE),\n>  \t\tOPT_BOOL(0, \"ignore-other-worktrees\", &opts->ignore_other_worktrees,\n> -\t\t\t N_(\"do not check if another worktree is holding the given ref\")),\n> +\t\t\t N_(\"do not check if another worktree is using this branch\")),\n\nGood.\n\n>  \t\tOPT_END()\n>  \t};\n>  \tstruct option *newopts = parse_options_concat(prevopts, options);\n\nThanks.\n\n"},{"id":"504727","messageId":"23f2006d-145f-4cea-ab36-859eb2e87489@app.fastmail.com","threadId":"62297","inReplyTo":"xmqqh69lru6e.fsf@gitster.g","subject":"Re: [PATCH] checkout: refer to other-worktree branch, not ref","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-10-10T18:23:40Z","receivedAt":"2024-10-10T18:24:01Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Oct 9, 2024, at 20:46, Junio C Hamano wrote:\n> A branch \"in use\" includes, but is not limited to, being checked\n> out.  For example, \"git rebase\" may first detach the HEAD when it\n> goes to work, but it fully intends to switch back to the branch it\n> rebased when it is done.  It does not want somebody else mucking\n> with the branch from other worktrees, so \"checkout\" or \"switch\"\n> would consider such a branch is \"in use\".\n\nI did not know that checkout and friends respect branches which are\npreocuppied with (e.g.) a rebase.  But I’m glad to learn that they\ndo. :)\n\n>\n>>  --ignore-other-worktrees::\n>> -\t`git checkout` refuses when the wanted ref is already checked\n>> -\tout by another worktree. This option makes it check the ref\n>> -\tout anyway. In other words, the ref can be held by more than one\n>> +\t`git checkout` refuses when the wanted branch is already checked\n>> +\tout by another worktree. This option makes it check the branch\n>> +\tout anyway. In other words, the branch can be held by more than one\n>>  \tworktree.\n>\n> As you are updating the usage string, we may want to unify the use\n> of the same word, just like the original said \"be held\" here to\n> match \"is holding\" over there.  Perhaps\n>\n> \t... branch is already checked out or otherwise in use by\n> \tanother worktree. ... the branch can be in use by more than\n> \tone worktree.\n>\n> or something?\n\nNice. I like it.\n\n-- \nKristoffer Haugsbakk\n\n"},{"id":"504730","messageId":"fcfbcd3868bda75dd0463e04739047e74d239d32.1728585467.git.code@khaugsbakk.name","threadId":"62297","inReplyTo":"259fcbb61f13873421d50df77f151130fdbf0166.1728494795.git.code@khaugsbakk.name","subject":"[PATCH v2] checkout: refer to other-worktree branch, not ref","fromName":"","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-10-10T18:39:29Z","receivedAt":"2024-10-10T18:39:45Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"From: Kristoffer Haugsbakk <code@khaugsbakk.name>\n\nWe can only check out commits or branches, not refs in general.  And the\nproblem here is if another worktree is using the branch that we want to\ncheck out.\n\nLet’s be more direct and just talk about branches instead of refs.\n\nAlso replace “be held” with “in use”.  Further, “in use” is not\nrestricted to a branch being checked out (e.g. the branch could be busy\non a rebase), hence generalize to “or otherwise in use” in the option\ndescription.\n\nSigned-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>\n---\n\nNotes (series):\n    v2:\n    • Commit to replacing “be held” with “in use”\n      • Also mention “in use” in the commit message\n    • Add “or otherwise in use”\n    • Flow/format `--ignore-other-worktrees` paragraph since a line was\n      getting long\n    \n    ❦\n    \n    (from v1)\n    \n    I also change “is holding” to “is using”.  This has plenty of\n    precedence:\n    \n    1. The code ultimately calls\n      `builtin/checkout.c:die_if_switching_to_a_branch_in_use` which says\n      that we die if the branch is “in use” by another worktree, just like\n      we do here for the new description string on\n      `--ignore-other-worktrees` (c.f. “holding the given ref”).\n    2. `man git checkout` uses the phrase “in use by” when talking about the\n       branch being checked out in another worktree.\n\n Documentation/git-checkout.txt | 8 ++++----\n builtin/checkout.c             | 2 +-\n 2 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\nindex 8bdfa54ab09..bf26655764f 100644\n--- a/Documentation/git-checkout.txt\n+++ b/Documentation/git-checkout.txt\n@@ -290,10 +290,10 @@ Note that this option uses the no overlay mode by default (see also\n `--overlay`), and currently doesn't support overlay mode.\n \n --ignore-other-worktrees::\n-\t`git checkout` refuses when the wanted ref is already checked\n-\tout by another worktree. This option makes it check the ref\n-\tout anyway. In other words, the ref can be held by more than one\n-\tworktree.\n+\t`git checkout` refuses when the wanted branch is already checked\n+\tout or otherwise in use by another worktree. This option makes\n+\tit check the branch out anyway. In other words, the branch can\n+\tbe in use by more than one worktree.\n \n --overwrite-ignore::\n --no-overwrite-ignore::\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 9c30000d3af..c449558e663 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -1716,7 +1716,7 @@ static struct option *add_common_switch_branch_options(\n \t\t\t   N_(\"update ignored files (default)\"),\n \t\t\t   PARSE_OPT_NOCOMPLETE),\n \t\tOPT_BOOL(0, \"ignore-other-worktrees\", &opts->ignore_other_worktrees,\n-\t\t\t N_(\"do not check if another worktree is holding the given ref\")),\n+\t\t\t N_(\"do not check if another worktree is using this branch\")),\n \t\tOPT_END()\n \t};\n \tstruct option *newopts = parse_options_concat(prevopts, options);\n\nInterdiff against v1:\n  diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\n  index b00b375dd27..bf26655764f 100644\n  --- a/Documentation/git-checkout.txt\n  +++ b/Documentation/git-checkout.txt\n  @@ -291,9 +291,9 @@ Note that this option uses the no overlay mode by default (see also\n   \n   --ignore-other-worktrees::\n   \t`git checkout` refuses when the wanted branch is already checked\n  -\tout by another worktree. This option makes it check the branch\n  -\tout anyway. In other words, the branch can be held by more than one\n  -\tworktree.\n  +\tout or otherwise in use by another worktree. This option makes\n  +\tit check the branch out anyway. In other words, the branch can\n  +\tbe in use by more than one worktree.\n   \n   --overwrite-ignore::\n   --no-overwrite-ignore::\n-- \n2.46.1.641.g54e7913fcb6\n\n"}]}