X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=builtin-log.c;h=c8feb0f7953a4d431c180e33f9f71d4434a4e51a;hb=698ce6f87e0d6db380f7306e190e8586da184577;hp=0027998f1014b0e25f130fcdb53dc47fdc617c1e;hpb=8ac80a5701780547404523a84f4b1ae67bfa6823;p=git.git diff --git a/builtin-log.c b/builtin-log.c index 0027998f..c8feb0f7 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -11,6 +11,9 @@ #include "log-tree.h" #include "builtin.h" +/* this is in builtin-diff.c */ +void add_head(struct rev_info *revs); + static int cmd_log_wc(int argc, const char **argv, char **envp, struct rev_info *rev) { @@ -20,6 +23,13 @@ static int cmd_log_wc(int argc, const char **argv, char **envp, rev->commit_format = CMIT_FMT_DEFAULT; rev->verbose_header = 1; argc = setup_revisions(argc, argv, rev, "HEAD"); + if (rev->always_show_header) { + if (rev->diffopt.pickaxe || rev->diffopt.filter) { + rev->always_show_header = 0; + if (rev->diffopt.output_format == DIFF_FORMAT_RAW) + rev->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT; + } + } if (argc > 1) die("unrecognized argument: %s", argv[1]); @@ -173,7 +183,12 @@ int cmd_format_patch(int argc, const char **argv, char **envp) argv[i + 1]); output_directory = strdup(argv[i + 1]); i++; - } else + } + else if (!strcmp(argv[i], "--attach")) + rev.mime_boundary = git_version_string; + else if (!strncmp(argv[i], "--attach=", 9)) + rev.mime_boundary = argv[i] + 9; + else argv[j++] = argv[i]; } argc = j; @@ -185,6 +200,11 @@ int cmd_format_patch(int argc, const char **argv, char **envp) if (argc > 1) die ("unrecognized argument: %s", argv[1]); + if (rev.pending_objects && rev.pending_objects->next == NULL) { + rev.pending_objects->item->flags |= UNINTERESTING; + add_head(&rev); + } + if (!use_stdout) realstdout = fdopen(dup(1), "w"); @@ -209,8 +229,14 @@ int cmd_format_patch(int argc, const char **argv, char **envp) shown = log_tree_commit(&rev, commit); free(commit->buffer); commit->buffer = NULL; - if (shown) - printf("-- \n%s\n\n", git_version_string); + if (shown) { + if (rev.mime_boundary) + printf("\n--%s%s--\n\n\n", + mime_boundary_leader, + rev.mime_boundary); + else + printf("-- \n%s\n\n", git_version_string); + } if (!use_stdout) fclose(stdout); }