# [minor usability suggestion] git rebase <upstream> --onto <newbase> ?

5 messages from 2008-11-07 to 2008-11-08. Participants: Ingo Molnar, Junio C Hamano, Daniel Barkalow.
Thread: https://gitlist.dev/t/16207

## Ingo Molnar, 2008-11-07 09:20

Subject: [minor usability suggestion] git rebase <upstream> --onto <newbase> ?
Message-ID: <20081107092035.GA1339@elte.hu>
URL: https://gitlist.dev/e/20081107092035.GA1339%40elte.hu

```

I use git rebase rarely, but i just had one of those exceptions where 
it's OK to use it: wanted to zap an unsafe commit [685aebb below] from 
a short-lifetime topic branch. With that i had this small usability 
incident:

 earth4:~/tip> tc
 tip/core/urgent 82d4e6e: xen: make sure stray alias mappings are gone

 earth4:~/tip> git rebase 685aebb --onto linus
 Current branch core/urgent is up to date.

 earth4:~/tip> glll
 82d4e6e: xen: make sure stray alias mappings are gone before pinning
 f6ab176: vmap: cope with vm_unmap_aliases before vmalloc_init()
 685aebb: kernel/cpu.c: section mismatch warning fix

 earth4:~/tip> git rebase --onto linus 685aebb
 First, rewinding head to replay your work on top of it...
 Applying: vmap: cope with vm_unmap_aliases before vmalloc_init()
 Applying: xen: make sure stray alias mappings are gone before pinning

 earth4:~/tip> glll
 d05fdf3: xen: make sure stray alias mappings are gone before pinning
 9b46333: vmap: cope with vm_unmap_aliases before vmalloc_init()

 earth4:~/tip> tc
 tip/core/urgent d05fdf3: xen: make sure stray alias mappings are gone 

 earth4:~/tip> git version
 git version 1.6.0.2.GIT

What i tried to achieve was to zap a single commit that was applied 
first, and preserve the other two commits - without having to go via 
the longer "git rebase -i" path.

It took me some time to figure out that while the principle i applied 
was correct, the first rebase command didnt work because i mistakenly 
flipped around the "--onto <newbase> <upstream>" arguments to 
"<upstream> --onto <newbase>".

Unless the reverse order is meaningful and important, it might make 
sense to flip it back implicitly and thus accept that order as well 
transparently.

For example "git log" is exemplary in this area as it accepts just 
about any permutation of parameters thrown at it, and i love that 
aspect of Git commands in general, it's a really nice property.

Or at least we should print some sort of warning/error? The "Current 
branch core/urgent is up to date." message definitely did not help me 
in noticing my mistake.

	Ingo

```

## Junio C Hamano, 2008-11-07 18:23

Subject: Re: [minor usability suggestion] git rebase <upstream> --onto <newbase> ?
Message-ID: <7vej1ngztd.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vej1ngztd.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20081107092035.GA1339@elte.hu>

```
Ingo Molnar <mingo@elte.hu> writes:

>  earth4:~/tip> git rebase 685aebb --onto linus
>  Current branch core/urgent is up to date.
> ...
> For example "git log" is exemplary in this area as it accepts just 
> about any permutation of parameters thrown at it, ...

Not really.

There may be oddball commands whose parameter order have been established
differently long before "git log" came, but almost all of them now use the
same convention used by the "git log" family, which is flags/options then
revs (and then paths if the operation makes sense with paths).  And rebase
is not one of the oddball ones.

Your "rebase" example is a rev then a flag/option, which is not how any
other git command take its command line parameters.

> Or at least we should print some sort of warning/error?

With that I agree with.  Patches? ;-)

```

## Daniel Barkalow, 2008-11-07 20:10

Subject: Re: [minor usability suggestion] git rebase <upstream> --onto <newbase> ?
Message-ID: <alpine.LNX.1.00.0811071504110.19665@iabervon.org>
URL: https://gitlist.dev/e/alpine.LNX.1.00.0811071504110.19665%40iabervon.org
In-Reply-To: <7vej1ngztd.fsf@gitster.siamese.dyndns.org>

```
On Fri, 7 Nov 2008, Junio C Hamano wrote:

> Ingo Molnar <mingo@elte.hu> writes:
> 
> >  earth4:~/tip> git rebase 685aebb --onto linus
> >  Current branch core/urgent is up to date.
> > ...
> > For example "git log" is exemplary in this area as it accepts just 
> > about any permutation of parameters thrown at it, ...
> 
> Not really.
> 
> There may be oddball commands whose parameter order have been established
> differently long before "git log" came, but almost all of them now use the
> same convention used by the "git log" family, which is flags/options then
> revs (and then paths if the operation makes sense with paths).  And rebase
> is not one of the oddball ones.
> 
> Your "rebase" example is a rev then a flag/option, which is not how any
> other git command take its command line parameters.

"git log origin/master -p" works, though. It's paths, not revisions, that 
can't appear before options (or revisions).

	-Daniel
*This .sig left intentionally blank*

```

## Junio C Hamano, 2008-11-07 21:06

Subject: Re: [minor usability suggestion] git rebase <upstream> --onto <newbase> ?
Message-ID: <7vy6zvfdp5.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy6zvfdp5.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <alpine.LNX.1.00.0811071504110.19665@iabervon.org>

```
Daniel Barkalow <barkalow@iabervon.org> writes:

> "git log origin/master -p" works, though.

That's an accident.  Do not rely on it.

```

## Ingo Molnar, 2008-11-08 11:49

Subject: Re: [minor usability suggestion] git rebase <upstream> --onto <newbase> ?
Message-ID: <20081108114955.GC8354@elte.hu>
URL: https://gitlist.dev/e/20081108114955.GC8354%40elte.hu
In-Reply-To: <7vy6zvfdp5.fsf@gitster.siamese.dyndns.org>

```

* Junio C Hamano <gitster@pobox.com> wrote:

> Daniel Barkalow <barkalow@iabervon.org> writes:
> 
> > "git log origin/master -p" works, though.
> 
> That's an accident.  Do not rely on it.

hm, i frequently rely on tacking-on options after the fact, especially 
the -- ones.

Just like the best workflow is append-mostly, command parameters are 
often added append-only as well, without jumping back and forth in the 
command line to edit the command.

Path or brach names starting with '--' are weird anyway, so isnt this 
a reasonable expectation? I hope i'm not misunderstanding something 
here.

	Ingo

```
