Re: [PATCH v4] branch: support for shortcuts like @{-1}, completed
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Oct 8, 2022, 03:17 UTC
- Message-ID
- <CAPig+cSX9jSPc_fJc0tuiER1-AqnbFGOk0r1tXEkv9gycVH-CA@mail.gmail.com>
- In-Reply-To
- <2e164aea-7dd8-5018-474a-01643553ea49@gmail.com>
On Fri, Oct 7, 2022 at 9:36 PM Rubén Justo <rjusto@gmail.com> wrote:
Show 20 quoted lines
> 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.
> + test_cmp expect actual