static int default_show_root = 1;
static const char *fmt_patch_subject_prefix = "PATCH";
+static const char *fmt_pretty;
static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
{
rev->abbrev = DEFAULT_ABBREV;
rev->commit_format = CMIT_FMT_DEFAULT;
+ if (fmt_pretty)
+ rev->commit_format = get_commit_format(fmt_pretty);
rev->verbose_header = 1;
DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
rev->show_root_diff = default_show_root;
static int git_log_config(const char *var, const char *value)
{
+ if (!strcmp(var, "format.pretty"))
+ return git_config_string(&fmt_pretty, var, value);
if (!strcmp(var, "format.subjectprefix")) {
if (!value)
config_error_nonbool(var);
int nr, struct commit **list, struct commit *head)
{
const char *committer;
- const char *origin_sha1, *head_sha1;
- const char *argv[7];
+ char *head_sha1;
const char *subject_start = NULL;
const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
const char *msg;
struct strbuf sb;
int i;
const char *encoding = "utf-8";
+ struct diff_options opts;
if (rev->commit_format != CMIT_FMT_EMAIL)
die("Cover letter needs email format");
strbuf_release(&sb);
shortlog_init(&log);
+ log.wrap_lines = 1;
+ log.wrap = 72;
+ log.in1 = 2;
+ log.in2 = 4;
for (i = 0; i < nr; i++)
shortlog_add_commit(&log, list[i]);
if (!origin)
return;
- origin_sha1 = sha1_to_hex(origin->object.sha1);
+ memcpy(&opts, &rev->diffopt, sizeof(opts));
+ opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
- argv[0] = "diff";
- argv[1] = "--stat";
- argv[2] = "--summary";
- argv[3] = head_sha1;
- argv[4] = "--not";
- argv[5] = origin_sha1;
- argv[6] = "--";
- argv[7] = NULL;
- fflush(stdout);
- run_command_v_opt(argv, RUN_GIT_CMD);
+ diff_setup_done(&opts);
+
+ diff_tree_sha1(origin->tree->object.sha1,
+ head->tree->object.sha1,
+ "", &opts);
+ diffcore_std(&opts);
+ diff_flush(&opts);
- fflush(stdout);
printf("\n");
}
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;