#include "diff.h"
#include "commit.h"
#include "log-tree.h"
+#include "reflog-walk.h"
static void show_parents(struct commit *commit, int abbrev)
{
return at;
}
+static unsigned int digits_in_number(unsigned int number)
+{
+ unsigned int i = 10, result = 1;
+ while (i <= number) {
+ i *= 10;
+ result++;
+ }
+ return result;
+}
+
void show_log(struct rev_info *opt, const char *sep)
{
static char this_header[16384];
opt->loginfo = NULL;
if (!opt->verbose_header) {
+ if (opt->left_right) {
+ if (commit->object.flags & BOUNDARY)
+ putchar('-');
+ else if (commit->object.flags & SYMMETRIC_LEFT)
+ putchar('<');
+ else
+ putchar('>');
+ }
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE)
extra = "\n";
if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
- putchar('\n');
+ putchar(opt->diffopt.line_termination);
opt->shown_one = 1;
/*
if (opt->total > 0) {
static char buffer[64];
snprintf(buffer, sizeof(buffer),
- "Subject: [PATCH %d/%d] ",
+ "Subject: [PATCH %0*d/%d] ",
+ digits_in_number(opt->total),
opt->nr, opt->total);
subject = buffer;
} else if (opt->total == 0)
opt->diffopt.stat_sep = buffer;
}
} else {
- printf("%s%s%s",
- diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
- opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
- diff_unique_abbrev(commit->object.sha1, abbrev_commit));
+ fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
+ stdout);
+ if (opt->commit_format != CMIT_FMT_ONELINE)
+ fputs("commit ", stdout);
+ if (opt->left_right) {
+ if (commit->object.flags & BOUNDARY)
+ putchar('-');
+ else if (commit->object.flags & SYMMETRIC_LEFT)
+ putchar('<');
+ else
+ putchar('>');
+ }
+ fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
+ stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
if (parent)
printf("%s",
diff_get_color(opt->diffopt.color_diff, DIFF_RESET));
putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
+ if (opt->reflog_info) {
+ show_reflog_message(opt->reflog_info,
+ opt->commit_format == CMIT_FMT_ONELINE,
+ opt->relative_date);
+ if (opt->commit_format == CMIT_FMT_ONELINE) {
+ printf("%s", sep);
+ return;
+ }
+ }
}
/*
opt->commit_format != CMIT_FMT_ONELINE) {
int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
if ((pch & opt->diffopt.output_format) == pch)
- printf("---%c", opt->diffopt.line_termination);
- else
- putchar(opt->diffopt.line_termination);
+ printf("---");
+ putchar('\n');
}
}
diff_flush(&opt->diffopt);