Imported Upstream version 2.27.0
[platform/upstream/git.git] / run-command.c
index f5e1149..9b3a57d 100644 (file)
@@ -421,12 +421,12 @@ static int prepare_cmd(struct argv_array *out, const struct child_process *cmd)
        }
 
        /*
-        * If there are no '/' characters in the command then perform a path
-        * lookup and use the resolved path as the command to exec.  If there
-        * are '/' characters, we have exec attempt to invoke the command
-        * directly.
+        * If there are no dir separator characters in the command then perform
+        * a path lookup and use the resolved path as the command to exec. If
+        * there are dir separator characters, we have exec attempt to invoke
+        * the command directly.
         */
-       if (!strchr(out->argv[1], '/')) {
+       if (!has_dir_sep(out->argv[1])) {
                char *program = locate_in_PATH(out->argv[1]);
                if (program) {
                        free((char *)out->argv[1]);
@@ -1864,3 +1864,16 @@ int run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
 
        return result;
 }
+
+int run_auto_gc(int quiet)
+{
+       struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
+       int status;
+
+       argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
+       if (quiet)
+               argv_array_push(&argv_gc_auto, "--quiet");
+       status = run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
+       argv_array_clear(&argv_gc_auto);
+       return status;
+}