OSDN Git Service

Merge branch 'js/fmt-patch'
authorJunio C Hamano <junkio@cox.net>
Wed, 24 May 2006 19:19:47 +0000 (12:19 -0700)
committerJunio C Hamano <junkio@cox.net>
Wed, 24 May 2006 19:19:47 +0000 (12:19 -0700)
This makes "git format-patch" a built-in.

* js/fmt-patch:
  git-rebase: use canonical A..B syntax to format-patch
  git-format-patch: now built-in.
  fmt-patch: Support --attach
  fmt-patch: understand old <his> notation
  Teach fmt-patch about --keep-subject
  Teach fmt-patch about --numbered
  fmt-patch: implement -o <dir>
  fmt-patch: output file names to stdout
  Teach fmt-patch to write individual files.
  Use RFC2822 dates from "git fmt-patch".
  git-fmt-patch: thinkofix to show [PATCH] properly.
  rename internal format-patch wip
  Minor tweak on subject line in --pretty=email
  Tentative built-in format-patch.

1  2 
Makefile
builtin-show-branch.c
builtin.h
cache.h
diff.c
git.c
log-tree.c

diff --cc Makefile
+++ b/Makefile
@@@ -113,10 -113,10 +113,10 @@@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__pow
  ### --- END CONFIGURATION SECTION ---
  
  SCRIPT_SH = \
 -      git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
 +      git-bisect.sh git-branch.sh git-checkout.sh \
        git-cherry.sh git-clean.sh git-clone.sh git-commit.sh \
        git-fetch.sh \
-       git-format-patch.sh git-ls-remote.sh \
+       git-ls-remote.sh \
        git-merge-one-file.sh git-parse-remote.sh \
        git-prune.sh git-pull.sh git-rebase.sh \
        git-repack.sh git-request-pull.sh git-reset.sh \
@@@ -168,13 -170,8 +168,13 @@@ PROGRAMS = 
  
  BUILT_INS = git-log$X git-whatchanged$X git-show$X \
        git-count-objects$X git-diff$X git-push$X \
 -      git-grep$X git-rev-list$X git-check-ref-format$X \
 -      git-init-db$X git-format-patch$X
 +      git-grep$X git-add$X git-rm$X git-rev-list$X \
 +      git-check-ref-format$X \
-       git-init-db$X git-tar-tree$X git-upload-tar$X \
++      git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
 +      git-ls-files$X git-ls-tree$X \
 +      git-read-tree$X git-commit-tree$X \
 +      git-apply$X git-show-branch$X git-diff-files$X \
 +      git-diff-index$X git-diff-stages$X git-diff-tree$X
  
  # what 'all' will build and 'install' will install, in gitexecdir
  ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
Simple merge
diff --cc builtin.h
Simple merge
diff --cc cache.h
Simple merge
diff --cc diff.c
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -1988,10 -1981,10 +1989,13 @@@ void diff_flush(struct diff_options *op
                show_stats(diffstat);
                free(diffstat);
                diffstat = NULL;
-               putchar(options->line_termination);
 +              if (options->summary)
 +                      for (i = 0; i < q->nr; i++)
 +                              diff_summary(q->queue[i]);
+               if (options->stat_sep)
+                       fputs(options->stat_sep, stdout);
+               else
+                       putchar(options->line_termination);
        }
        for (i = 0; i < q->nr; i++) {
                struct diff_filepair *p = q->queue[i];
diff --cc git.c
Simple merge
diff --cc log-tree.c
@@@ -49,14 -50,62 +50,62 @@@ void show_log(struct rev_info *opt, str
        /*
         * Print header line of header..
         */
-       printf("%s%s",
-               opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
-               diff_unique_abbrev(commit->object.sha1, abbrev_commit));
-       if (opt->parents)
-               show_parents(commit, abbrev_commit);
-       if (parent)
-               printf(" (from %s)", diff_unique_abbrev(parent->object.sha1, abbrev_commit));
-       putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
+       if (opt->commit_format == CMIT_FMT_EMAIL) {
+               char *sha1 = sha1_to_hex(commit->object.sha1);
+               if (opt->total > 0) {
+                       static char buffer[64];
+                       snprintf(buffer, sizeof(buffer),
+                                       "Subject: [PATCH %d/%d] ",
+                                       opt->nr, opt->total);
+                       subject = buffer;
+               } else if (opt->total == 0)
+                       subject = "Subject: [PATCH] ";
+               else
+                       subject = "Subject: ";
+               printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
+               if (opt->mime_boundary) {
+                       static char subject_buffer[1024];
+                       static char buffer[1024];
+                       snprintf(subject_buffer, sizeof(subject_buffer) - 1,
+                                "MIME-Version: 1.0\n"
+                                "Content-Type: multipart/mixed;\n"
+                                " boundary=\"%s%s\"\n"
+                                "\n"
+                                "This is a multi-part message in MIME "
+                                "format.\n"
+                                "--%s%s\n"
+                                "Content-Type: text/plain; "
+                                "charset=UTF-8; format=fixed\n"
+                                "Content-Transfer-Encoding: 8bit\n\n",
+                                mime_boundary_leader, opt->mime_boundary,
+                                mime_boundary_leader, opt->mime_boundary);
+                       after_subject = subject_buffer;
+                       snprintf(buffer, sizeof(buffer) - 1,
+                                "--%s%s\n"
+                                "Content-Type: text/x-patch;\n"
+                                " name=\"%s.diff\"\n"
+                                "Content-Transfer-Encoding: 8bit\n"
+                                "Content-Disposition: inline;\n"
+                                " filename=\"%s.diff\"\n\n",
+                                mime_boundary_leader, opt->mime_boundary,
+                                sha1, sha1);
+                       opt->diffopt.stat_sep = buffer;
+               }
+       } else {
+               printf("%s%s",
+                      opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
+                      diff_unique_abbrev(commit->object.sha1, abbrev_commit));
+               if (opt->parents)
+                       show_parents(commit, abbrev_commit);
 -              if (parent) 
++              if (parent)
+                       printf(" (from %s)",
+                              diff_unique_abbrev(parent->object.sha1,
+                                                 abbrev_commit));
+               putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
+       }
  
        /*
         * And then the pretty-printed message itself