From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org, David.Turner@twosigma.com,
bmwill@google.com, sandals@crustytoothpaste.net
Subject: Re: [PATCHv3 3/4] submodule: add flags to ok_to_remove_submodule
Date: Wed, 14 Dec 2016 15:48:40 -0800 [thread overview]
Message-ID: <xmqqpokuvzqf.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20161214224101.6211-4-sbeller@google.com> (Stefan Beller's message of "Wed, 14 Dec 2016 14:41:00 -0800")
Stefan Beller <sbeller@google.com> writes:
> diff --git a/submodule.c b/submodule.c
> index 9f0b544ebe..2d13744b06 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1019,7 +1019,7 @@ int submodule_uses_gitfile(const char *path)
> return 1;
> }
>
> -int ok_to_remove_submodule(const char *path)
> +int ok_to_remove_submodule(const char *path, unsigned flags)
> {
> ssize_t len;
> struct child_process cp = CHILD_PROCESS_INIT;
> @@ -1032,15 +1032,27 @@ int ok_to_remove_submodule(const char *path)
> if (!submodule_uses_gitfile(path))
> return 0;
>
> - argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
> + argv_array_pushl(&cp.args, "status", "--porcelain",
> "--ignore-submodules=none", NULL);
> +
> + if (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED)
> + argv_array_push(&cp.args, "-uno");
> + else
> + argv_array_push(&cp.args, "-uall");
> +
> + if (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED))
> + argv_array_push(&cp.args, "--ignored");
> +
These "internal values to assemble command line" operations we
cannot avoid. But things like this ...
> if (start_command(&cp))
> - die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
> + die(_("could not run 'git status --porcelain --ignore-submodules=none %s %s' in submodule '%s'"),
> + (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) ? "-uno" : "-uall",
> + (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)) ? "--ignored" : "",
> + path);
and this ...
> if (finish_command(&cp))
> - die(_("'git status --porcelain -u --ignore-submodules=none' failed in submodule %s"), path);
> + die(_("'git status --porcelain --ignore-submodules=none %s %s' failed in submodule '%s'"),
> + (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) ? "-uno" : "-uall",
> + (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)) ? "--ignored" : "",
> + path);
makes me wonder if we want a helper that builds the string out of an
already assembled cp.args[] array, so that we won't have to do the
same thing twice/thrice and more importantly we won't have to worry
about these three going out of sync.
next prev parent reply other threads:[~2016-12-14 23:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 22:40 [PATCHv3 0/4] git-rm absorbs submodule git directory before deletion Stefan Beller
2016-12-14 22:40 ` [PATCHv3 1/4] submodule.h: add extern keyword to functions Stefan Beller
2016-12-14 22:40 ` [PATCHv3 2/4] submodule: modernize ok_to_remove_submodule to use argv_array Stefan Beller
2016-12-14 22:41 ` [PATCHv3 3/4] submodule: add flags to ok_to_remove_submodule Stefan Beller
2016-12-14 23:10 ` Brandon Williams
2016-12-14 23:48 ` Junio C Hamano [this message]
2016-12-14 22:41 ` [PATCHv3 4/4] rm: add absorb a submodules git dir before deletion Stefan Beller
2016-12-14 23: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=xmqqpokuvzqf.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=David.Turner@twosigma.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=sandals@crustytoothpaste.net \
--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).