]> git.ipfire.org Git - thirdparty/git.git/blobdiff - revision.c
object-name.h: move declarations for object-name.c functions from cache.h
[thirdparty/git.git] / revision.c
index 439e34a7c51803335c4f5677f67058b633c46339..7438b50e267f5ca436724447d01f215b2e67b168 100644 (file)
@@ -1,5 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
 #include "config.h"
+#include "environment.h"
+#include "gettext.h"
+#include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
@@ -25,7 +30,9 @@
 #include "bisect.h"
 #include "packfile.h"
 #include "worktree.h"
+#include "setup.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "commit-reach.h"
 #include "commit-graph.h"
 #include "prio-queue.h"
@@ -324,7 +331,8 @@ static void add_pending_object_with_path(struct rev_info *revs,
        if (revs->reflog_info && obj->type == OBJ_COMMIT) {
                struct strbuf buf = STRBUF_INIT;
                size_t namelen = strlen(name);
-               int len = interpret_branch_name(name, namelen, &buf, &options);
+               int len = repo_interpret_branch_name(the_repository, name,
+                                                    namelen, &buf, &options);
 
                if (0 < len && len < namelen && buf.len)
                        strbuf_addstr(&buf, name + len);
@@ -354,7 +362,7 @@ void add_head_to_pending(struct rev_info *revs)
 {
        struct object_id oid;
        struct object *obj;
-       if (get_oid("HEAD", &oid))
+       if (repo_get_oid(the_repository, "HEAD", &oid))
                return;
        obj = parse_object(revs->repo, &oid);
        if (!obj)
@@ -600,10 +608,12 @@ static struct commit *one_relevant_parent(const struct rev_info *revs,
 static int tree_difference = REV_TREE_SAME;
 
 static void file_add_remove(struct diff_options *options,
-                   int addremove, unsigned mode,
-                   const struct object_id *oid,
-                   int oid_valid,
-                   const char *fullpath, unsigned dirty_submodule)
+                   int addremove,
+                   unsigned mode UNUSED,
+                   const struct object_id *oid UNUSED,
+                   int oid_valid UNUSED,
+                   const char *fullpath UNUSED,
+                   unsigned dirty_submodule UNUSED)
 {
        int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;
        struct rev_info *revs = options->change_fn_data;
@@ -614,12 +624,15 @@ static void file_add_remove(struct diff_options *options,
 }
 
 static void file_change(struct diff_options *options,
-                unsigned old_mode, unsigned new_mode,
-                const struct object_id *old_oid,
-                const struct object_id *new_oid,
-                int old_oid_valid, int new_oid_valid,
-                const char *fullpath,
-                unsigned old_dirty_submodule, unsigned new_dirty_submodule)
+                unsigned old_mode UNUSED,
+                unsigned new_mode UNUSED,
+                const struct object_id *old_oid UNUSED,
+                const struct object_id *new_oid UNUSED,
+                int old_oid_valid UNUSED,
+                int new_oid_valid UNUSED,
+                const char *fullpath UNUSED,
+                unsigned old_dirty_submodule UNUSED,
+                unsigned new_dirty_submodule UNUSED)
 {
        tree_difference = REV_TREE_DIFFERENT;
        options->flags.has_changes = 1;
@@ -772,8 +785,8 @@ static int check_maybe_different_in_bloom_filter(struct rev_info *revs,
 static int rev_compare_tree(struct rev_info *revs,
                            struct commit *parent, struct commit *commit, int nth_parent)
 {
-       struct tree *t1 = get_commit_tree(parent);
-       struct tree *t2 = get_commit_tree(commit);
+       struct tree *t1 = repo_get_commit_tree(the_repository, parent);
+       struct tree *t2 = repo_get_commit_tree(the_repository, commit);
        int bloom_ret = 1;
 
        if (!t1)
@@ -819,7 +832,7 @@ static int rev_compare_tree(struct rev_info *revs,
 
 static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
 {
-       struct tree *t1 = get_commit_tree(commit);
+       struct tree *t1 = repo_get_commit_tree(the_repository, commit);
 
        if (!t1)
                return 0;
@@ -957,7 +970,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
        if (!revs->prune)
                return;
 
-       if (!get_commit_tree(commit))
+       if (!repo_get_commit_tree(the_repository, commit))
                return;
 
        if (!commit->parents) {
@@ -1569,7 +1582,8 @@ void exclude_hidden_refs(struct ref_exclusions *exclusions, const char *section)
 {
        struct exclude_hidden_refs_cb cb;
 
-       if (strcmp(section, "receive") && strcmp(section, "uploadpack"))
+       if (strcmp(section, "fetch") && strcmp(section, "receive") &&
+                       strcmp(section, "uploadpack"))
                die(_("unsupported section for hidden refs: %s"), section);
 
        if (exclusions->hidden_refs_configured)
@@ -1808,7 +1822,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
        worktrees = get_worktrees();
        for (p = worktrees; *p; p++) {
                struct worktree *wt = *p;
-               struct index_state istate = { NULL };
+               struct index_state istate = INDEX_STATE_INIT(revs->repo);
 
                if (wt->is_current)
                        continue; /* current index already taken care of */
@@ -1862,7 +1876,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
                flags ^= UNINTERESTING | BOTTOM;
                arg++;
        }
-       if (get_oid_committish(arg, &oid))
+       if (repo_get_oid_committish(the_repository, arg, &oid))
                return 0;
        while (1) {
                it = get_reference(revs, arg, &oid, 0);
@@ -1943,15 +1957,15 @@ static void prepare_show_merge(struct rev_info *revs)
        int i, prune_num = 1; /* counting terminating NULL */
        struct index_state *istate = revs->repo->index;
 
-       if (get_oid("HEAD", &oid))
+       if (repo_get_oid(the_repository, "HEAD", &oid))
                die("--merge without HEAD?");
        head = lookup_commit_or_die(&oid, "HEAD");
-       if (get_oid("MERGE_HEAD", &oid))
+       if (repo_get_oid(the_repository, "MERGE_HEAD", &oid))
                die("--merge without MERGE_HEAD?");
        other = lookup_commit_or_die(&oid, "MERGE_HEAD");
        add_pending_object(revs, &head->object, "HEAD");
        add_pending_object(revs, &other->object, "MERGE_HEAD");
-       bases = get_merge_bases(head, other);
+       bases = repo_get_merge_bases(the_repository, head, other);
        add_rev_cmdline_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING | BOTTOM);
        add_pending_commit_list(revs, bases, UNINTERESTING | BOTTOM);
        free_commit_list(bases);
@@ -2046,7 +2060,7 @@ static int handle_dotdot_1(const char *arg, char *dotdot,
                if (!a || !b)
                        return dotdot_missing(arg, dotdot, revs, symmetric);
 
-               exclude = get_merge_bases(a, b);
+               exclude = repo_get_merge_bases(the_repository, a, b);
                add_rev_cmdline_list(revs, exclude, REV_CMD_MERGE_BASE,
                                     flags_exclude);
                add_pending_commit_list(revs, exclude, flags_exclude);
@@ -3054,6 +3068,7 @@ void release_revisions(struct rev_info *revs)
        date_mode_release(&revs->date_mode);
        release_revisions_mailmap(revs->mailmap);
        free_grep_patterns(&revs->grep_filter);
+       graph_clear(revs->graph);
        /* TODO (need to handle "no_free"): diff_free(&revs->diffopt) */
        diff_free(&revs->pruning);
        reflog_walk_info_release(revs->reflog_info);
@@ -3434,8 +3449,8 @@ void reset_revision_walk(void)
 }
 
 static int mark_uninteresting(const struct object_id *oid,
-                             struct packed_git *pack,
-                             uint32_t pos,
+                             struct packed_git *pack UNUSED,
+                             uint32_t pos UNUSED,
                              void *cb)
 {
        struct rev_info *revs = cb;
@@ -3871,7 +3886,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
         * in it.
         */
        encoding = get_log_output_encoding();
-       message = logmsg_reencode(commit, NULL, encoding);
+       message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
 
        /* Copy the commit to temporary if we are using "fake" headers */
        if (buf.len)
@@ -3907,7 +3922,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
                retval = grep_buffer(&opt->grep_filter,
                                     (char *)message, strlen(message));
        strbuf_release(&buf);
-       unuse_commit_buffer(commit, message);
+       repo_unuse_commit_buffer(the_repository, commit, message);
        return retval;
 }
 
@@ -4153,7 +4168,7 @@ static struct commit *get_revision_1(struct rev_info *revs)
  * Return true for entries that have not yet been shown.  (This is an
  * object_array_each_func_t.)
  */
-static int entry_unshown(struct object_array_entry *entry, void *cb_data_unused)
+static int entry_unshown(struct object_array_entry *entry, void *cb_data UNUSED)
 {
        return !(entry->item->flags & SHOWN);
 }