Re: [PATCH v4] branch: support for shortcuts like @{-1}, completed
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 8, 2022, 04:23 UTC
- Message-ID
- <xmqqzge7aqq2.fsf@gitster.g>
- In-Reply-To
- <CAPig+cSX9jSPc_fJc0tuiER1-AqnbFGOk0r1tXEkv9gycVH-CA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 25 quoted lines
> On Fri, Oct 7, 2022 at 9:36 PM Rubén Justo <rjusto@gmail.com> wrote:
>> branch command with options "edit-description", "set-upstream-to" and
>> "unset-upstream" expects a branch name. Since ae5a6c3684 (checkout:
>> implement "@{-N}" shortcut name for N-th last branch, 2009-01-17) a
>> branch can be specified using shortcuts like @{-1}. Those shortcuts
>> need to be resolved when considering the arguments.
>> [...]
>> Signed-off-by: Rubén Justo <rjusto@gmail.com>
>> ---
>> diff --git a/t/t3204-branch-name-interpretation.sh b/t/t3204-branch-name-interpretation.sh
>> @@ -133,4 +133,28 @@ test_expect_success 'checkout does not treat remote @{upstream} as a branch' '
>> +test_expect_success 'edit-description via @{-1}' '
>> + git checkout -b desc-branch &&
>> + git checkout -b non-desc-branch &&
>> + write_script editor <<-\EOF &&
>> + echo "Branch description" >"$1"
>> + EOF
>> + EDITOR=./editor git branch --edit-description @{-1} &&
>> + test_must_fail git config branch.non-desc-branch.description &&
>> + git config branch.desc-branch.description >actual &&
>> + echo "Branch description\n" >expect &&
>
> Is the intention here with the embedded "\n" that `echo` should emit
> two newlines? If so, interpreting "\n" specially is not POSIX behavior
> for `echo`, thus we probably don't want to rely upon it.Good eyes. You are correct that "echo" and "\n" do not play well together.
Thanks.