Code

Merge branch 'cn/format-patch-quiet' into maint
authorJunio C Hamano <gitster@pobox.com>
Sun, 15 May 2011 23:10:49 +0000 (16:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 15 May 2011 23:10:49 +0000 (16:10 -0700)
* cn/format-patch-quiet:
  format-patch: document --quiet option
  format-patch: don't pass on the --quiet flag

1  2 
builtin/log.c

diff --combined builtin/log.c
index 916019c630445f0258be1f409bdaf5de9863dae8,691d5f0dff39378e4f3746f8a05e989dc9e4a561..c6dce9b8950410b08e13c11aa940404a7fcd2b78
@@@ -49,8 -49,13 +49,8 @@@ static int parse_decoration_style(cons
        return -1;
  }
  
 -static void cmd_log_init(int argc, const char **argv, const char *prefix,
 -                       struct rev_info *rev, struct setup_revision_opt *opt)
 +static void cmd_log_init_defaults(struct rev_info *rev)
  {
 -      int i;
 -      int decoration_given = 0;
 -      struct userformat_want w;
 -
        rev->abbrev = DEFAULT_ABBREV;
        rev->commit_format = CMIT_FMT_DEFAULT;
        if (fmt_pretty)
  
        if (default_date_mode)
                rev->date_mode = parse_date_format(default_date_mode);
 +}
  
 +static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 +                       struct rev_info *rev, struct setup_revision_opt *opt)
 +{
 +      int i;
 +      int decoration_given = 0;
 +      struct userformat_want w;
        /*
         * Check for -h before setup_revisions(), or "git log -h" will
         * fail when run without a git directory.
        setup_pager();
  }
  
 +static void cmd_log_init(int argc, const char **argv, const char *prefix,
 +                       struct rev_info *rev, struct setup_revision_opt *opt)
 +{
 +      cmd_log_init_defaults(rev);
 +      cmd_log_init_finish(argc, argv, prefix, rev, opt);
 +}
 +
  /*
   * This gives a rough estimate for how many commits we
   * will print out in the list.
@@@ -495,11 -486,16 +495,11 @@@ int cmd_log_reflog(int argc, const cha
        rev.verbose_header = 1;
        memset(&opt, 0, sizeof(opt));
        opt.def = "HEAD";
 -      cmd_log_init(argc, argv, prefix, &rev, &opt);
 -
 -      /*
 -       * This means that we override whatever commit format the user gave
 -       * on the cmd line.  Sad, but cmd_log_init() currently doesn't
 -       * allow us to set a different default.
 -       */
 +      cmd_log_init_defaults(&rev);
        rev.commit_format = CMIT_FMT_ONELINE;
        rev.use_terminator = 1;
        rev.always_show_header = 1;
 +      cmd_log_init_finish(argc, argv, prefix, &rev, &opt);
  
        return cmd_log_walk(&rev);
  }
@@@ -627,7 -623,7 +627,7 @@@ static FILE *realstdout = NULL
  static const char *output_directory = NULL;
  static int outdir_offset;
  
- static int reopen_stdout(struct commit *commit, struct rev_info *rev)
+ static int reopen_stdout(struct commit *commit, struct rev_info *rev, int quiet)
  {
        struct strbuf filename = STRBUF_INIT;
        int suffix_len = strlen(fmt_patch_suffix) + 1;
  
        get_patch_filename(commit, rev->nr, fmt_patch_suffix, &filename);
  
-       if (!DIFF_OPT_TST(&rev->diffopt, QUICK))
+       if (!quiet)
                fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
  
        if (freopen(filename.buf, "w", stdout) == NULL)
@@@ -722,7 -718,8 +722,8 @@@ static void print_signature(void
  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)
+                             int nr, struct commit **list, struct commit *head,
+                             int quiet)
  {
        const char *committer;
        const char *subject_start = NULL;
                        sha1_to_hex(head->object.sha1), committer, committer);
        }
  
-       if (!use_stdout && reopen_stdout(commit, rev))
+       if (!use_stdout && reopen_stdout(commit, rev, quiet))
                return;
  
        if (commit) {
@@@ -999,6 -996,7 +1000,7 @@@ int cmd_format_patch(int argc, const ch
        char *add_signoff = NULL;
        struct strbuf buf = STRBUF_INIT;
        int use_patch_format = 0;
+       int quiet = 0;
        const struct option builtin_format_patch_options[] = {
                { OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
                            "use [PATCH n/m] even with a single patch",
                            PARSE_OPT_OPTARG, thread_callback },
                OPT_STRING(0, "signature", &signature, "signature",
                            "add a signature"),
+               OPT_BOOLEAN(0, "quiet", &quiet,
+                           "don't print the patch filenames"),
                OPT_END()
        };
  
                if (thread)
                        gen_message_id(&rev, "cover");
                make_cover_letter(&rev, use_stdout, numbered, numbered_files,
-                                 origin, nr, list, head);
+                                 origin, nr, list, head, quiet);
                total++;
                start_number--;
        }
                }
  
                if (!use_stdout && reopen_stdout(numbered_files ? NULL : commit,
-                                                &rev))
+                                                &rev, quiet))
                        die(_("Failed to create output files"));
                shown = log_tree_commit(&rev, commit);
                free(commit->buffer);