git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org, jrnieder@gmail.com, Jens.Lehmann@web.de
Subject: Re: [PATCH 2/2] submodule: port init from shell to C
Date: Thu, 18 Feb 2016 15:15:37 -0800	[thread overview]
Message-ID: <xmqqmvqxehk6.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqmvqxg30y.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Thu, 18 Feb 2016 12:46:37 -0800")

Junio C Hamano <gitster@pobox.com> writes:

>> +	strbuf_reset(&sb);
>> +	strbuf_addf(&sb, "submodule.%s.url", sub->name);
>> +	if (git_config_get_string(sb.buf, &url)) {
>> +		url = xstrdup(sub->url);
>> +		if (!url)
>> +			die(_("No url found for submodule path '%s' in .gitmodules"),
>> +				displaypath);
>
> I am assuming that this corresponds to these lines in the original
> scripted version:
>
> 		url=$(git config -f .gitmodules submodule."$name".url)
> 		test -z "$url" &&
> 		die "$(eval_gettext "No url found for submodule path...
>
> but what makes git_config_get_string() to read from ".gitmodules"
> file?  Doesn't it read from $GIT_DIR/config & ~/.gitconfig instead?

I am starting to suspect that reading of ".gitmodules" in the
context of "git submodule" command is a good use case for the
configset API.  It wants to read variables from ".gitmodules" and
the regular configuration file, and cares about where they come
from, illustrated by this codepath.  Read URL from .gitmodules, do
something to it, and update the regular configuration file.  Read
Update from .gitmodules, do some verification, and selectively store
it in the regular configuration file.  There may be cases where you
want to check if a variable is in the regular configuration file
(i.e. read from there), see its value in ".gitmodules", and
conditionally update the regular configuration file (i.e. write into
it).  The configset API was designed to help implement this kind of
thing in a clean manner (i.e. initialize one, add ".gitmodules"
file, and then configset_get_* on it, without affecting what you
read and write with the regular config_get_*/config_set_* to the
regular configuration file).

  reply	other threads:[~2016-02-18 23:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-12 23:39 [PATCH 0/2] Port `git submodule init` from shell to C Stefan Beller
2016-02-12 23:39 ` [PATCH 1/2] submodule: port resolve_relative_url " Stefan Beller
2016-02-18 20:23   ` Junio C Hamano
2016-02-27  8:28   ` Duy Nguyen
2016-03-02 17:21   ` Johannes Sixt
2016-03-02 17:34     ` Stefan Beller
2016-02-12 23:39 ` [PATCH 2/2] submodule: port init " Stefan Beller
2016-02-18 20:46   ` Junio C Hamano
2016-02-18 23:15     ` Junio C Hamano [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-04-16  0:50 [PATCH 0/2] Another reroll of sb/submodule-init Stefan Beller
2016-04-16  0:50 ` [PATCH 2/2] submodule: port init from shell to C Stefan Beller
2016-04-14 18:18 [PATCH 0/2] Port `submodule init` " Stefan Beller
2016-04-14 18:18 ` [PATCH 2/2] submodule: port init from shell " Stefan Beller
2016-04-13  0:18 [PATCH 0/2] Port `git submodule init` " Stefan Beller
2016-04-13  0:18 ` [PATCH 2/2] submodule: port init " Stefan Beller
2016-03-15  0:15 [PATCH 0/2] Port `git submodule init` " Stefan Beller
2016-03-15  0:15 ` [PATCH 2/2] submodule: port init " Stefan Beller
2016-01-15 23:37 [PATCH 0/2] Port `git submodule init` " Stefan Beller
2016-01-15 23:37 ` [PATCH 2/2] submodule: Port init " Stefan Beller

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=xmqqmvqxehk6.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --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).