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

Re: [PATCH] branch: add '-' to delete previous branch

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 30, 2020, 15:59 UTC
Message-ID
<20200430155904.GA30682@syl.local>
In-Reply-To
<20200430145221.z3lpgjstybqztfqb@arch>
Hi Ivan,
On Thu, Apr 30, 2020 at 10:52:21PM +0800, Ivan Tham wrote:
Show 36 quoted lines
> On Wed, Apr 29, 2020 at 12:58:51PM -0600, Taylor Blau wrote:
> > On Wed, Apr 29, 2020 at 09:01:33PM +0800, Ivan Tham wrote:
> > > Add support to delete previous branch from git checkout/switch to have
> > > feature parity with git switch -.
> > >
> > > Signed-off-by: Ivan Tham <pickfire@riseup.net>
> > > ---
> > >  Documentation/git-branch.txt | 10 ++++++++++
> > >  builtin/branch.c             |  6 +++++-
> > >  t/t3200-branch.sh            |  7 +++++++
> > >  3 files changed, 22 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
> > > index 135206ff4a..37e7cbbc52 100644
> > > --- a/Documentation/git-branch.txt
> > > +++ b/Documentation/git-branch.txt
> > > @@ -265,6 +265,10 @@ start-point is either a local or remote-tracking branch.
> > >  	The new branch name must pass all checks defined by
> > >  	linkgit:git-check-ref-format[1].  Some of these checks
> > >  	may restrict the characters allowed in a branch name.
> > > ++
> > > +You can use the `@{-N}` syntax to refer to the N-th last branch checked out
> > > +using "git checkout" operation. You may also specify `-` which is synonymous to
> > > +`@{-1}`.
> >
> > Interesting; we're already using strbuf_branchname, so the first part of
> > this documentation was true even before this commit. Would you consider
> > splitting this into two patches?
> >
> > The first should include the first sentence of this documentation, an
> > additional test in t3200 exercising an explicit 'git branch -D @{-N}'
> > for some 'N', but no changes in builtin/branch.c. The second patch would
> > then make '-' a synonym for '@{-1}'.
>
> Is not this already true? Why do we need to split it? Currently using
> '@{-N}' to delete branch already works.

It is the case that 'git branch -D @{-N}' already works, which was surprising to me. I am suggesting that you make documenting the existent behavior a new first patch.

Of course, that might be the only patch that you end up sending in v2, since it seems that consensus has formed around not supposing '-' as a shorthand for '@{-1}' with 'git branch -D'.

Thanks, Taylor

Previous: Ivan ThamNext: Junio C Hamano
Message 24 of 25 in “branch: add '-' to delete previous branch”
  1. branch: add '-' to delete previous branchIvan Tham, Apr 29, 2020
  2. Sergey OrganovApr 29, 2020
  3. Taylor BlauApr 29, 2020
  4. Eric SunshineApr 29, 2020
  5. Sergey OrganovApr 29, 2020
  6. Taylor BlauApr 29, 2020
  7. Junio C HamanoApr 29, 2020
  8. Taylor BlauApr 29, 2020
  9. Junio C HamanoApr 29, 2020
  10. Junio C HamanoApr 29, 2020
  11. Sergey OrganovApr 29, 2020
  12. Konstantin KhomoutovApr 30, 2020
  13. Junio C HamanoApr 30, 2020
  14. Sergey OrganovMay 1, 2020
  15. Konstantin KhomoutovMay 1, 2020
  16. Sergey OrganovMay 1, 2020
  17. Taylor BlauMay 1, 2020
  18. Ivan ThamApr 30, 2020
  19. Junio C HamanoApr 29, 2020
  20. Randall S. BeckerApr 29, 2020
  21. Sergey OrganovApr 29, 2020
  22. Taylor BlauApr 29, 2020
  23. Ivan ThamApr 30, 2020
  24. Taylor BlauApr 30, 2020
  25. Junio C HamanoApr 30, 2020

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.