Merge branch 'jk/options-cleanup'
[gitweb.git] / builtin / commit.c
index 6aac5e284c589085668707aff3ac91470dc17ff7..b3bd2d41813f80d848afc199c2fae92cae6b6c11 100644 (file)
@@ -32,6 +32,7 @@
 #include "sequencer.h"
 #include "notes-utils.h"
 #include "mailmap.h"
+#include "sigchain.h"
 
 static const char * const builtin_commit_usage[] = {
        N_("git commit [<options>] [--] <pathspec>..."),
@@ -760,7 +761,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                hook_arg2 = "";
        }
 
-       s->fp = fopen(git_path(commit_editmsg), "w");
+       s->fp = fopen_for_writing(git_path(commit_editmsg));
        if (s->fp == NULL)
                die_errno(_("could not open '%s'"), git_path(commit_editmsg));
 
@@ -1537,8 +1538,10 @@ static int run_rewrite_hook(const unsigned char *oldsha1,
                return code;
        n = snprintf(buf, sizeof(buf), "%s %s\n",
                     sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
+       sigchain_push(SIGPIPE, SIG_IGN);
        write_in_full(proc.in, buf, n);
        close(proc.in);
+       sigchain_pop(SIGPIPE);
        return finish_command(&proc);
 }
 
@@ -1687,7 +1690,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                if (fp == NULL)
                        die_errno(_("could not open '%s' for reading"),
                                  git_path_merge_head());
-               while (strbuf_getline(&m, fp, '\n') != EOF) {
+               while (strbuf_getline_lf(&m, fp) != EOF) {
                        struct commit *parent;
 
                        parent = get_merge_parent(m.buf);