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