sha1_file: make read_info_alternates static
[gitweb.git] / sequencer.c
index 021ddf36d0db43074c3dc674a907ef73cba8ffcc..eec8a60d6bdf22d429c14ad07288f823d9bac7b5 100644 (file)
@@ -226,7 +226,7 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
 
        read_cache();
        if (checkout_fast_forward(from, to, 1))
-               exit(128); /* the callee should have complained already */
+               return -1; /* the callee should have complained already */
 
        strbuf_addf(&sb, _("%s: fast-forward"), action_name(opts));
 
@@ -644,14 +644,18 @@ static int read_and_refresh_cache(struct replay_opts *opts)
 {
        static struct lock_file index_lock;
        int index_fd = hold_locked_index(&index_lock, 0);
-       if (read_index_preload(&the_index, NULL) < 0)
+       if (read_index_preload(&the_index, NULL) < 0) {
+               rollback_lock_file(&index_lock);
                return error(_("git %s: failed to read the index"),
                        action_name(opts));
+       }
        refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
        if (the_index.cache_changed && index_fd >= 0) {
-               if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
+               if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK)) {
+                       rollback_lock_file(&index_lock);
                        return error(_("git %s: failed to refresh the index"),
                                action_name(opts));
+               }
        }
        rollback_lock_file(&index_lock);
        return 0;