git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	Brandon Williams <bmwill@google.com>,
	David Turner <David.Turner@twosigma.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCHv5 3/4] submodule: rename and add flags to ok_to_remove_submodule
Date: Tue, 27 Dec 2016 09:55:27 -0800	[thread overview]
Message-ID: <CAGZ79kbpq3WPk-sSoVh8s0FUanctEjHH92LfpoBGYV2WhfEV-w@mail.gmail.com> (raw)
In-Reply-To: <xmqqr34uchuq.fsf@gitster.mtv.corp.google.com>

On Mon, Dec 26, 2016 at 4:53 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> As only 0 is understood as false, rename the function to invert the
>> meaning, i.e. the return code of 0 signals the removal of the submodule
>> is fine, and other values can be used to return a more precise answer
>> what went wrong.
>
> Makes sense to rename it as that will catch all the callers that
> depend on the old semantics and name.
>
>> -     if (start_command(&cp))
>> -             die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
>> +     if (start_command(&cp)) {
>> +             if (flags & SUBMODULE_REMOVAL_DIE_ON_ERROR)
>> +                     die(_("could not start 'git status in submodule '%s'"),
>> +                             path);
>> +             ret = -1;
>> +             goto out;
>> +     }
>
> This new codepath that does not die will not leak anything, as
> a failed start_command() should release its argv[] and env[].
>
>>       len = strbuf_read(&buf, cp.out, 1024);
>>       if (len > 2)
>> -             ok_to_remove = 0;
>> +             ret = 1;
>
> Not a new problem but is it obvious why the comparison of "len" is
> against "2"?  This may deserve a one-liner comment.
>
> Otherwise looks good to me.

I took the check "len > 2" from the other occurrence in submodule.c.
When thinking about it (and inspecting the man page for
porcelain status), I think just checking != 0 is sufficient.

So in a reroll I'll change that to just

    if (len)
        ...

I'll look at the other occurrences and see if we can reuse code
as well.

Thanks,
Stefan

  reply	other threads:[~2016-12-27 17:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-20 23:20 [PATCHv5 0/4] git-rm absorbs submodule git directory before deletion Stefan Beller
2016-12-20 23:20 ` [PATCHv5 1/4] submodule.h: add extern keyword to functions Stefan Beller
2016-12-27  1:13   ` Junio C Hamano
2016-12-27 17:59     ` Stefan Beller
2016-12-20 23:20 ` [PATCHv5 2/4] submodule: modernize ok_to_remove_submodule to use argv_array Stefan Beller
2016-12-20 23:20 ` [PATCHv5 3/4] submodule: rename and add flags to ok_to_remove_submodule Stefan Beller
2016-12-27  0:53   ` Junio C Hamano
2016-12-27 17:55     ` Stefan Beller [this message]
2016-12-20 23:20 ` [PATCHv5 4/4] rm: absorb a submodules git dir before deletion Stefan Beller
2016-12-27  1:10   ` Junio C Hamano
2016-12-27 18:17     ` Stefan Beller
2016-12-27 18:26       ` Stefan Beller
2016-12-27 21:55         ` 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=CAGZ79kbpq3WPk-sSoVh8s0FUanctEjHH92LfpoBGYV2WhfEV-w@mail.gmail.com \
    --to=sbeller@google.com \
    --cc=David.Turner@twosigma.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=sandals@crustytoothpaste.net \
    /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).