submodule: modernize ok_to_remove_submodule to use argv_array

Instead of constructing the NULL terminated array ourselves, we should make use of the argv_array infrastructure. While at it, adapt the error messages to reflect the actual invocation. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Dec 20, 2016 at 15:20 UTC 5a1c824f70ec261f8f9e5e039555fc80301dee0b
1 file changed +4 -10
submodule.c
+4 -10
@@ -1023,13 +1023,6 @@ int ok_to_remove_submodule(const char *path)
1023 {
1024 ssize_t len;
1025 struct child_process cp = CHILD_PROCESS_INIT;
1026 - const char *argv[] = {
1027 - "status",
1028 - "--porcelain",
1029 - "-u",
1030 - "--ignore-submodules=none",
1031 - NULL,
1032 - };
1026 struct strbuf buf = STRBUF_INIT;
1027 int ok_to_remove = 1;
1028
@@ -1039,14 +1032,15 @@ int ok_to_remove_submodule(const char *path)
1032 if (!submodule_uses_gitfile(path))
1033 return 0;
1034
1042 - cp.argv = argv;
1035 + argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
1036 + "--ignore-submodules=none", NULL);
1037 prepare_submodule_repo_env(&cp.env_array);
1038 cp.git_cmd = 1;
1039 cp.no_stdin = 1;
1040 cp.out = -1;
1041 cp.dir = path;
1042 if (start_command(&cp))
1049 - die("Could not run 'git status --porcelain -uall --ignore-submodules=none' in submodule %s", path);
1043 + die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
1044
1045 len = strbuf_read(&buf, cp.out, 1024);
1046 if (len > 2)
@@ -1054,7 +1048,7 @@ int ok_to_remove_submodule(const char *path)
1048 close(cp.out);
1049
1050 if (finish_command(&cp))
1057 - die("'git status --porcelain -uall --ignore-submodules=none' failed in submodule %s", path);
1051 + die(_("'git status --porcelain -u --ignore-submodules=none' failed in submodule %s"), path);
1052
1053 strbuf_release(&buf);
1054 return ok_to_remove;