blob: allow lookup_blob to handle arbitrary repositories
[gitweb.git] / builtin / am.c
index 2fc2d1e82c5ead598476964329b555e38de9a495..b6eeb46c4b65aefbc83b25d11d2ea28646990137 100644 (file)
@@ -32,6 +32,7 @@
 #include "apply.h"
 #include "string-list.h"
 #include "packfile.h"
+#include "repository.h"
 
 /**
  * Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -1400,9 +1401,10 @@ static void write_index_patch(const struct am_state *state)
        FILE *fp;
 
        if (!get_oid_tree("HEAD", &head))
-               tree = lookup_tree(&head);
+               tree = lookup_tree(the_repository, &head);
        else
-               tree = lookup_tree(the_hash_algo->empty_tree);
+               tree = lookup_tree(the_repository,
+                                  the_repository->hash_algo->empty_tree);
 
        fp = xfopen(am_path(state, "patch"), "w");
        init_revisions(&rev_info, NULL);
@@ -1631,7 +1633,8 @@ static void do_commit(const struct am_state *state)
 
        if (!get_oid_commit("HEAD", &parent)) {
                old_oid = &parent;
-               commit_list_insert(lookup_commit(&parent), &parents);
+               commit_list_insert(lookup_commit(the_repository, &parent),
+                                  &parents);
        } else {
                old_oid = NULL;
                say(state, stderr, _("applying to an empty history"));
@@ -1827,15 +1830,11 @@ static void am_run(struct am_state *state, int resume)
                }
 
                if (apply_status) {
-                       int advice_amworkdir = 1;
-
                        printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
                                linelen(state->msg), state->msg);
 
-                       git_config_get_bool("advice.amworkdir", &advice_amworkdir);
-
                        if (advice_amworkdir)
-                               printf_ln(_("Use 'git am --show-current-patch' to see the failed patch"));
+                               advise(_("Use 'git am --show-current-patch' to see the failed patch"));
 
                        die_user_resolve(state);
                }