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

Re: [PATCH] branch: do not fail a no-op --edit-desc

From
Rubén Justo <rjusto@gmail.com>
Date
Sep 29, 2022, 21:49 UTC
Message-ID
<ba8a503b-76e2-5de9-1082-3b4c6ecd0cc3@gmail.com>
In-Reply-To
<xmqqczbftina.fsf@gitster.g>
Let me try again, I think my review was not good :-)
On 28/9/22 21:15, Junio C Hamano wrote:
> In a repository on a branch without branch description, try running

It is a bit confusing the construction "a repository on a branch without branch description" as "branch" have "repository" inherent. So "On a branch without description.." holds the same meaning with less distracting words.

> The simpler solution of course introduces TOCTOU, but you are

I like that the message introduces an appropriate term that also can be a trigger for some to learn something without distracting others. Instead of just using: "BUG"

> fooling yourself in your own repository.  Not overwriting the branch
> description on the same branch you added in another window, while
> you had this other editor open, may even be a feature ;-)

But.. do we want to implement this this way? Maybe we will have to implement on purpose this feature in some future refactorization?

And.. the message does not make it clear the situation: if there is a previous description, will clear; if not, will keep.

Show 8 quoted lines
>  test_expect_success 'use --edit-description' '
> +	EDITOR=: git branch --edit-description &&
> +	test_must_fail git config branch.main.description &&
> +
>  	write_script editor <<-\EOF &&
>  		echo "New contents" >"$1"
>  	EOF
> 

If we want that feature, should we test for it? (do not take the snippet as tested...):

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index d5a1fc1375..aa5ee14bae 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1393,6 +1393,16 @@ test_expect_success 'use --edit-description' '
        EOF
        EDITOR=./editor git branch --edit-description &&
        echo "New contents" >expect &&
+       write_script editor <<-\EOF &&
+               if [ -z "$NA" ]; then
+                       NA=description GIT_EDITOR=./$0 git branch --edit-description
+               fi
+               echo $NA >$1
+       EOF
+       EDITOR=./editor git branch --edit-description &&
+       test_must_fail git config branch.main.description &&
+       EDITOR=./editor git branch --edit-description &&
+       git config branch.main.description &&
        test_cmp expect EDITOR_OUTPUT
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 13 in “branch: do not fail a no-op --edit-desc”
  1. branch: do not fail a no-op --edit-descJunio C Hamano, Sep 28, 2022
  2. Rubén JustoSep 28, 2022
  3. Junio C HamanoSep 28, 2022
  4. Rubén JustoSep 29, 2022
  5. Junio C HamanoSep 29, 2022
  6. Rubén JustoSep 30, 2022
  7. Rubén JustoOct 1, 2022
  8. branch: do not fail a no-op --edit-descJunio C Hamano, Sep 30, 2022
  9. Ævar Arnfjörð BjarmasonSep 30, 2022
  10. Junio C HamanoSep 30, 2022
  11. Ævar Arnfjörð BjarmasonSep 30, 2022
  12. Junio C HamanoSep 30, 2022
  13. branch: do not fail a no-op --edit-descJunio C Hamano, Sep 30, 2022

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.