t3404: fix quoting of redirect for some versions of bash
[gitweb.git] / submodule.c
index d37d400b2227c58f352795b9f6ede20a9cd54631..d491e6a7717ef0e1b9f7efd91becb024b98e0161 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;
@@ -1102,16 +1100,11 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
        struct strbuf file_name = STRBUF_INIT;
        struct strbuf rel_path = STRBUF_INIT;
        const char *real_work_tree = xstrdup(real_path(work_tree));
-       FILE *fp;
 
        /* Update gitfile */
        strbuf_addf(&file_name, "%s/.git", work_tree);
-       fp = fopen(file_name.buf, "w");
-       if (!fp)
-               die(_("Could not create git link %s"), file_name.buf);
-       fprintf(fp, "gitdir: %s\n", relative_path(git_dir, real_work_tree,
-                                                 &rel_path));
-       fclose(fp);
+       write_file(file_name.buf, 1, "gitdir: %s\n",
+                  relative_path(git_dir, real_work_tree, &rel_path));
 
        /* Update core.worktree setting */
        strbuf_reset(&file_name);