Git 2.4.9
[gitweb.git] / submodule.c
index d37d400b2227c58f352795b9f6ede20a9cd54631..5a563ad100b107e1d41258da57395b92604b9504 100644 (file)
@@ -576,12 +576,10 @@ static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
                cp.env = local_repo_env;
                cp.git_cmd = 1;
                cp.no_stdin = 1;
-               cp.out = -1;
                cp.dir = path;
-               if (!run_command(&cp) && !strbuf_read(&buf, cp.out, 1024))
+               if (!capture_command(&cp, &buf, 1024) && !buf.len)
                        is_present = 1;
 
-               close(cp.out);
                strbuf_release(&buf);
        }
        return is_present;
@@ -893,7 +891,6 @@ int submodule_uses_gitfile(const char *path)
 
 int ok_to_remove_submodule(const char *path)
 {
-       struct stat st;
        ssize_t len;
        struct child_process cp = CHILD_PROCESS_INIT;
        const char *argv[] = {
@@ -906,7 +903,7 @@ int ok_to_remove_submodule(const char *path)
        struct strbuf buf = STRBUF_INIT;
        int ok_to_remove = 1;
 
-       if ((lstat(path, &st) < 0) || is_empty_dir(path))
+       if (!file_exists(path) || is_empty_dir(path))
                return 1;
 
        if (!submodule_uses_gitfile(path))