From: Martin von Zweigbergk Date: Fri, 31 Aug 2012 18:03:28 GMT Subject: Re: [PATCH 2/4] merge-base: "--is-ancestor A B" Message-ID: In-Reply-To: <7vtxvjnfcu.fsf@alter.siamese.dyndns.org> 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 than two arguments are given. > > Yes, but it is a good discipline not to depend too much on what > other parts of the code may have done, when you do not have to. Yes, I definitely agree. It was more that when I saw this line and then tried it out, I was a little surprised that it didn't tell med "--is-ancestor takes exactly two commits" when I gave it only one. But since few users read the code before running the command, it will probably not be too surprising :-) >> Maybe >> include --is-ancestor in the usage message? > > 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 merge-base [-a|--all] ... or: git merge-base [-a|--all] --octopus ... or: git merge-base --independent ... -a, --all output all common ancestors --octopus find ancestors for a single n-way merge --independent list revs not reachable from others --is-ancestor is the first one ancestor of the other? > 'git merge-base' [-a|--all] --octopus ... > +'git merge-base' --is-ancestor > 'git merge-base' --independent ... Ah, I guess this is what I was looking for. The remainder of the patch looks good too. Thanks.