]> git.ipfire.org Git - thirdparty/git.git/blobdiff - revision.c
Merge branch 'jk/leakfix'
[thirdparty/git.git] / revision.c
index 5ed86e45241aaaf26bf0010c9f6c95e41be9b92c..96630e31867dd6987b8d5447bcaedb777303679d 100644 (file)
@@ -23,7 +23,7 @@
 #include "bisect.h"
 #include "packfile.h"
 #include "worktree.h"
-#include "argv-array.h"
+#include "strvec.h"
 #include "commit-reach.h"
 #include "commit-graph.h"
 #include "prio-queue.h"
@@ -702,6 +702,7 @@ static void prepare_to_use_bloom_filter(struct rev_info *revs)
        len = strlen(path);
        if (!len) {
                revs->bloom_filter_settings = NULL;
+               free(path_alloc);
                return;
        }
 
@@ -1814,7 +1815,7 @@ void repo_init_revisions(struct repository *r,
 
        revs->repo = r;
        revs->abbrev = DEFAULT_ABBREV;
-       revs->ignore_merges = 1;
+       revs->ignore_merges = -1;
        revs->simplify_history = 1;
        revs->pruning.repo = r;
        revs->pruning.flags.recursive = 1;
@@ -2092,14 +2093,14 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
 }
 
 static void read_pathspec_from_stdin(struct strbuf *sb,
-                                    struct argv_array *prune)
+                                    struct strvec *prune)
 {
        while (strbuf_getline(sb, stdin) != EOF)
-               argv_array_push(prune, sb->buf);
+               strvec_push(prune, sb->buf);
 }
 
 static void read_revisions_from_stdin(struct rev_info *revs,
-                                     struct argv_array *prune)
+                                     struct strvec *prune)
 {
        struct strbuf sb;
        int seen_dashdash = 0;
@@ -2334,7 +2335,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
        } else if (!strcmp(arg, "--unpacked")) {
                revs->unpacked = 1;
        } else if (starts_with(arg, "--unpacked=")) {
-               die("--unpacked=<packfile> no longer supported.");
+               die(_("--unpacked=<packfile> no longer supported"));
        } else if (!strcmp(arg, "-r")) {
                revs->diff = 1;
                revs->diffopt.flags.recursive = 1;
@@ -2344,6 +2345,15 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->diffopt.flags.tree_in_recursive = 1;
        } else if (!strcmp(arg, "-m")) {
                revs->ignore_merges = 0;
+       } else if ((argcount = parse_long_opt("diff-merges", argv, &optarg))) {
+               if (!strcmp(optarg, "off")) {
+                       revs->ignore_merges = 1;
+               } else {
+                       die(_("unknown value for --diff-merges: %s"), optarg);
+               }
+               return argcount;
+       } else if (!strcmp(arg, "--no-diff-merges")) {
+               revs->ignore_merges = 1;
        } else if (!strcmp(arg, "-c")) {
                revs->diff = 1;
                revs->dense_combined_merges = 0;
@@ -2694,7 +2704,7 @@ static void NORETURN diagnose_missing_default(const char *def)
 int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
 {
        int i, flags, left, seen_dashdash, got_rev_arg = 0, revarg_opt;
-       struct argv_array prune_data = ARGV_ARRAY_INIT;
+       struct strvec prune_data = STRVEC_INIT;
        const char *submodule = NULL;
        int seen_end_of_options = 0;
 
@@ -2713,7 +2723,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                        argv[i] = NULL;
                        argc = i;
                        if (argv[i + 1])
-                               argv_array_pushv(&prune_data, argv + i + 1);
+                               strvec_pushv(&prune_data, argv + i + 1);
                        seen_dashdash = 1;
                        break;
                }
@@ -2779,14 +2789,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                        for (j = i; j < argc; j++)
                                verify_filename(revs->prefix, argv[j], j == i);
 
-                       argv_array_pushv(&prune_data, argv + i);
+                       strvec_pushv(&prune_data, argv + i);
                        break;
                }
                else
                        got_rev_arg = 1;
        }
 
-       if (prune_data.argc) {
+       if (prune_data.nr) {
                /*
                 * If we need to introduce the magic "a lone ':' means no
                 * pathspec whatsoever", here is the place to do so.
@@ -2802,9 +2812,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                 * }
                 */
                parse_pathspec(&revs->prune_data, 0, 0,
-                              revs->prefix, prune_data.argv);
+                              revs->prefix, prune_data.v);
        }
-       argv_array_clear(&prune_data);
+       strvec_clear(&prune_data);
 
        if (revs->def == NULL)
                revs->def = opt ? opt->def : NULL;
@@ -2853,8 +2863,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                        copy_pathspec(&revs->diffopt.pathspec,
                                      &revs->prune_data);
        }
-       if (revs->combine_merges)
+       if (revs->combine_merges && revs->ignore_merges < 0)
                revs->ignore_merges = 0;
+       if (revs->ignore_merges < 0)
+               revs->ignore_merges = 1;
        if (revs->combined_all_paths && !revs->combine_merges)
                die("--combined-all-paths makes no sense without -c or --cc");
 
@@ -2888,9 +2900,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
        if (!revs->reflog_info && revs->grep_filter.use_reflog_filter)
                die("cannot use --grep-reflog without --walk-reflogs");
 
-       if (revs->first_parent_only && revs->bisect)
-               die(_("--first-parent is incompatible with --bisect"));
-
        if (revs->line_level_traverse &&
            (revs->diffopt.output_format & ~(DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT)))
                die(_("-L does not yet support diff formats besides -p and -s"));