Re: [PATCH] branch -l: print useful info whilst rebasing a non-local branch
- From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
- Date
- Mar 25, 2018, 03:41 UTC
- Message-ID
- <87ea8cac-c745-b7e6-7804-5116cd94ed48@gmail.com>
- In-Reply-To
- <CAPig+cQ8xw23SGhpx5qtDEyzJGR1v4L2Lm9tEWe56Rh3c8Q3cg@mail.gmail.com>
On Sunday 25 March 2018 07:04 AM, Eric Sunshine wrote:
Show 7 quoted lines
> On Sat, Mar 24, 2018 at 2:38 PM, Kaartic Sivaraam > <kaartic.sivaraam@gmail.com> wrote: >> When rebasing interacitvely (rebase -i), "git branch -l" prints a line > > The "git branch -l" threw me since "-l" is short for --create-reflog. > I'm guessing you meant "git branch --list". >
That's surprising, I just tried "git branch -l" on a repository and I did get a list of branch names. Is this a consequence of some option parsing weirdness ?!
To be honest, I actually assumed "-l" to be a shorthand for "--list" and didn't check with it in the documentation; which I should have. Sorry, for that. I still wonder why "git branch -l" prints a list of branch names when it is not a shorthand for "--list" ? (BTW, I'm also surprised by the fact that "-l" is not act shorthand for "--list"!)
Regardless, I'll update the commit message to use "--list" in place of "-l".
Show 10 quoted lines
>> indicating the current branch being rebased. This works well when the >> interactive rebase was intiated when a local branch is checked out. >> >> This doesn't play well when the rebase was initiated on a remote >> branch or an arbitrary commit that is not pointed to by a local >> branch. > > A shorter way of saying "arbitrary commit ... not pointed at by local > branch" would be "detached HEAD". >
Thanks. I was actually searching for this word. It didn't strike when I wrote the commit message, yesterday.
Show 7 quoted lines
> You could collapse the whole thing back down to:
>
> strbuf_addf(&desc, _("(no branch, rebasing %s)"),
> state.branch ? state.branch : state.detached_from);
>
> which means you don't need the 'rebasing' variable or the braces.
> Nice point.
> Can we have a couple new tests: one checking "git branch --list" for > the typical case (when rebasing off a named branch) and one checking > when rebasing from a detached HEAD? >
Sure, but I guess it would take some time for me to add the tests. I'll send a v2 with the suggested changes.
-- Kaartic