Merge branch 'es/blame-L-breakage'
[gitweb.git] / git.c
diff --git a/git.c b/git.c
index 88eef5a7cc6d36f6e17f4855945116dd6f1b0681..6104d5eefc882cdbf978b5a141c93c20b78fcb2b 100644 (file)
--- a/git.c
+++ b/git.c
@@ -514,8 +514,9 @@ static int run_argv(int *argcp, const char ***argv)
 }
 
 
-int main(int argc, const char **argv)
+int main(int argc, char **av)
 {
+       const char **argv = (const char **) av;
        const char *cmd;
 
        startup_info = &git_startup_info;
@@ -524,6 +525,13 @@ int main(int argc, const char **argv)
        if (!cmd)
                cmd = "git-help";
 
+       /*
+        * Always open file descriptors 0/1/2 to avoid clobbering files
+        * in die().  It also avoids messing up when the pipes are dup'ed
+        * onto stdin/stdout/stderr in the child processes we spawn.
+        */
+       sanitize_stdfds();
+
        git_setup_gettext();
 
        /*