]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/am.c
Merge branch 'bw/format-patch-o-create-leading-dirs'
[thirdparty/git.git] / builtin / am.c
index ee7305eaa663ae434b44ed567661b5fd81dbe817..8181c2aef39fbe04e797d521d757e3ac5628fd00 100644 (file)
@@ -24,7 +24,6 @@
 #include "sequencer.h"
 #include "revision.h"
 #include "merge-recursive.h"
-#include "revision.h"
 #include "log-tree.h"
 #include "notes-utils.h"
 #include "rerere.h"
@@ -1071,19 +1070,6 @@ static const char *msgnum(const struct am_state *state)
        return sb.buf;
 }
 
-/**
- * Refresh and write index.
- */
-static void refresh_and_write_cache(void)
-{
-       struct lock_file lock_file = LOCK_INIT;
-
-       hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
-       refresh_cache(REFRESH_QUIET);
-       if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
-               die(_("unable to write index file"));
-}
-
 /**
  * Dies with a user-friendly message on how to proceed after resolving the
  * problem. This message can be overridden with state->resolvemsg.
@@ -1540,7 +1526,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
        o.branch1 = "HEAD";
        their_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg);
        o.branch2 = their_tree_name;
-       o.detect_directory_renames = 0;
+       o.detect_directory_renames = MERGE_DIRECTORY_RENAMES_NONE;
 
        if (state->quiet)
                o.verbosity = 0;
@@ -1705,7 +1691,8 @@ static void am_run(struct am_state *state, int resume)
 
        unlink(am_path(state, "dirtyindex"));
 
-       refresh_and_write_cache();
+       if (refresh_and_write_cache(REFRESH_QUIET, 0, 0) < 0)
+               die(_("unable to write index file"));
 
        if (repo_index_has_changes(the_repository, NULL, &sb)) {
                write_state_bool(state, "dirtyindex", 1);