get_patch_filename(): drop "just-numbers" hack
[gitweb.git] / builtin / log.c
index ba59110a3e9e1bcb94fa2ff40002600c00ac437d..3c6f20a2352622998a5d98dc412574838f911850 100644 (file)
@@ -34,8 +34,8 @@ static const char *fmt_patch_subject_prefix = "PATCH";
 static const char *fmt_pretty;
 
 static const char * const builtin_log_usage[] = {
-       "git log [<options>] [<since>..<until>] [[--] <path>...]\n"
-       "   or: git show [options] <object>...",
+       N_("git log [<options>] [<since>..<until>] [[--] <path>...]\n")
+       N_("   or: git show [options] <object>..."),
        NULL
 };
 
@@ -97,9 +97,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
        int quiet = 0, source = 0;
 
        const struct option builtin_log_options[] = {
-               OPT_BOOLEAN(0, "quiet", &quiet, "suppress diff output"),
-               OPT_BOOLEAN(0, "source", &source, "show source"),
-               { OPTION_CALLBACK, 0, "decorate", NULL, NULL, "decorate options",
+               OPT_BOOLEAN(0, "quiet", &quiet, N_("suppress diff output")),
+               OPT_BOOLEAN(0, "source", &source, N_("show source")),
+               { OPTION_CALLBACK, 0, "decorate", NULL, NULL, N_("decorate options"),
                  PARSE_OPT_OPTARG, decorate_callback},
                OPT_END()
        };
@@ -109,9 +109,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
                             PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
                             PARSE_OPT_KEEP_DASHDASH);
 
-       argc = setup_revisions(argc, argv, rev, opt);
        if (quiet)
                rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT;
+       argc = setup_revisions(argc, argv, rev, opt);
 
        /* Any arguments at this point are not recognized */
        if (argc > 1)
@@ -456,7 +456,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
        init_revisions(&rev, prefix);
        rev.diff = 1;
        rev.always_show_header = 1;
-       rev.no_walk = 1;
+       rev.no_walk = REVISION_WALK_NO_WALK_SORTED;
        rev.diffopt.stat_width = -1;    /* Scale to real terminal size */
 
        memset(&opt, 0, sizeof(opt));
@@ -673,7 +673,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,
                         struct rev_info *rev, int quiet)
 {
        struct strbuf filename = STRBUF_INIT;
-       int suffix_len = strlen(fmt_patch_suffix) + 1;
+       int suffix_len = strlen(rev->patch_suffix) + 1;
 
        if (output_directory) {
                strbuf_addstr(&filename, output_directory);
@@ -684,7 +684,10 @@ static int reopen_stdout(struct commit *commit, const char *subject,
                        strbuf_addch(&filename, '/');
        }
 
-       get_patch_filename(commit, subject, rev->nr, fmt_patch_suffix, &filename);
+       if (rev->numbered_files)
+               strbuf_addf(&filename, "%d", rev->nr);
+       else
+               get_patch_filename(&filename, commit, subject, rev);
 
        if (!quiet)
                fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
@@ -696,7 +699,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,
        return 0;
 }
 
-static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const char *prefix)
+static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
 {
        struct rev_info check_rev;
        struct commit *commit;
@@ -717,7 +720,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
        init_patch_ids(ids);
 
        /* given a range a..b get all patch ids for b..a */
-       init_revisions(&check_rev, prefix);
+       init_revisions(&check_rev, rev->prefix);
+       check_rev.max_parents = 1;
        o1->flags ^= UNINTERESTING;
        o2->flags ^= UNINTERESTING;
        add_pending_object(&check_rev, o1, "o1");
@@ -726,10 +730,6 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
                die(_("revision walk setup failed"));
 
        while ((commit = get_revision(&check_rev)) != NULL) {
-               /* ignore merges */
-               if (commit->parents && commit->parents->next)
-                       continue;
-
                add_commit_patch_id(commit, ids);
        }
 
@@ -771,7 +771,6 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
 }
 
 static void make_cover_letter(struct rev_info *rev, int use_stdout,
-                             int numbered, int numbered_files,
                              struct commit *origin,
                              int nr, struct commit **list, struct commit *head,
                              const char *branch_name,
@@ -794,7 +793,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        committer = git_committer_info(0);
 
        if (!use_stdout &&
-           reopen_stdout(NULL, numbered_files ? NULL : "cover-letter", rev, quiet))
+           reopen_stdout(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
                return;
 
        log_write_email_headers(rev, head, &pp.subject, &pp.after_subject,
@@ -1048,7 +1047,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        int nr = 0, total, i;
        int use_stdout = 0;
        int start_number = -1;
-       int numbered_files = 0;         /* _just_ numbers */
+       int just_numbers = 0;
        int ignore_if_in_upstream = 0;
        int cover_letter = 0;
        int boundary_count = 0;
@@ -1073,7 +1072,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                            N_("print patches to standard out")),
                OPT_BOOLEAN(0, "cover-letter", &cover_letter,
                            N_("generate a cover letter")),
-               OPT_BOOLEAN(0, "numbered-files", &numbered_files,
+               OPT_BOOLEAN(0, "numbered-files", &just_numbers,
                            N_("use simple number sequence for output file names")),
                OPT_STRING(0, "suffix", &fmt_patch_suffix, N_("sfx"),
                            N_("use <sfx> instead of '.patch'")),
@@ -1306,7 +1305,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
                                return 0;
                }
-               get_patch_ids(&rev, &ids, prefix);
+               get_patch_ids(&rev, &ids);
        }
 
        if (!use_stdout)
@@ -1341,12 +1340,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                const char *msgid = clean_message_id(in_reply_to);
                string_list_append(rev.ref_message_ids, msgid);
        }
-       rev.numbered_files = numbered_files;
+       rev.numbered_files = just_numbers;
        rev.patch_suffix = fmt_patch_suffix;
        if (cover_letter) {
                if (thread)
                        gen_message_id(&rev, "cover");
-               make_cover_letter(&rev, use_stdout, numbered, numbered_files,
+               make_cover_letter(&rev, use_stdout,
                                  origin, nr, list, head, branch_name, quiet);
                total++;
                start_number--;
@@ -1393,7 +1392,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                }
 
                if (!use_stdout &&
-                   reopen_stdout(numbered_files ? NULL : commit, NULL, &rev, quiet))
+                   reopen_stdout(rev.numbered_files ? NULL : commit, NULL, &rev, quiet))
                        die(_("Failed to create output files"));
                shown = log_tree_commit(&rev, commit);
                free(commit->buffer);
@@ -1508,10 +1507,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
        }
 
        init_revisions(&revs, prefix);
-       revs.diff = 1;
-       revs.combine_merges = 0;
-       revs.ignore_merges = 1;
-       DIFF_OPT_SET(&revs.diffopt, RECURSIVE);
+       revs.max_parents = 1;
 
        if (add_pending_commit(head, &revs, 0))
                die(_("Unknown commit %s"), head);
@@ -1525,7 +1521,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
                        return 0;
        }
 
-       get_patch_ids(&revs, &ids, prefix);
+       get_patch_ids(&revs, &ids);
 
        if (limit && add_pending_commit(limit, &revs, UNINTERESTING))
                die(_("Unknown commit %s"), limit);
@@ -1534,10 +1530,6 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
        if (prepare_revision_walk(&revs))
                die(_("revision walk setup failed"));
        while ((commit = get_revision(&revs)) != NULL) {
-               /* ignore merges */
-               if (commit->parents && commit->parents->next)
-                       continue;
-
                commit_list_insert(commit, &list);
        }