Merge branch 'master' of https://github.com/Softcatala/git-po
[gitweb.git] / builtin / log.c
index 1dbb9d829bffcb25739737783c4fd4fd734f5940..e8e51068bd903c01e12207637d59d80ea940bf2d 100644 (file)
@@ -107,6 +107,8 @@ static int log_line_range_callback(const struct option *option, const char *arg,
 {
        struct line_opt_callback_data *data = option->value;
 
+       BUG_ON_OPT_NEG(unset);
+
        if (!arg)
                return -1;
 
@@ -118,7 +120,7 @@ static int log_line_range_callback(const struct option *option, const char *arg,
 
 static void init_log_defaults(void)
 {
-       init_grep_defaults();
+       init_grep_defaults(the_repository);
        init_diff_ui_defaults();
 
        decoration_style = auto_decoration_style();
@@ -470,7 +472,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
        init_log_defaults();
        git_config(git_log_config, NULL);
 
-       init_revisions(&rev, prefix);
+       repo_init_revisions(the_repository, &rev, prefix);
        rev.diff = 1;
        rev.simplify_history = 0;
        memset(&opt, 0, sizeof(opt));
@@ -510,7 +512,8 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
                                 &oidc, &obj_context))
                die(_("Not a valid object name %s"), obj_name);
        if (!obj_context.path ||
-           !textconv_object(obj_context.path, obj_context.mode, &oidc, 1, &buf, &size)) {
+           !textconv_object(the_repository, obj_context.path,
+                            obj_context.mode, &oidc, 1, &buf, &size)) {
                free(obj_context.path);
                return stream_blob_to_fd(1, oid, NULL, 0);
        }
@@ -587,7 +590,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
        git_config(git_log_config, NULL);
 
        memset(&match_all, 0, sizeof(match_all));
-       init_revisions(&rev, prefix);
+       repo_init_revisions(the_repository, &rev, prefix);
        rev.diff = 1;
        rev.always_show_header = 1;
        rev.no_walk = REVISION_WALK_NO_WALK_SORTED;
@@ -667,7 +670,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
        init_log_defaults();
        git_config(git_log_config, NULL);
 
-       init_revisions(&rev, prefix);
+       repo_init_revisions(the_repository, &rev, prefix);
        init_reflog_walk(&rev.reflog_info);
        rev.verbose_header = 1;
        memset(&opt, 0, sizeof(opt));
@@ -706,7 +709,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
        init_log_defaults();
        git_config(git_log_config, NULL);
 
-       init_revisions(&rev, prefix);
+       repo_init_revisions(the_repository, &rev, prefix);
        rev.always_show_header = 1;
        memset(&opt, 0, sizeof(opt));
        opt.def = "HEAD";
@@ -916,10 +919,10 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
        if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
                die(_("Not a range."));
 
-       init_patch_ids(ids);
+       init_patch_ids(the_repository, ids);
 
        /* given a range a..b get all patch ids for b..a */
-       init_revisions(&check_rev, rev->prefix);
+       repo_init_revisions(the_repository, &check_rev, rev->prefix);
        check_rev.max_parents = 1;
        o1->flags ^= UNINTERESTING;
        o2->flags ^= UNINTERESTING;
@@ -1008,8 +1011,6 @@ static void show_diffstat(struct rev_info *rev,
 
        memcpy(&opts, &rev->diffopt, sizeof(opts));
        opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
-       opts.stat_width = MAIL_DEFAULT_WRAP;
-
        diff_setup_done(&opts);
 
        diff_tree_oid(get_commit_tree_oid(origin),
@@ -1093,9 +1094,18 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        }
 
        if (rev->rdiff1) {
+               /*
+                * Pass minimum required diff-options to range-diff; others
+                * can be added later if deemed desirable.
+                */
+               struct diff_options opts;
+               diff_setup(&opts);
+               opts.file = rev->diffopt.file;
+               opts.use_color = rev->diffopt.use_color;
+               diff_setup_done(&opts);
                fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
                show_range_diff(rev->rdiff1, rev->rdiff2,
-                               rev->creation_factor, 1, &rev->diffopt);
+                               rev->creation_factor, 1, &opts);
        }
 }
 
@@ -1150,6 +1160,8 @@ static int keep_subject = 0;
 
 static int keep_callback(const struct option *opt, const char *arg, int unset)
 {
+       BUG_ON_OPT_NEG(unset);
+       BUG_ON_OPT_ARG(arg);
        ((struct rev_info *)opt->value)->total = -1;
        keep_subject = 1;
        return 0;
@@ -1160,6 +1172,7 @@ static int subject_prefix = 0;
 static int subject_prefix_callback(const struct option *opt, const char *arg,
                            int unset)
 {
+       BUG_ON_OPT_NEG(unset);
        subject_prefix = 1;
        ((struct rev_info *)opt->value)->subject_prefix = arg;
        return 0;
@@ -1167,6 +1180,8 @@ static int subject_prefix_callback(const struct option *opt, const char *arg,
 
 static int rfc_callback(const struct option *opt, const char *arg, int unset)
 {
+       BUG_ON_OPT_NEG(unset);
+       BUG_ON_OPT_ARG(arg);
        return subject_prefix_callback(opt, "RFC PATCH", unset);
 }
 
@@ -1175,6 +1190,7 @@ static int numbered_cmdline_opt = 0;
 static int numbered_callback(const struct option *opt, const char *arg,
                             int unset)
 {
+       BUG_ON_OPT_ARG(arg);
        *(int *)opt->value = numbered_cmdline_opt = unset ? 0 : 1;
        if (unset)
                auto_number =  0;
@@ -1184,6 +1200,7 @@ static int numbered_callback(const struct option *opt, const char *arg,
 static int no_numbered_callback(const struct option *opt, const char *arg,
                                int unset)
 {
+       BUG_ON_OPT_NEG(unset);
        return numbered_callback(opt, arg, 1);
 }
 
@@ -1191,6 +1208,7 @@ static int output_directory_callback(const struct option *opt, const char *arg,
                              int unset)
 {
        const char **dir = (const char **)opt->value;
+       BUG_ON_OPT_NEG(unset);
        if (*dir)
                die(_("Two output directories?"));
        *dir = arg;
@@ -1377,13 +1395,13 @@ static void prepare_bases(struct base_tree_info *bases,
                return;
 
        init_commit_base(&commit_base);
-       diff_setup(&diffopt);
+       repo_diff_setup(the_repository, &diffopt);
        diffopt.flags.recursive = 1;
        diff_setup_done(&diffopt);
 
        oidcpy(&bases->base_commit, &base->object.oid);
 
-       init_revisions(&revs, NULL);
+       repo_init_revisions(the_repository, &revs, NULL);
        revs.max_parents = 1;
        revs.topo_order = 1;
        for (i = 0; i < total; i++) {
@@ -1507,7 +1525,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                            PARSE_OPT_NOARG, numbered_callback },
                { OPTION_CALLBACK, 'N', "no-numbered", &numbered, NULL,
                            N_("use [PATCH] even with multiple patches"),
-                           PARSE_OPT_NOARG, no_numbered_callback },
+                           PARSE_OPT_NOARG | PARSE_OPT_NONEG, no_numbered_callback },
                OPT_BOOL('s', "signoff", &do_signoff, N_("add Signed-off-by:")),
                OPT_BOOL(0, "stdout", &use_stdout,
                            N_("print patches to standard out")),
@@ -1588,7 +1606,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        extra_cc.strdup_strings = 1;
        init_log_defaults();
        git_config(git_format_config, NULL);
-       init_revisions(&rev, prefix);
+       repo_init_revisions(the_repository, &rev, prefix);
        rev.commit_format = CMIT_FMT_EMAIL;
        rev.expand_tabs_in_log_default = 0;
        rev.verbose_header = 1;
@@ -2038,7 +2056,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
                }
        }
 
-       init_revisions(&revs, prefix);
+       repo_init_revisions(the_repository, &revs, prefix);
        revs.max_parents = 1;
 
        if (add_pending_commit(head, &revs, 0))