summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 552bcac)
raw | patch | inline | side by side (parent: 552bcac)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Mon, 25 Feb 2008 23:24:17 +0000 (18:24 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 26 Feb 2008 05:28:32 +0000 (21:28 -0800) |
Use the "boundary" feature to find the origin (or find that there are
multiple origins), and use the actual list of commits to pass to
shortlog.
This makes all cover letter include shortlogs, and all cover letters
for series with a single boundary commit include diffstats (if there
are multiple boundary commits it's unclear what would be meaningful as
a diffstat). Note that the single boundary test is empirical, not
theoretical; even a -2 limiting condition will give a diffstat if there's
only one boundary commit in this particular case.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
multiple origins), and use the actual list of commits to pass to
shortlog.
This makes all cover letter include shortlogs, and all cover letters
for series with a single boundary commit include diffstats (if there
are multiple boundary commits it's unclear what would be meaningful as
a diffstat). Note that the single boundary test is empirical, not
theoretical; even a -2 limiting condition will give a diffstat if there's
only one boundary commit in this particular case.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
builtin-log.c | patch | blob | history |
diff --git a/builtin-log.c b/builtin-log.c
index 0b348eb6b3babaa9c5e30136f1e4cd849e46f27d..3112d96db0dd60b50cd4b5c02e51821f678fb8ff 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
#include "patch-ids.h"
#include "refs.h"
#include "run-command.h"
+#include "shortlog.h"
static int default_show_root = 1;
static const char *fmt_patch_subject_prefix = "PATCH";
info->message_id = strbuf_detach(&buf, NULL);
}
-static void make_cover_letter(struct rev_info *rev,
- int use_stdout, int numbered, int numbered_files,
- struct commit *origin, struct commit *head)
+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 *committer;
const char *origin_sha1, *head_sha1;
const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
const char *msg;
const char *extra_headers = rev->extra_headers;
+ struct shortlog log;
struct strbuf sb;
+ int i;
const char *encoding = "utf-8";
if (rev->commit_format != CMIT_FMT_EMAIL)
NULL : "cover-letter", 0, rev->total))
return;
- origin_sha1 = sha1_to_hex(origin ? origin->object.sha1 : null_sha1);
head_sha1 = sha1_to_hex(head->object.sha1);
log_write_email_headers(rev, head_sha1, &subject_start, &extra_headers);
strbuf_release(&sb);
+ shortlog_init(&log);
+ for (i = 0; i < nr; i++)
+ shortlog_add_commit(&log, list[i]);
+
+ shortlog_output(&log);
+
/*
- * We can only do diffstat with a unique reference point, and
- * log is a bit tricky, so just skip it.
+ * We can only do diffstat with a unique reference point
*/
if (!origin)
return;
- argv[0] = "shortlog";
- argv[1] = head_sha1;
- argv[2] = "--not";
- argv[3] = origin_sha1;
- argv[4] = "--";
- argv[5] = NULL;
- fflush(stdout);
- run_command_v_opt(argv, RUN_GIT_CMD);
+ origin_sha1 = sha1_to_hex(origin->object.sha1);
argv[0] = "diff";
argv[1] = "--stat";
int ignore_if_in_upstream = 0;
int thread = 0;
int cover_letter = 0;
+ int boundary_count = 0;
struct commit *origin = NULL, *head = NULL;
const char *in_reply_to = NULL;
struct patch_ids ids;
}
if (cover_letter) {
/* remember the range */
- int negative_count = 0;
int i;
for (i = 0; i < rev.pending.nr; i++) {
struct object *o = rev.pending.objects[i].item;
- if (o->flags & UNINTERESTING) {
- origin = (struct commit *)o;
- negative_count++;
- } else
+ if (!(o->flags & UNINTERESTING))
head = (struct commit *)o;
}
- /* Multiple origins don't work for diffstat. */
- if (negative_count > 1)
- origin = NULL;
/* We can't generate a cover letter without any patches */
if (!head)
return 0;
if (!use_stdout)
realstdout = xfdopen(xdup(1), "w");
- prepare_revision_walk(&rev);
+ if (prepare_revision_walk(&rev))
+ die("revision walk setup failed");
+ rev.boundary = 1;
while ((commit = get_revision(&rev)) != NULL) {
+ if (commit->object.flags & BOUNDARY) {
+ fprintf(stderr, "Boundary %s\n", sha1_to_hex(commit->object.sha1));
+ boundary_count++;
+ origin = (boundary_count == 1) ? commit : NULL;
+ continue;
+ }
+
/* ignore merges */
if (commit->parents && commit->parents->next)
continue;
if (thread)
gen_message_id(&rev, "cover");
make_cover_letter(&rev, use_stdout, numbered, numbered_files,
- origin, head);
+ origin, nr, list, head);
total++;
start_number--;
}