From: Jeff King <peff@peff.net>
To: Stefan Beller <sbeller@google.com>
Cc: Junio C Hamano <gitster@pobox.com>,
"git@vger.kernel.org" <git@vger.kernel.org>,
Jens Lehmann <Jens.Lehmann@web.de>,
Avery Pennarun <apenwarr@gmail.com>,
Jonathan Nieder <jrnieder@gmail.com>
Subject: Re: [PATCHv3 6/7] submodule--helper: add remote-branch helper
Date: Wed, 3 Aug 2016 16:15:44 -0400 [thread overview]
Message-ID: <20160803201544.7sljaikzwws7rekv@sigill.intra.peff.net> (raw)
In-Reply-To: <CAGZ79kYW0dwUh=QpKL9W+cv8k_Z9Vc2wxoLMqud5brDtS9DYpA@mail.gmail.com>
On Wed, Aug 03, 2016 at 01:11:51PM -0700, Stefan Beller wrote:
> > Coverity complains about "sub" being NULL here, and indeed, it seems
> > like an easy segfault:
> >
> > $ ./git submodule--helper remote-branch foo
> > Segmentation fault
> >
> > I guess this should return NULL in that case. But then this...
>
> I thought about checking for (!sub && !sub->branch) to return "master";
> However I disregarded that implementation as the submodule-config is
> reliable for any correct input. Though we need to handle wrong input as
> well. So how about:
>
> if (!sub)
> die(_("A submodule doesn't exist at path %s"), path);
> if (!sub->branch)
> return "master";
OK by me, as long as the caller of submodule--helper handles the death
reasonably. Since it's an internal helper program, we really only have
to worry about what git-submodule.sh does with it, which is good.
> > would need to handle the NULL return, as well. So maybe "master" or the
> > empty string would be better. I haven't followed the topic closely
> > enough to have an opinion.
>
> Oh I see, this can turn into a discussion what the API for
> remote_submodule_branch is. I think handling the NULL here and dying makes
> more sense as then we can keep remote_submodule_branch pure to its
> intended use case. (If in the far future we have all the submodule stuff in C,
> we may want to call remote_submodule_branch when we already know
> that the path is valid, so no need to check it in there. Also not dying in there
> is more libified.)
Yep, that makes sense to me, too.
-Peff
next prev parent reply other threads:[~2016-08-03 20:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-29 0:44 [PATCHv3 0/7] submodule update: allow '.' for branch value Stefan Beller
2016-07-29 0:44 ` [PATCHv3 1/7] t7406: future proof tests with hard coded depth Stefan Beller
2016-07-29 0:44 ` [PATCHv3 2/7] submodule update: respect depth in subsequent fetches Stefan Beller
2016-07-29 0:44 ` [PATCHv3 3/7] submodule update: narrow scope of local variable Stefan Beller
2016-07-29 0:44 ` [PATCHv3 4/7] submodule--helper: fix usage string for relative-path Stefan Beller
2016-07-29 0:44 ` [PATCHv3 5/7] submodule-config: keep configured branch around Stefan Beller
2016-07-29 0:44 ` [PATCHv3 6/7] submodule--helper: add remote-branch helper Stefan Beller
2016-08-03 16:25 ` Jeff King
2016-08-03 20:11 ` Stefan Beller
2016-08-03 20:15 ` Jeff King [this message]
2016-07-29 0:44 ` [PATCHv3 7/7] submodule update: allow '.' for branch value Stefan Beller
2016-08-01 21:48 ` [PATCHv3 0/7] " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160803201544.7sljaikzwws7rekv@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Jens.Lehmann@web.de \
--cc=apenwarr@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).