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

Re: bug with git merge-base

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2018, 04:05 UTC
Message-ID
<xmqqsh23xzoy.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAPig+cS+8+uGQTfxmq1XGMt5FBM1oq72d3N=3BkjhrA9ui+EWw@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 10 quoted lines
> On Wed, Sep 19, 2018 at 6:25 PM Alexander Mills
> <alexander.d.mills@gmail.com> wrote:
>> The following command sequence exits with 1, and no stderr
>>
>> base='remotes/origin/dev';
>> fork_point="$(git merge-base --fork-point "$base")";
>>
>> I cannot figure out why it's exiting with 1, but there is no stdout/stderr
>
> Unable to reproduce the problem. Perhaps you can provide more context.

Well, reading builtin/merge-base.c::handle_fork_point(), I think the intended behaviour is:

 - die() when input is not well formed (e.g. bad commit object,
   ambigous ref name, etc.); there is an error worth reporting in
   this case.
 - show one that used to sit at the tip of the ref, if exists, and
   signal success with exit status 0; there of course is no error in
   this case.
 - if there is no such fork point found, signal failure with exit
   status 1; nothing is written to the standard output as there is
   no fork point to be shown, and nothing is written to the standard
   error.

I do not think the code considers the last case as an error, i.e. it is just as natural not to have any fork point, as there is one.

It might be OK to teach the command to say "no fork point found" to the standard error under "--verbose" mode in the last case, but since the command does not take --verbose or --quiet, I have a feeling that everything is working as designed.

Previous: Eric SunshineNext: Junio C Hamano
Message 3 of 4 in “bug with git merge-base”
  1. Alexander MillsSep 19, 2018
  2. Eric SunshineSep 21, 2018
  3. Junio C HamanoSep 21, 2018
  4. Junio C HamanoSep 21, 2018

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.