]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-merge.c
Simplify t3410
[git.git] / builtin-merge.c
index 7c2b90c70baed2c7f008c2b98ad26135ef12db00..e4555b01996050db8d2909bc6e6bf5110b2bf4c9 100644 (file)
@@ -293,40 +293,13 @@ static void squash_message(void)
                pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,
                        NULL, NULL, rev.date_mode, 0);
        }
-       write(fd, out.buf, out.len);
-       close(fd);
+       if (write(fd, out.buf, out.len) < 0)
+               die("Writing SQUASH_MSG: %s", strerror(errno));
+       if (close(fd))
+               die("Finishing SQUASH_MSG: %s", strerror(errno));
        strbuf_release(&out);
 }
 
-static int run_hook(const char *name)
-{
-       struct child_process hook;
-       const char *argv[3], *env[2];
-       char index[PATH_MAX];
-
-       argv[0] = git_path("hooks/%s", name);
-       if (access(argv[0], X_OK) < 0)
-               return 0;
-
-       snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", get_index_file());
-       env[0] = index;
-       env[1] = NULL;
-
-       if (squash)
-               argv[1] = "1";
-       else
-               argv[1] = "0";
-       argv[2] = NULL;
-
-       memset(&hook, 0, sizeof(hook));
-       hook.argv = argv;
-       hook.no_stdin = 1;
-       hook.stdout_to_stderr = 1;
-       hook.env = env;
-
-       return run_command(&hook);
-}
-
 static void finish(const unsigned char *new_head, const char *msg)
 {
        struct strbuf reflog_message = STRBUF_INIT;
@@ -372,7 +345,7 @@ static void finish(const unsigned char *new_head, const char *msg)
        }
 
        /* Run a post-merge hook */
-       run_hook("post-merge");
+       run_hook(NULL, "post-merge", squash ? "1" : "0", NULL);
 
        strbuf_release(&reflog_message);
 }