Re: [PATCH 2/4] merge-base: "--is-ancestor A B"

2012-08-31 Thread Junio C Hamano
Martin von Zweigbergk writes: > On Fri, Aug 31, 2012 at 10:25 AM, Junio C Hamano wrote: > ... >> I think "merge-base -h" will get this for free thanks to parseopt. > > It seems not, or maybe I'm using the wrong terminology; I meant to > include it in the first part of the below. > > usage: git m

Re: [PATCH 2/4] merge-base: "--is-ancestor A B"

2012-08-31 Thread Martin von Zweigbergk
On Fri, Aug 31, 2012 at 10:25 AM, Junio C Hamano wrote: > Martin von Zweigbergk writes: > >>> + if (argc != 2) >>> + die("--is-ancestor takes exactly two commits"); >> >> I think git merge-base shows the usage message regardless if argc < 2, >> so this only happens when more t

Re: [PATCH 2/4] merge-base: "--is-ancestor A B"

2012-08-31 Thread Junio C Hamano
Martin von Zweigbergk writes: >> + if (argc != 2) >> + die("--is-ancestor takes exactly two commits"); > > I think git merge-base shows the usage message regardless if argc < 2, > so this only happens when more than two arguments are given. Yes, but it is a good discipline no

Re: [PATCH 2/4] merge-base: "--is-ancestor A B"

2012-08-31 Thread Martin von Zweigbergk
(Resending as plain text, sorry about duplicate, Junio.) On Thu, Aug 30, 2012 at 4:13 PM, Junio C Hamano wrote: > > In many scripted Porcelain commands, we find this idiom: > > if test "$(git rev-parse --verify A)" = "$(git merge-base A B)" > then > ... A is an ancestor of B ... >

[PATCH 2/4] merge-base: "--is-ancestor A B"

2012-08-30 Thread Junio C Hamano
In many scripted Porcelain commands, we find this idiom: if test "$(git rev-parse --verify A)" = "$(git merge-base A B)" then ... A is an ancestor of B ... fi But you do not have to compute exact merge-base only to see if A is an ancestor of B. Give them a more direct way to