diff-lib: convert do_diff_cache to struct object_id
[gitweb.git] / builtin / am.c
index f08b7e6626021e425e4712763bee2236b8eab47b..200d9dbed4644a87b2ba5ffc1d77585a4f0cd157 100644 (file)
@@ -134,17 +134,15 @@ struct am_state {
 };
 
 /**
- * Initializes am_state with the default values. The state directory is set to
- * dir.
+ * Initializes am_state with the default values.
  */
-static void am_state_init(struct am_state *state, const char *dir)
+static void am_state_init(struct am_state *state)
 {
        int gpgsign;
 
        memset(state, 0, sizeof(*state));
 
-       assert(dir);
-       state->dir = xstrdup(dir);
+       state->dir = git_pathdup("rebase-apply");
 
        state->prec = 4;
 
@@ -1147,7 +1145,7 @@ static int index_has_changes(struct strbuf *sb)
                DIFF_OPT_SET(&opt, EXIT_WITH_STATUS);
                if (!sb)
                        DIFF_OPT_SET(&opt, QUICK);
-               do_diff_cache(head.hash, &opt);
+               do_diff_cache(&head, &opt);
                diffcore_std(&opt);
                for (i = 0; sb && i < diff_queued_diff.nr; i++) {
                        if (i)
@@ -1455,9 +1453,9 @@ static void write_index_patch(const struct am_state *state)
        FILE *fp;
 
        if (!get_sha1_tree("HEAD", head.hash))
-               tree = lookup_tree(head.hash);
+               tree = lookup_tree(&head);
        else
-               tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
+               tree = lookup_tree(&empty_tree_oid);
 
        fp = xfopen(am_path(state, "patch"), "w");
        init_revisions(&rev_info, NULL);
@@ -1490,7 +1488,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
        if (get_mail_commit_oid(&commit_oid, mail) < 0)
                die(_("could not parse %s"), mail);
 
-       commit = lookup_commit_or_die(commit_oid.hash, mail);
+       commit = lookup_commit_or_die(&commit_oid, mail);
 
        get_commit_info(state, commit);
 
@@ -1620,7 +1618,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
                init_revisions(&rev_info, NULL);
                rev_info.diffopt.output_format = DIFF_FORMAT_NAME_STATUS;
                diff_opt_parse(&rev_info.diffopt, &diff_filter_str, 1, rev_info.prefix);
-               add_pending_sha1(&rev_info, "HEAD", our_tree.hash, 0);
+               add_pending_oid(&rev_info, "HEAD", &our_tree, 0);
                diff_setup_done(&rev_info.diffopt);
                run_diff_index(&rev_info, 1);
        }
@@ -1685,7 +1683,7 @@ static void do_commit(const struct am_state *state)
 
        if (!get_sha1_commit("HEAD", parent.hash)) {
                old_oid = &parent;
-               commit_list_insert(lookup_commit(parent.hash), &parents);
+               commit_list_insert(lookup_commit(&parent), &parents);
        } else {
                old_oid = NULL;
                say(state, stderr, _("applying to an empty history"));
@@ -2323,7 +2321,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 
        git_config(git_am_config, NULL);
 
-       am_state_init(&state, git_path("rebase-apply"));
+       am_state_init(&state);
 
        in_progress = am_in_progress(&state);
        if (in_progress)