author | Junio C Hamano <junkio@cox.net> | |
Sun, 16 Apr 2006 10:39:00 +0000 (03:39 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 16 Apr 2006 10:39:00 +0000 (03:39 -0700) |
* lt/logopt:
log/whatchanged/show - log formatting cleanup.
Simplify common default options setup for built-in log family.
log/whatchanged/show - log formatting cleanup.
Simplify common default options setup for built-in log family.
git.c | patch | blob | history | |
log-tree.c | patch | blob | history | |
revision.h | patch | blob | history |
index 239b26adfda494e6568d07b22c28d0c2ef4ca78c..c5de8d3a1257a27fbe27fa7db76c90dc50944bbf 100644 (file)
--- a/git.c
+++ b/git.c
const char *commit_prefix = "commit ";
int shown = 0;
+ rev->abbrev = DEFAULT_ABBREV;
+ rev->commit_format = CMIT_FMT_DEFAULT;
+ argc = setup_revisions(argc, argv, rev, "HEAD");
+
if (argc > 1)
die("unrecognized argument: %s", argv[1]);
if (rev->commit_format == CMIT_FMT_ONELINE)
prepare_revision_walk(rev);
setup_pager();
while ((commit = get_revision(rev)) != NULL) {
+ unsigned long ofs = 0;
+
if (shown && rev->diff &&
rev->commit_format != CMIT_FMT_ONELINE)
putchar('\n');
- fputs(commit_prefix, stdout);
+
+ ofs = sprintf(buf, "%s", commit_prefix);
if (rev->abbrev_commit && rev->abbrev)
- fputs(find_unique_abbrev(commit->object.sha1,
- rev->abbrev),
- stdout);
+ ofs += sprintf(buf + ofs, "%s",
+ find_unique_abbrev(commit->object.sha1,
+ rev->abbrev));
else
- fputs(sha1_to_hex(commit->object.sha1), stdout);
+ ofs += sprintf(buf + ofs, "%s",
+ sha1_to_hex(commit->object.sha1));
if (rev->parents) {
struct commit_list *parents = commit->parents;
while (parents) {
parents = parents->next;
if (o->flags & TMP_MARK)
continue;
- printf(" %s", sha1_to_hex(o->sha1));
+ ofs += sprintf(buf + ofs, " %s",
+ sha1_to_hex(o->sha1));
o->flags |= TMP_MARK;
}
/* TMP_MARK is a general purpose flag that can
parents = parents->next)
parents->item->object.flags &= ~TMP_MARK;
}
- if (rev->commit_format == CMIT_FMT_ONELINE)
- putchar(' ');
- else
- putchar('\n');
- pretty_print_commit(rev->commit_format, commit, ~0, buf,
- LOGSIZE, rev->abbrev);
- printf("%s\n", buf);
+ buf[ofs++] =
+ (rev->commit_format == CMIT_FMT_ONELINE) ? ' ' : '\n';
+ ofs += pretty_print_commit(rev->commit_format, commit, ~0,
+ buf + ofs,
+ LOGSIZE - ofs - 20,
+ rev->abbrev);
+
if (rev->diff) {
- printf("--\n");
+ rev->use_precomputed_header = buf;
+ strcpy(buf + ofs, "\n---\n");
log_tree_commit(rev, commit);
}
+ else
+ printf("%s\n", buf);
shown = 1;
free(commit->buffer);
commit->buffer = NULL;
struct rev_info rev;
init_revisions(&rev);
- rev.abbrev = DEFAULT_ABBREV;
- rev.no_commit_id = 1;
- rev.commit_format = CMIT_FMT_DEFAULT;
rev.diff = 1;
rev.diffopt.recursive = 1;
- argc = setup_revisions(argc, argv, &rev, "HEAD");
return cmd_log_wc(argc, argv, envp, &rev);
}
init_revisions(&rev);
rev.diff = 1;
- rev.ignore_merges = 0;
+ rev.diffopt.recursive = 1;
rev.combine_merges = 1;
rev.dense_combined_merges = 1;
- rev.abbrev = DEFAULT_ABBREV;
- rev.commit_format = CMIT_FMT_DEFAULT;
- rev.diffopt.recursive = 1;
+ rev.ignore_merges = 0;
rev.no_walk = 1;
- argc = setup_revisions(argc, argv, &rev, "HEAD");
return cmd_log_wc(argc, argv, envp, &rev);
}
struct rev_info rev;
init_revisions(&rev);
- rev.abbrev = DEFAULT_ABBREV;
- rev.no_commit_id = 1;
- rev.commit_format = CMIT_FMT_DEFAULT;
- argc = setup_revisions(argc, argv, &rev, "HEAD");
+ rev.always_show_header = 1;
+ rev.diffopt.recursive = 1;
+ rev.combine_merges = 1;
+ rev.ignore_merges = 0;
return cmd_log_wc(argc, argv, envp, &rev);
}
diff --git a/log-tree.c b/log-tree.c
index 04a68e0f570dee3701c1879c4190473880aa540b..7d9f41ede145f47fe8886770cdfb6e0bfb1abaea 100644 (file)
--- a/log-tree.c
+++ b/log-tree.c
int abbrev = opt->diffopt.abbrev;
const char *msg = commit->buffer;
+ if (opt->use_precomputed_header)
+ return opt->use_precomputed_header;
+
if (!opt->verbose_header)
return sha1_to_hex(commit_sha1);
diff --git a/revision.h b/revision.h
index 7b854866b2fe43bf01d5453d4d580ffb2179d8a5..74dc5ef179e9778b874ceee7aefc6162892b116a 100644 (file)
--- a/revision.h
+++ b/revision.h
enum cmit_fmt commit_format;
const char *header_prefix;
const char *header;
+ const char *use_precomputed_header;
/* special limits */
int max_count;