]> git.ipfire.org Git - thirdparty/git.git/blobdiff - revision.c
strmap: enable allocations to come from a mem_pool
[thirdparty/git.git] / revision.c
index 08c2ad23af668a42cca30a5cebfcc2feee1ce895..f27649d45d1dde74e67d75310affd4d78f504bc5 100644 (file)
@@ -139,7 +139,7 @@ static void paths_and_oids_clear(struct hashmap *map)
                free(entry->path);
        }
 
-       hashmap_free_entries(map, struct path_and_oids_entry, ent);
+       hashmap_clear_and_free(map, struct path_and_oids_entry, ent);
 }
 
 static void paths_and_oids_insert(struct hashmap *map,
@@ -315,13 +315,14 @@ static void add_pending_object_with_path(struct rev_info *revs,
                                         const char *name, unsigned mode,
                                         const char *path)
 {
+       struct interpret_branch_name_options options = { 0 };
        if (!obj)
                return;
        if (revs->no_walk && (obj->flags & UNINTERESTING))
                revs->no_walk = 0;
        if (revs->reflog_info && obj->type == OBJ_COMMIT) {
                struct strbuf buf = STRBUF_INIT;
-               int len = interpret_branch_name(name, 0, &buf, 0);
+               int len = interpret_branch_name(name, 0, &buf, &options);
 
                if (0 < len && name[len] && buf.len)
                        strbuf_addstr(&buf, name + len);
@@ -439,7 +440,7 @@ static struct commit *handle_commit(struct rev_info *revs,
        if (object->type == OBJ_COMMIT) {
                struct commit *commit = (struct commit *)object;
 
-               if (parse_commit(commit) < 0)
+               if (repo_parse_commit(revs->repo, commit) < 0)
                        die("unable to parse commit %s", name);
                if (flags & UNINTERESTING) {
                        mark_parents_uninteresting(commit);
@@ -680,10 +681,7 @@ static void prepare_to_use_bloom_filter(struct rev_info *revs)
 
        repo_parse_commit(revs->repo, revs->commits->item);
 
-       if (!revs->repo->objects->commit_graph)
-               return;
-
-       revs->bloom_filter_settings = revs->repo->objects->commit_graph->bloom_filter_settings;
+       revs->bloom_filter_settings = get_bloom_filter_settings(revs->repo);
        if (!revs->bloom_filter_settings)
                return;
 
@@ -754,7 +752,7 @@ static int check_maybe_different_in_bloom_filter(struct rev_info *revs,
        if (commit_graph_generation(commit) == GENERATION_NUMBER_INFINITY)
                return -1;
 
-       filter = get_bloom_filter(revs->repo, commit, 0);
+       filter = get_bloom_filter(revs->repo, commit);
 
        if (!filter) {
                count_bloom_filter_not_present++;
@@ -1012,7 +1010,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
                                        ts->treesame[0] = 1;
                        }
                }
-               if (parse_commit(p) < 0)
+               if (repo_parse_commit(revs->repo, p) < 0)
                        die("cannot simplify commit %s (because of %s)",
                            oid_to_hex(&commit->object.oid),
                            oid_to_hex(&p->object.oid));
@@ -1057,7 +1055,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
                                 * IOW, we pretend this parent is a
                                 * "root" commit.
                                 */
-                               if (parse_commit(p) < 0)
+                               if (repo_parse_commit(revs->repo, p) < 0)
                                        die("cannot simplify commit %s (invalid %s)",
                                            oid_to_hex(&commit->object.oid),
                                            oid_to_hex(&p->object.oid));
@@ -1125,7 +1123,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
                        parent = parent->next;
                        if (p)
                                p->object.flags |= UNINTERESTING;
-                       if (parse_commit_gently(p, 1) < 0)
+                       if (repo_parse_commit_gently(revs->repo, p, 1) < 0)
                                continue;
                        if (p->parents)
                                mark_parents_uninteresting(p);
@@ -1156,7 +1154,7 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
                struct commit *p = parent->item;
                int gently = revs->ignore_missing_links ||
                             revs->exclude_promisor_objects;
-               if (parse_commit_gently(p, gently) < 0) {
+               if (repo_parse_commit_gently(revs->repo, p, gently) < 0) {
                        if (revs->exclude_promisor_objects &&
                            is_promisor_object(&p->object.oid)) {
                                if (revs->first_parent_only)
@@ -2352,7 +2350,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->diffopt.flags.recursive = 1;
                revs->diffopt.flags.tree_in_recursive = 1;
        } else if (!strcmp(arg, "-m")) {
+               /*
+                * To "diff-index", "-m" means "match missing", and to the "log"
+                * family of commands, it means "show full diff for merges". Set
+                * both fields appropriately.
+                */
                revs->ignore_merges = 0;
+               revs->match_missing = 1;
        } else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
                if (!strcmp(optarg, "off")) {
                        revs->ignore_merges = 1;
@@ -2576,8 +2580,8 @@ static int for_each_good_bisect_ref(struct ref_store *refs, each_ref_fn fn, void
 }
 
 static int handle_revision_pseudo_opt(const char *submodule,
-                               struct rev_info *revs,
-                               int argc, const char **argv, int *flags)
+                                     struct rev_info *revs,
+                                     const char **argv, int *flags)
 {
        const char *arg = argv[0];
        const char *optarg;
@@ -2748,7 +2752,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                        int opts;
 
                        opts = handle_revision_pseudo_opt(submodule,
-                                               revs, argc - i, argv + i,
+                                               revs, argv + i,
                                                &flags);
                        if (opts > 0) {
                                i += opts - 1;
@@ -3330,7 +3334,7 @@ static void explore_walk_step(struct rev_info *revs)
        if (!c)
                return;
 
-       if (parse_commit_gently(c, 1) < 0)
+       if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
                return;
 
        if (revs->sort_order == REV_SORT_BY_AUTHOR_DATE)
@@ -3368,7 +3372,7 @@ static void indegree_walk_step(struct rev_info *revs)
        if (!c)
                return;
 
-       if (parse_commit_gently(c, 1) < 0)
+       if (repo_parse_commit_gently(revs->repo, c, 1) < 0)
                return;
 
        explore_to_depth(revs, commit_graph_generation(c));
@@ -3450,7 +3454,7 @@ static void init_topo_walk(struct rev_info *revs)
                struct commit *c = list->item;
                uint32_t generation;
 
-               if (parse_commit_gently(c, 1))
+               if (repo_parse_commit_gently(revs->repo, c, 1))
                        continue;
 
                test_flag_and_insert(&info->explore_queue, c, TOPO_WALK_EXPLORED);
@@ -3514,7 +3518,7 @@ static void expand_topo_walk(struct rev_info *revs, struct commit *commit)
                if (parent->object.flags & UNINTERESTING)
                        continue;
 
-               if (parse_commit_gently(parent, 1) < 0)
+               if (repo_parse_commit_gently(revs->repo, parent, 1) < 0)
                        continue;
 
                generation = commit_graph_generation(parent);