Re: [PATCH 2/4] merge-base: "--is-ancestor A B"
- From
Martin von Zweigbergk <martinvonz@gmail.com>
- Date
- Aug 31, 2012, 15:44 UTC
- Message-ID
- <CANiSa6iy60Ts5Rdss6EwGN5Vp9KCqn35BzMC+Aacm+zqWjp4-w@mail.gmail.com>
- In-Reply-To
- <1346368388-23576-3-git-send-email-gitster@pobox.com>
(Resending as plain text, sorry about duplicate, Junio.)
On Thu, Aug 30, 2012 at 4:13 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 11 quoted lines
> > 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 use the underlying > machinery.
Thanks! It has bugged me ever since I first saw that idiom that there was no way that better shows the intent.
> + 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. Maybe include --is-ancestor in the usage message?
> + if (is_ancestor && (show_all | octopus | reduce))
> + die("--is-reachable cannot be used with other options");I suppose --is-reachable should be --is-ancestor.