Skip to content

Commit 5a1c824

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bd26756 commit 5a1c824

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

submodule.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,13 +1023,6 @@ int ok_to_remove_submodule(const char *path)
10231023
{
10241024
ssize_t len;
10251025
struct child_process cp = CHILD_PROCESS_INIT;
1026-
const char *argv[] = {
1027-
"status",
1028-
"--porcelain",
1029-
"-u",
1030-
"--ignore-submodules=none",
1031-
NULL,
1032-
};
10331026
struct strbuf buf = STRBUF_INIT;
10341027
int ok_to_remove = 1;
10351028

@@ -1039,22 +1032,23 @@ int ok_to_remove_submodule(const char *path)
10391032
if (!submodule_uses_gitfile(path))
10401033
return 0;
10411034

1042-
cp.argv = argv;
1035+
argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
1036+
"--ignore-submodules=none", NULL);
10431037
prepare_submodule_repo_env(&cp.env_array);
10441038
cp.git_cmd = 1;
10451039
cp.no_stdin = 1;
10461040
cp.out = -1;
10471041
cp.dir = path;
10481042
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);
10501044

10511045
len = strbuf_read(&buf, cp.out, 1024);
10521046
if (len > 2)
10531047
ok_to_remove = 0;
10541048
close(cp.out);
10551049

10561050
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);
10581052

10591053
strbuf_release(&buf);
10601054
return ok_to_remove;

0 commit comments

Comments
 (0)