git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 9 in “"merge-base" updates”
  1. 0/4 "merge-base" updatesJunio C Hamano, Aug 30, 2012
  2. 1/4 merge_bases_many(): split out the logic to paint historyJunio C Hamano, Aug 30, 2012
  3. 2/4 merge-base: "--is-ancestor A B"Junio C Hamano, Aug 30, 2012
  4. Martin von ZweigbergkAug 31, 2012
  5. Junio C HamanoAug 31, 2012
  6. Martin von ZweigbergkAug 31, 2012
  7. Junio C HamanoAug 31, 2012
  8. 3/4 in_merge_bases(): use paint_down_to_common()Junio C Hamano, Aug 30, 2012
  9. 4/4 get_merge_bases_many(): walk from many tips in parallelJunio C Hamano, Aug 30, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.