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

Re: [PATCH] branch: handle errors on setting tracking branches

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 25, 2015, 16:52 UTC
Message-ID
<xmqqzj0a4f2n.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20150924140538.GA11666@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 32 quoted lines
> I count 4 callers in the current code, and none of them currently looks
> at the return value. Your patch updates setup_tracking() to propagate
> the error, which is good. But that is called from exactly one place,
> create_branch(), which also ignores the outcome. :-/
>
> I don't think we want to die() when the config fails. That might be the
> right thing for "branch --set-upstream-to", but probably not for
> "checkout -b". I think we need to look at each call site and see whether
> we should be propagating the error back. With the hope that we would
> ultimately affect the exit code of the command.
>
> In the case of branch creation, we are in a two-step procedure: create
> the branch, then set up its tracking config. We _could_ rollback the
> first step when the second step fails, but that is probably not worth
> the complication.
>
>> Actually, there are quite a few places where we don't check the
>> return values of git_config_set and related functions. I didn't
>> go through them yet, but might do so if you deem this to be of
>> value.
>
> I think more error-checking is better than less. But I do think it's
> worth plumbing through the error codes in each case.
>
> It's tempting to just die() when the operation fails, but as discussed
> above, that's not always the most appropriate thing.
>
>>  branch.c | 24 ++++++++++++++++--------
>>  branch.h |  3 ++-
>>  2 files changed, 18 insertions(+), 9 deletions(-)
>
> The patch itself looks OK to me from a cursory read.

I agree with everything you said in the analysis, including that this patch is a good first step in the right direction, but at the same time it is a glorified no-op whose only external effect is to make the error diagnosis a bit noisier. A good first step in the right direction with stride length of zero ;-)

Previous: Jeff King
Message 3 of 3 in “branch: handle errors on setting tracking branches”
  1. branch: handle errors on setting tracking branchesPatrick Steinhardt, Sep 24, 2015
  2. Jeff KingSep 24, 2015
  3. Junio C HamanoSep 25, 2015

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.