rev-list: check reflog_info before showing usage
[gitweb.git] / sequencer.c
index 924fb1d0c3c84dd823393d7dea21af2d70a8d54e..3010faf86398697469e903318a35421d911acb23 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "config.h"
 #include "lockfile.h"
 #include "sequencer.h"
 #include "dir.h"
@@ -899,8 +900,8 @@ static void flush_rewritten_pending(void) {
        FILE *out;
 
        if (strbuf_read_file(&buf, rebase_path_rewritten_pending(), 82) > 0 &&
-                       !get_sha1("HEAD", newsha1) &&
-                       (out = fopen(rebase_path_rewritten_list(), "a"))) {
+           !get_sha1("HEAD", newsha1) &&
+           (out = fopen_or_warn(rebase_path_rewritten_list(), "a"))) {
                char *bol = buf.buf, *eol;
 
                while (*bol) {
@@ -919,7 +920,7 @@ static void flush_rewritten_pending(void) {
 
 static void record_in_rewritten(struct object_id *oid,
                enum todo_command next_command) {
-       FILE *out = fopen(rebase_path_rewritten_pending(), "a");
+       FILE *out = fopen_or_warn(rebase_path_rewritten_pending(), "a");
 
        if (!out)
                return;
@@ -1211,8 +1212,7 @@ struct todo_list {
 static void todo_list_release(struct todo_list *todo_list)
 {
        strbuf_release(&todo_list->buf);
-       free(todo_list->items);
-       todo_list->items = NULL;
+       FREE_AND_NULL(todo_list->items);
        todo_list->nr = todo_list->alloc = 0;
 }
 
@@ -1381,7 +1381,7 @@ static int read_populate_todo(struct todo_list *todo_list,
 
        if (is_rebase_i(opts)) {
                struct todo_list done = TODO_LIST_INIT;
-               FILE *f = fopen(rebase_path_msgtotal(), "w");
+               FILE *f = fopen_or_warn(rebase_path_msgtotal(), "w");
 
                if (strbuf_read_file(&done.buf, rebase_path_done(), 0) > 0 &&
                                !parse_insn_buffer(done.buf.buf, &done))
@@ -1922,7 +1922,7 @@ static int apply_autostash(struct replay_opts *opts)
        argv_array_push(&child.args, "apply");
        argv_array_push(&child.args, stash_sha1.buf);
        if (!run_command(&child))
-               printf(_("Applied autostash.\n"));
+               fprintf(stderr, _("Applied autostash.\n"));
        else {
                struct child_process store = CHILD_PROCESS_INIT;
 
@@ -1936,10 +1936,11 @@ static int apply_autostash(struct replay_opts *opts)
                if (run_command(&store))
                        ret = error(_("cannot store %s"), stash_sha1.buf);
                else
-                       printf(_("Applying autostash resulted in conflicts.\n"
-                               "Your changes are safe in the stash.\n"
-                               "You can run \"git stash pop\" or"
-                               " \"git stash drop\" at any time.\n"));
+                       fprintf(stderr,
+                               _("Applying autostash resulted in conflicts.\n"
+                                 "Your changes are safe in the stash.\n"
+                                 "You can run \"git stash pop\" or"
+                                 " \"git stash drop\" at any time.\n"));
        }
 
        strbuf_release(&stash_sha1);
@@ -2130,8 +2131,8 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
                        if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
                            !get_sha1(buf.buf, orig.hash) &&
                            !get_sha1("HEAD", head.hash)) {
-                               diff_tree_sha1(orig.hash, head.hash,
-                                              "", &log_tree_opt.diffopt);
+                               diff_tree_oid(&orig, &head, "",
+                                             &log_tree_opt.diffopt);
                                log_tree_diff_flush(&log_tree_opt);
                        }
                }