From: Jonathan Nieder <jrnieder@gmail.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Jens Lehmann <Jens.Lehmann@web.de>,
Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Heiko Voigt <hvoigt@hvoigt.net>, Phil Hord <phil.hord@gmail.com>,
"W. Trevor King" <wking@tremily.us>,
Peter Collingbourne <peter@pcc.me.uk>,
John Keeping <john@keeping.me.uk>
Subject: Re: [RFC/PATCH] rm: delete .gitmodules entry of submodules removed from the work tree
Date: Wed, 10 Apr 2013 16:30:58 -0700 [thread overview]
Message-ID: <20130410233058.GI27070@google.com> (raw)
In-Reply-To: <CALkWK0mzbgFP7JnCP7=NCA1guGg8ayF-mn7WdJEZyYX5hgePFw@mail.gmail.com>
Hi,
Thanks for looking it over.
Ramkumar Ramachandra wrote:
> - Why are you hard-coding ".gitmodules" instead of using a simple #define?
Advantage of ".gitmodules": it's obvious what it means.
Advantage of DOT_GITMODULES: protection against spelling errors.
Git has a lot of use of both styles of string constant, for better or
worse. Consistency means following what the surrounding code does,
and making changes if appropriate in a separate patch.
> - Why are you returning -1, instead of an error() with a message?
I think the idea is that remove_path_from_gitmodules() is idempotent:
if that path isn't listed in gitmodules, that's considered fine and
.gitmodules is left alone, instead of making a user that tries to
first remove a .gitmodules file and then all submodules suffer.
Perhaps a return value of '0 if gitmodules unmodified, 1 if modified'
would make it clearer that this isn't an error condition.
[...]
>> + path_option = unsorted_string_list_lookup(&config_name_for_path, path);
>> + if (!path_option) {
>> + warning(_("Could not find section in .gitmodules where path=%s"), path);
>> + return -1;
>> + }
>
> Repetition from your mv series. Why copy-paste, when you can factor
> it out into a function?
Do you mean that update_path_in_gitmodules should treat newpath ==
NULL as a cue to remove that entry, or something similar?
> Why are you calling warning() and then returning -1?
Sure, "return warning(...)" is a good shortcut.
> warning() not work?) How is it a warning if you just stop all
> processing and return?
Probably it shouldn't warn in this case.
>> + strbuf_addstr(§, "submodule.");
>> + strbuf_addstr(§, path_option->util);
>
> What do you have against strbuf_addf()?
I think both addf and addstr are pretty clear. The implementation of
addf is more complicated, which can be relevant in performance-critical
code (not here).
> Why is your variable named "sect"? Did you mean "section"?
I think both "sect" and "section" are pretty clear.
[...]
>> + /* Maybe the user already did that, don't error out here */
>> + warning(_("Could not remove .gitmodules entry for %s"), path);
>> + return -1;
>
> Maybe the user already did what? What happens if she didn't do "it"
> and failure is due to some other cause?
git_config_rename_section_in_file() can fail for the following reasons:
* invalid new section name (NULL is valid, so doesn't apply here)
* could not lock config file
* write error
* could not commit config file
If the old section is missing, it doesn't even fail (it just
returns 0). So I agree: this should be an error instead of a warning.
Hope that helps,
Jonathan
prev parent reply other threads:[~2013-04-10 23:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 22:03 [RFC/PATCH] rm: delete .gitmodules entry of submodules removed from the work tree Jens Lehmann
2013-04-10 22:24 ` Ramkumar Ramachandra
2013-04-10 23:30 ` Jonathan Nieder [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130410233058.GI27070@google.com \
--to=jrnieder@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hvoigt@hvoigt.net \
--cc=john@keeping.me.uk \
--cc=peter@pcc.me.uk \
--cc=phil.hord@gmail.com \
--cc=wking@tremily.us \
/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.
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 NNTP newsgroup(s).