2006-04-09 16:11:11 +08:00
|
|
|
#include "cache.h"
|
|
|
|
#include "diff.h"
|
|
|
|
#include "commit.h"
|
2008-09-05 05:39:21 +08:00
|
|
|
#include "tag.h"
|
2008-05-04 18:36:54 +08:00
|
|
|
#include "graph.h"
|
2006-04-09 16:11:11 +08:00
|
|
|
#include "log-tree.h"
|
2007-01-11 18:47:48 +08:00
|
|
|
#include "reflog-walk.h"
|
2008-09-05 05:39:21 +08:00
|
|
|
#include "refs.h"
|
2009-02-20 05:26:31 +08:00
|
|
|
#include "string-list.h"
|
2010-06-19 09:37:35 +08:00
|
|
|
#include "color.h"
|
2011-10-19 06:53:23 +08:00
|
|
|
#include "gpg-interface.h"
|
2013-02-12 18:17:39 +08:00
|
|
|
#include "sequencer.h"
|
2006-04-09 16:11:11 +08:00
|
|
|
|
2007-04-17 07:05:10 +08:00
|
|
|
struct decoration name_decoration = { "object names" };
|
|
|
|
|
2010-06-19 09:37:34 +08:00
|
|
|
enum decoration_type {
|
|
|
|
DECORATION_NONE = 0,
|
|
|
|
DECORATION_REF_LOCAL,
|
|
|
|
DECORATION_REF_REMOTE,
|
|
|
|
DECORATION_REF_TAG,
|
|
|
|
DECORATION_REF_STASH,
|
|
|
|
DECORATION_REF_HEAD,
|
2011-08-18 20:29:37 +08:00
|
|
|
DECORATION_GRAFTED,
|
2010-06-19 09:37:34 +08:00
|
|
|
};
|
|
|
|
|
2010-06-19 09:37:35 +08:00
|
|
|
static char decoration_colors[][COLOR_MAXLEN] = {
|
|
|
|
GIT_COLOR_RESET,
|
|
|
|
GIT_COLOR_BOLD_GREEN, /* REF_LOCAL */
|
|
|
|
GIT_COLOR_BOLD_RED, /* REF_REMOTE */
|
|
|
|
GIT_COLOR_BOLD_YELLOW, /* REF_TAG */
|
|
|
|
GIT_COLOR_BOLD_MAGENTA, /* REF_STASH */
|
|
|
|
GIT_COLOR_BOLD_CYAN, /* REF_HEAD */
|
2011-08-18 20:29:37 +08:00
|
|
|
GIT_COLOR_BOLD_BLUE, /* GRAFTED */
|
2010-06-19 09:37:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char *decorate_get_color(int decorate_use_color, enum decoration_type ix)
|
|
|
|
{
|
color: delay auto-color decision until point of use
When we read a color value either from a config file or from
the command line, we use git_config_colorbool to convert it
from the tristate always/never/auto into a single yes/no
boolean value.
This has some timing implications with respect to starting
a pager.
If we start (or decide not to start) the pager before
checking the colorbool, everything is fine. Either isatty(1)
will give us the right information, or we will properly
check for pager_in_use().
However, if we decide to start a pager after we have checked
the colorbool, things are not so simple. If stdout is a tty,
then we will have already decided to use color. However, the
user may also have configured color.pager not to use color
with the pager. In this case, we need to actually turn off
color. Unfortunately, the pager code has no idea which color
variables were turned on (and there are many of them
throughout the code, and they may even have been manipulated
after the colorbool selection by something like "--color" on
the command line).
This bug can be seen any time a pager is started after
config and command line options are checked. This has
affected "git diff" since 89d07f7 (diff: don't run pager if
user asked for a diff style exit code, 2007-08-12). It has
also affect the log family since 1fda91b (Fix 'git log'
early pager startup error case, 2010-08-24).
This patch splits the notion of parsing a colorbool and
actually checking the configuration. The "use_color"
variables now have an additional possible value,
GIT_COLOR_AUTO. Users of the variable should use the new
"want_color()" wrapper, which will lazily determine and
cache the auto-color decision.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-18 13:04:23 +08:00
|
|
|
if (want_color(decorate_use_color))
|
2010-06-19 09:37:35 +08:00
|
|
|
return decoration_colors[ix];
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2010-06-24 08:21:16 +08:00
|
|
|
static int parse_decorate_color_slot(const char *slot)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We're comparing with 'ignore-case' on
|
|
|
|
* (because config.c sets them all tolower),
|
|
|
|
* but let's match the letters in the literal
|
|
|
|
* string values here with how they are
|
|
|
|
* documented in Documentation/config.txt, for
|
|
|
|
* consistency.
|
|
|
|
*
|
|
|
|
* We love being consistent, don't we?
|
|
|
|
*/
|
|
|
|
if (!strcasecmp(slot, "branch"))
|
|
|
|
return DECORATION_REF_LOCAL;
|
|
|
|
if (!strcasecmp(slot, "remoteBranch"))
|
|
|
|
return DECORATION_REF_REMOTE;
|
|
|
|
if (!strcasecmp(slot, "tag"))
|
|
|
|
return DECORATION_REF_TAG;
|
|
|
|
if (!strcasecmp(slot, "stash"))
|
|
|
|
return DECORATION_REF_STASH;
|
|
|
|
if (!strcasecmp(slot, "HEAD"))
|
|
|
|
return DECORATION_REF_HEAD;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int parse_decorate_color_config(const char *var, const int ofs, const char *value)
|
|
|
|
{
|
|
|
|
int slot = parse_decorate_color_slot(var + ofs);
|
|
|
|
if (slot < 0)
|
|
|
|
return 0;
|
|
|
|
if (!value)
|
|
|
|
return config_error_nonbool(var);
|
|
|
|
color_parse(value, var, decoration_colors[slot]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-19 09:37:35 +08:00
|
|
|
/*
|
|
|
|
* log-tree.c uses DIFF_OPT_TST for determining whether to use color
|
|
|
|
* for showing the commit sha1, use the same check for --decorate
|
|
|
|
*/
|
|
|
|
#define decorate_get_color_opt(o, ix) \
|
2011-08-18 13:03:12 +08:00
|
|
|
decorate_get_color((o)->use_color, ix)
|
2010-06-19 09:37:35 +08:00
|
|
|
|
2010-06-19 09:37:34 +08:00
|
|
|
static void add_name_decoration(enum decoration_type type, const char *name, struct object *obj)
|
2008-09-05 05:39:21 +08:00
|
|
|
{
|
|
|
|
int nlen = strlen(name);
|
2010-06-19 09:37:34 +08:00
|
|
|
struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + nlen);
|
|
|
|
memcpy(res->name, name, nlen + 1);
|
|
|
|
res->type = type;
|
2008-09-05 05:39:21 +08:00
|
|
|
res->next = add_decoration(&name_decoration, obj, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
|
|
|
|
{
|
2011-08-19 20:43:50 +08:00
|
|
|
struct object *obj;
|
2010-06-19 09:37:34 +08:00
|
|
|
enum decoration_type type = DECORATION_NONE;
|
2011-08-19 20:43:50 +08:00
|
|
|
|
|
|
|
if (!prefixcmp(refname, "refs/replace/")) {
|
|
|
|
unsigned char original_sha1[20];
|
2011-08-25 23:09:30 +08:00
|
|
|
if (!read_replace_refs)
|
|
|
|
return 0;
|
2011-08-19 20:43:50 +08:00
|
|
|
if (get_sha1_hex(refname + 13, original_sha1)) {
|
|
|
|
warning("invalid replace ref %s", refname);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
obj = parse_object(original_sha1);
|
|
|
|
if (obj)
|
|
|
|
add_name_decoration(DECORATION_GRAFTED, "replaced", obj);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = parse_object(sha1);
|
2008-09-05 05:39:21 +08:00
|
|
|
if (!obj)
|
|
|
|
return 0;
|
2010-06-19 09:37:34 +08:00
|
|
|
|
2011-08-18 20:29:34 +08:00
|
|
|
if (!prefixcmp(refname, "refs/heads/"))
|
2010-06-19 09:37:34 +08:00
|
|
|
type = DECORATION_REF_LOCAL;
|
2011-08-18 20:29:34 +08:00
|
|
|
else if (!prefixcmp(refname, "refs/remotes/"))
|
2010-06-19 09:37:34 +08:00
|
|
|
type = DECORATION_REF_REMOTE;
|
2011-08-18 20:29:34 +08:00
|
|
|
else if (!prefixcmp(refname, "refs/tags/"))
|
2010-06-19 09:37:34 +08:00
|
|
|
type = DECORATION_REF_TAG;
|
2012-01-05 20:39:40 +08:00
|
|
|
else if (!strcmp(refname, "refs/stash"))
|
2010-06-19 09:37:34 +08:00
|
|
|
type = DECORATION_REF_STASH;
|
2012-01-05 20:39:40 +08:00
|
|
|
else if (!strcmp(refname, "HEAD"))
|
2010-06-19 09:37:34 +08:00
|
|
|
type = DECORATION_REF_HEAD;
|
|
|
|
|
2009-08-15 22:23:12 +08:00
|
|
|
if (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS)
|
|
|
|
refname = prettify_refname(refname);
|
2010-06-19 09:37:34 +08:00
|
|
|
add_name_decoration(type, refname, obj);
|
2008-09-05 05:39:21 +08:00
|
|
|
while (obj->type == OBJ_TAG) {
|
|
|
|
obj = ((struct tag *)obj)->tagged;
|
|
|
|
if (!obj)
|
|
|
|
break;
|
2010-06-19 09:37:34 +08:00
|
|
|
add_name_decoration(DECORATION_REF_TAG, refname, obj);
|
2008-09-05 05:39:21 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-18 20:29:37 +08:00
|
|
|
static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)
|
|
|
|
{
|
|
|
|
struct commit *commit = lookup_commit(graft->sha1);
|
|
|
|
if (!commit)
|
|
|
|
return 0;
|
|
|
|
add_name_decoration(DECORATION_GRAFTED, "grafted", &commit->object);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-15 22:23:12 +08:00
|
|
|
void load_ref_decorations(int flags)
|
2008-09-05 05:39:21 +08:00
|
|
|
{
|
|
|
|
static int loaded;
|
|
|
|
if (!loaded) {
|
|
|
|
loaded = 1;
|
2009-08-15 22:23:12 +08:00
|
|
|
for_each_ref(add_ref_decoration, &flags);
|
2009-10-13 04:34:12 +08:00
|
|
|
head_ref(add_ref_decoration, &flags);
|
2011-08-18 20:29:37 +08:00
|
|
|
for_each_commit_graft(add_graft_decoration, NULL);
|
2008-09-05 05:39:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-03 22:59:00 +08:00
|
|
|
static void show_parents(struct commit *commit, int abbrev)
|
|
|
|
{
|
|
|
|
struct commit_list *p;
|
|
|
|
for (p = commit->parents; p ; p = p->next) {
|
|
|
|
struct commit *parent = p->item;
|
2009-02-14 06:10:41 +08:00
|
|
|
printf(" %s", find_unique_abbrev(parent->object.sha1, abbrev));
|
2006-05-03 22:59:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-04 22:02:03 +08:00
|
|
|
static void show_children(struct rev_info *opt, struct commit *commit, int abbrev)
|
|
|
|
{
|
|
|
|
struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
|
|
|
|
for ( ; p; p = p->next) {
|
|
|
|
printf(" %s", find_unique_abbrev(p->item->object.sha1, abbrev));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-28 03:51:59 +08:00
|
|
|
void show_decorations(struct rev_info *opt, struct commit *commit)
|
2007-04-17 07:05:10 +08:00
|
|
|
{
|
|
|
|
const char *prefix;
|
|
|
|
struct name_decoration *decoration;
|
2010-06-19 09:37:35 +08:00
|
|
|
const char *color_commit =
|
|
|
|
diff_get_color_opt(&opt->diffopt, DIFF_COMMIT);
|
|
|
|
const char *color_reset =
|
|
|
|
decorate_get_color_opt(&opt->diffopt, DECORATION_NONE);
|
2007-04-17 07:05:10 +08:00
|
|
|
|
2008-10-28 03:51:59 +08:00
|
|
|
if (opt->show_source && commit->util)
|
2008-11-16 02:02:01 +08:00
|
|
|
printf("\t%s", (char *) commit->util);
|
2008-11-04 03:23:57 +08:00
|
|
|
if (!opt->show_decorations)
|
|
|
|
return;
|
2007-04-17 07:05:10 +08:00
|
|
|
decoration = lookup_decoration(&name_decoration, &commit->object);
|
|
|
|
if (!decoration)
|
|
|
|
return;
|
|
|
|
prefix = " (";
|
|
|
|
while (decoration) {
|
2010-06-19 09:37:34 +08:00
|
|
|
printf("%s", prefix);
|
2010-06-19 09:37:35 +08:00
|
|
|
fputs(decorate_get_color_opt(&opt->diffopt, decoration->type),
|
|
|
|
stdout);
|
2010-06-19 09:37:34 +08:00
|
|
|
if (decoration->type == DECORATION_REF_TAG)
|
2010-06-19 09:37:35 +08:00
|
|
|
fputs("tag: ", stdout);
|
2010-06-19 09:37:34 +08:00
|
|
|
printf("%s", decoration->name);
|
2010-06-19 09:37:35 +08:00
|
|
|
fputs(color_reset, stdout);
|
|
|
|
fputs(color_commit, stdout);
|
2007-04-17 07:05:10 +08:00
|
|
|
prefix = ", ";
|
|
|
|
decoration = decoration->next;
|
|
|
|
}
|
|
|
|
putchar(')');
|
|
|
|
}
|
|
|
|
|
2007-02-09 08:43:54 +08:00
|
|
|
static unsigned int digits_in_number(unsigned int number)
|
|
|
|
{
|
|
|
|
unsigned int i = 10, result = 1;
|
|
|
|
while (i <= number) {
|
|
|
|
i *= 10;
|
|
|
|
result++;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-22 14:06:01 +08:00
|
|
|
void fmt_output_subject(struct strbuf *filename,
|
|
|
|
const char *subject,
|
2012-12-22 15:26:16 +08:00
|
|
|
struct rev_info *info)
|
2009-03-23 10:14:04 +08:00
|
|
|
{
|
2012-12-22 15:26:16 +08:00
|
|
|
const char *suffix = info->patch_suffix;
|
|
|
|
int nr = info->nr;
|
2012-12-22 14:06:01 +08:00
|
|
|
int start_len = filename->len;
|
|
|
|
int max_len = start_len + FORMAT_PATCH_NAME_MAX - (strlen(suffix) + 1);
|
|
|
|
|
2012-12-22 16:21:23 +08:00
|
|
|
if (0 < info->reroll_count)
|
|
|
|
strbuf_addf(filename, "v%d-", info->reroll_count);
|
2012-12-22 14:06:01 +08:00
|
|
|
strbuf_addf(filename, "%04d-%s", nr, subject);
|
|
|
|
|
|
|
|
if (max_len < filename->len)
|
|
|
|
strbuf_setlen(filename, max_len);
|
|
|
|
strbuf_addstr(filename, suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fmt_output_commit(struct strbuf *filename,
|
|
|
|
struct commit *commit,
|
|
|
|
struct rev_info *info)
|
|
|
|
{
|
|
|
|
struct pretty_print_context ctx = {0};
|
|
|
|
struct strbuf subject = STRBUF_INIT;
|
|
|
|
|
|
|
|
format_commit_message(commit, "%f", &subject, &ctx);
|
|
|
|
fmt_output_subject(filename, subject.buf, info);
|
|
|
|
strbuf_release(&subject);
|
2009-03-23 10:14:04 +08:00
|
|
|
}
|
|
|
|
|
2009-03-23 10:14:05 +08:00
|
|
|
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
|
2008-03-15 15:09:20 +08:00
|
|
|
const char **subject_p,
|
|
|
|
const char **extra_headers_p,
|
|
|
|
int *need_8bit_cte_p)
|
2008-02-19 11:56:08 +08:00
|
|
|
{
|
|
|
|
const char *subject = NULL;
|
|
|
|
const char *extra_headers = opt->extra_headers;
|
2009-03-23 10:14:05 +08:00
|
|
|
const char *name = sha1_to_hex(commit->object.sha1);
|
2008-03-15 15:09:20 +08:00
|
|
|
|
|
|
|
*need_8bit_cte_p = 0; /* unknown */
|
2008-02-19 11:56:08 +08:00
|
|
|
if (opt->total > 0) {
|
|
|
|
static char buffer[64];
|
|
|
|
snprintf(buffer, sizeof(buffer),
|
2011-05-30 22:19:05 +08:00
|
|
|
"Subject: [%s%s%0*d/%d] ",
|
2008-02-19 11:56:08 +08:00
|
|
|
opt->subject_prefix,
|
2011-05-30 22:19:05 +08:00
|
|
|
*opt->subject_prefix ? " " : "",
|
2008-02-19 11:56:08 +08:00
|
|
|
digits_in_number(opt->total),
|
|
|
|
opt->nr, opt->total);
|
|
|
|
subject = buffer;
|
|
|
|
} else if (opt->total == 0 && opt->subject_prefix && *opt->subject_prefix) {
|
|
|
|
static char buffer[256];
|
|
|
|
snprintf(buffer, sizeof(buffer),
|
|
|
|
"Subject: [%s] ",
|
|
|
|
opt->subject_prefix);
|
|
|
|
subject = buffer;
|
|
|
|
} else {
|
|
|
|
subject = "Subject: ";
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("From %s Mon Sep 17 00:00:00 2001\n", name);
|
2008-05-04 18:36:54 +08:00
|
|
|
graph_show_oneline(opt->graph);
|
|
|
|
if (opt->message_id) {
|
2008-02-19 11:56:08 +08:00
|
|
|
printf("Message-Id: <%s>\n", opt->message_id);
|
2008-05-04 18:36:54 +08:00
|
|
|
graph_show_oneline(opt->graph);
|
|
|
|
}
|
2009-02-20 05:26:31 +08:00
|
|
|
if (opt->ref_message_ids && opt->ref_message_ids->nr > 0) {
|
|
|
|
int i, n;
|
|
|
|
n = opt->ref_message_ids->nr;
|
|
|
|
printf("In-Reply-To: <%s>\n", opt->ref_message_ids->items[n-1].string);
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
printf("%s<%s>\n", (i > 0 ? "\t" : "References: "),
|
|
|
|
opt->ref_message_ids->items[i].string);
|
2008-05-04 18:36:54 +08:00
|
|
|
graph_show_oneline(opt->graph);
|
|
|
|
}
|
2008-02-19 11:56:08 +08:00
|
|
|
if (opt->mime_boundary) {
|
|
|
|
static char subject_buffer[1024];
|
|
|
|
static char buffer[1024];
|
2009-03-23 10:14:05 +08:00
|
|
|
struct strbuf filename = STRBUF_INIT;
|
2008-03-15 15:09:20 +08:00
|
|
|
*need_8bit_cte_p = -1; /* NEVER */
|
2008-02-19 11:56:08 +08:00
|
|
|
snprintf(subject_buffer, sizeof(subject_buffer) - 1,
|
|
|
|
"%s"
|
|
|
|
"MIME-Version: 1.0\n"
|
|
|
|
"Content-Type: multipart/mixed;"
|
|
|
|
" boundary=\"%s%s\"\n"
|
|
|
|
"\n"
|
|
|
|
"This is a multi-part message in MIME "
|
|
|
|
"format.\n"
|
|
|
|
"--%s%s\n"
|
|
|
|
"Content-Type: text/plain; "
|
|
|
|
"charset=UTF-8; format=fixed\n"
|
|
|
|
"Content-Transfer-Encoding: 8bit\n\n",
|
|
|
|
extra_headers ? extra_headers : "",
|
|
|
|
mime_boundary_leader, opt->mime_boundary,
|
|
|
|
mime_boundary_leader, opt->mime_boundary);
|
|
|
|
extra_headers = subject_buffer;
|
|
|
|
|
2012-12-22 13:39:37 +08:00
|
|
|
if (opt->numbered_files)
|
|
|
|
strbuf_addf(&filename, "%d", opt->nr);
|
|
|
|
else
|
2012-12-22 14:06:01 +08:00
|
|
|
fmt_output_commit(&filename, commit, opt);
|
2008-02-19 11:56:08 +08:00
|
|
|
snprintf(buffer, sizeof(buffer) - 1,
|
2008-07-30 13:49:33 +08:00
|
|
|
"\n--%s%s\n"
|
2008-02-19 11:56:08 +08:00
|
|
|
"Content-Type: text/x-patch;"
|
2009-03-23 10:14:05 +08:00
|
|
|
" name=\"%s\"\n"
|
2008-02-19 11:56:08 +08:00
|
|
|
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
"Content-Disposition: %s;"
|
2009-03-23 10:14:05 +08:00
|
|
|
" filename=\"%s\"\n\n",
|
2008-02-19 11:56:08 +08:00
|
|
|
mime_boundary_leader, opt->mime_boundary,
|
2009-03-23 10:14:05 +08:00
|
|
|
filename.buf,
|
2008-02-19 11:56:08 +08:00
|
|
|
opt->no_inline ? "attachment" : "inline",
|
2009-03-23 10:14:05 +08:00
|
|
|
filename.buf);
|
2008-02-19 11:56:08 +08:00
|
|
|
opt->diffopt.stat_sep = buffer;
|
2009-03-23 10:14:05 +08:00
|
|
|
strbuf_release(&filename);
|
2008-02-19 11:56:08 +08:00
|
|
|
}
|
|
|
|
*subject_p = subject;
|
|
|
|
*extra_headers_p = extra_headers;
|
|
|
|
}
|
|
|
|
|
2012-01-05 05:48:45 +08:00
|
|
|
static void show_sig_lines(struct rev_info *opt, int status, const char *bol)
|
|
|
|
{
|
|
|
|
const char *color, *reset, *eol;
|
|
|
|
|
|
|
|
color = diff_get_color_opt(&opt->diffopt,
|
|
|
|
status ? DIFF_WHITESPACE : DIFF_FRAGINFO);
|
|
|
|
reset = diff_get_color_opt(&opt->diffopt, DIFF_RESET);
|
|
|
|
while (*bol) {
|
|
|
|
eol = strchrnul(bol, '\n');
|
|
|
|
printf("%s%.*s%s%s", color, (int)(eol - bol), bol, reset,
|
|
|
|
*eol ? "\n" : "");
|
|
|
|
bol = (*eol) ? (eol + 1) : eol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-19 06:53:23 +08:00
|
|
|
static void show_signature(struct rev_info *opt, struct commit *commit)
|
|
|
|
{
|
|
|
|
struct strbuf payload = STRBUF_INIT;
|
|
|
|
struct strbuf signature = STRBUF_INIT;
|
|
|
|
struct strbuf gpg_output = STRBUF_INIT;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (parse_signed_commit(commit->object.sha1, &payload, &signature) <= 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
status = verify_signed_buffer(payload.buf, payload.len,
|
|
|
|
signature.buf, signature.len,
|
2013-02-15 00:04:44 +08:00
|
|
|
&gpg_output, NULL);
|
2011-10-19 06:53:23 +08:00
|
|
|
if (status && !gpg_output.len)
|
|
|
|
strbuf_addstr(&gpg_output, "No signature\n");
|
|
|
|
|
2012-01-05 05:48:45 +08:00
|
|
|
show_sig_lines(opt, status, gpg_output.buf);
|
2011-10-19 06:53:23 +08:00
|
|
|
|
|
|
|
out:
|
|
|
|
strbuf_release(&gpg_output);
|
|
|
|
strbuf_release(&payload);
|
|
|
|
strbuf_release(&signature);
|
|
|
|
}
|
|
|
|
|
2012-01-05 05:51:28 +08:00
|
|
|
static int which_parent(const unsigned char *sha1, const struct commit *commit)
|
|
|
|
{
|
|
|
|
int nth;
|
|
|
|
const struct commit_list *parent;
|
|
|
|
|
|
|
|
for (nth = 0, parent = commit->parents; parent; parent = parent->next) {
|
|
|
|
if (!hashcmp(parent->item->object.sha1, sha1))
|
|
|
|
return nth;
|
|
|
|
nth++;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-01-05 08:23:12 +08:00
|
|
|
static int is_common_merge(const struct commit *commit)
|
|
|
|
{
|
|
|
|
return (commit->parents
|
|
|
|
&& commit->parents->next
|
|
|
|
&& !commit->parents->next->next);
|
|
|
|
}
|
|
|
|
|
2012-01-05 05:51:28 +08:00
|
|
|
static void show_one_mergetag(struct rev_info *opt,
|
|
|
|
struct commit_extra_header *extra,
|
|
|
|
struct commit *commit)
|
|
|
|
{
|
|
|
|
unsigned char sha1[20];
|
|
|
|
struct tag *tag;
|
|
|
|
struct strbuf verify_message;
|
|
|
|
int status, nth;
|
|
|
|
size_t payload_size, gpg_message_offset;
|
|
|
|
|
|
|
|
hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), sha1);
|
|
|
|
tag = lookup_tag(sha1);
|
|
|
|
if (!tag)
|
|
|
|
return; /* error message already given */
|
|
|
|
|
|
|
|
strbuf_init(&verify_message, 256);
|
|
|
|
if (parse_tag_buffer(tag, extra->value, extra->len))
|
|
|
|
strbuf_addstr(&verify_message, "malformed mergetag\n");
|
2012-01-05 08:23:12 +08:00
|
|
|
else if (is_common_merge(commit) &&
|
|
|
|
!hashcmp(tag->tagged->sha1,
|
|
|
|
commit->parents->next->item->object.sha1))
|
|
|
|
strbuf_addf(&verify_message,
|
|
|
|
"merged tag '%s'\n", tag->tag);
|
2012-01-05 05:51:28 +08:00
|
|
|
else if ((nth = which_parent(tag->tagged->sha1, commit)) < 0)
|
|
|
|
strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
|
|
|
|
tag->tag, tag->tagged->sha1);
|
|
|
|
else
|
|
|
|
strbuf_addf(&verify_message,
|
|
|
|
"parent #%d, tagged '%s'\n", nth + 1, tag->tag);
|
|
|
|
gpg_message_offset = verify_message.len;
|
|
|
|
|
|
|
|
payload_size = parse_signature(extra->value, extra->len);
|
2013-02-15 00:04:43 +08:00
|
|
|
status = -1;
|
|
|
|
if (extra->len > payload_size)
|
|
|
|
if (verify_signed_buffer(extra->value, payload_size,
|
|
|
|
extra->value + payload_size,
|
|
|
|
extra->len - payload_size,
|
2013-02-15 00:04:44 +08:00
|
|
|
&verify_message, NULL)) {
|
2013-02-15 00:04:43 +08:00
|
|
|
if (verify_message.len <= gpg_message_offset)
|
|
|
|
strbuf_addstr(&verify_message, "No signature\n");
|
|
|
|
else
|
|
|
|
status = 0;
|
|
|
|
}
|
2012-01-05 05:51:28 +08:00
|
|
|
|
|
|
|
show_sig_lines(opt, status, verify_message.buf);
|
|
|
|
strbuf_release(&verify_message);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void show_mergetag(struct rev_info *opt, struct commit *commit)
|
|
|
|
{
|
|
|
|
struct commit_extra_header *extra, *to_free;
|
|
|
|
|
|
|
|
to_free = read_commit_extra_headers(commit, NULL);
|
|
|
|
for (extra = to_free; extra; extra = extra->next) {
|
|
|
|
if (strcmp(extra->key, "mergetag"))
|
|
|
|
continue; /* not a merge tag */
|
|
|
|
show_one_mergetag(opt, extra, commit);
|
|
|
|
}
|
|
|
|
free_commit_extra_headers(to_free);
|
|
|
|
}
|
|
|
|
|
2008-04-29 16:32:59 +08:00
|
|
|
void show_log(struct rev_info *opt)
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
{
|
2008-10-10 03:12:12 +08:00
|
|
|
struct strbuf msgbuf = STRBUF_INIT;
|
2006-06-25 18:54:14 +08:00
|
|
|
struct log_info *log = opt->loginfo;
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
struct commit *commit = log->commit, *parent = log->parent;
|
|
|
|
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
|
2009-10-19 23:48:08 +08:00
|
|
|
const char *extra_headers = opt->extra_headers;
|
|
|
|
struct pretty_print_context ctx = {0};
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
|
|
|
|
opt->loginfo = NULL;
|
|
|
|
if (!opt->verbose_header) {
|
2008-05-04 18:36:54 +08:00
|
|
|
graph_show_commit(opt->graph);
|
|
|
|
|
2011-03-07 20:31:39 +08:00
|
|
|
if (!opt->graph)
|
2011-03-10 22:45:03 +08:00
|
|
|
put_revision_mark(opt, commit);
|
2009-02-14 06:10:41 +08:00
|
|
|
fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
|
2008-05-04 18:36:52 +08:00
|
|
|
if (opt->print_parents)
|
2006-05-03 22:59:00 +08:00
|
|
|
show_parents(commit, abbrev_commit);
|
2011-10-04 22:02:03 +08:00
|
|
|
if (opt->children.name)
|
|
|
|
show_children(opt, commit, abbrev_commit);
|
2008-10-28 03:51:59 +08:00
|
|
|
show_decorations(opt, commit);
|
2008-05-04 18:36:54 +08:00
|
|
|
if (opt->graph && !graph_is_commit_finished(opt->graph)) {
|
|
|
|
putchar('\n');
|
|
|
|
graph_show_remainder(opt->graph);
|
|
|
|
}
|
2006-08-07 20:11:23 +08:00
|
|
|
putchar(opt->diffopt.line_termination);
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-07-01 15:26:28 +08:00
|
|
|
* If use_terminator is set, we already handled any record termination
|
|
|
|
* at the end of the last record.
|
2008-04-29 16:32:59 +08:00
|
|
|
* Otherwise, add a diffopt.line_termination character before all
|
|
|
|
* entries but the first. (IOW, as a separator between entries)
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
*/
|
2008-05-04 18:36:54 +08:00
|
|
|
if (opt->shown_one && !opt->use_terminator) {
|
|
|
|
/*
|
|
|
|
* If entries are separated by a newline, the output
|
|
|
|
* should look human-readable. If the last entry ended
|
|
|
|
* with a newline, print the graph output before this
|
|
|
|
* newline. Otherwise it will end up as a completely blank
|
|
|
|
* line and will look like a gap in the graph.
|
|
|
|
*
|
|
|
|
* If the entry separator is not a newline, the output is
|
|
|
|
* primarily intended for programmatic consumption, and we
|
|
|
|
* never want the extra graph output before the entry
|
|
|
|
* separator.
|
|
|
|
*/
|
|
|
|
if (opt->diffopt.line_termination == '\n' &&
|
|
|
|
!opt->missing_newline)
|
|
|
|
graph_show_padding(opt->graph);
|
Fix "git log -z" behaviour
For commit messages, we should really put the "line_termination" when we
output the character in between different commits, *not* between the
commit and the diff. The diff goes hand-in-hand with the commit, it
shouldn't be separated from it with the termination character.
So this:
- uses the termination character for true inter-commit spacing
- uses a regular newline between the commit log and the diff
We had it the other way around.
For the normal case where the termination character is '\n', this
obviously doesn't change anything at all, since we just switched two
identical characters around. So it's very safe - it doesn't change any
normal usage, but it definitely fixes "git log -z".
By fixing "git log -z", you can now also do insane things like
git log -p -z |
grep -z "some patch expression" |
tr '\0' '\n' |
less -S
and you will see only those commits that have the "some patch expression"
in their commit message _or_ their patches.
(This is slightly different from 'git log -S"some patch expression"',
since the latter requires the expression to literally *change* in the
patch, while the "git log -p -z | grep .." approach will see it if it's
just an unchanged _part_ of the patch context)
Of course, if you actually do something like the above, you're probably
insane, but hey, it works!
Try the above command line for a demonstration (of course, you need to
change the "some patch expression" to be something relevant). The old
behaviour of "git log -p -z" was useless (and got things completely wrong
for log entries without patches).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-08 03:49:56 +08:00
|
|
|
putchar(opt->diffopt.line_termination);
|
2008-05-04 18:36:54 +08:00
|
|
|
}
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
opt->shown_one = 1;
|
|
|
|
|
2008-05-04 18:36:54 +08:00
|
|
|
/*
|
|
|
|
* If the history graph was requested,
|
|
|
|
* print the graph, up to this commit's line
|
|
|
|
*/
|
|
|
|
graph_show_commit(opt->graph);
|
|
|
|
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
/*
|
|
|
|
* Print header line of header..
|
|
|
|
*/
|
2006-04-19 07:45:27 +08:00
|
|
|
|
2006-05-05 10:30:52 +08:00
|
|
|
if (opt->commit_format == CMIT_FMT_EMAIL) {
|
2009-10-19 23:48:08 +08:00
|
|
|
log_write_email_headers(opt, commit, &ctx.subject, &extra_headers,
|
|
|
|
&ctx.need_8bit_cte);
|
2007-02-23 08:35:03 +08:00
|
|
|
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
|
2007-11-11 03:05:14 +08:00
|
|
|
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
|
2006-12-17 07:31:25 +08:00
|
|
|
if (opt->commit_format != CMIT_FMT_ONELINE)
|
|
|
|
fputs("commit ", stdout);
|
2008-05-25 15:07:21 +08:00
|
|
|
|
2011-03-07 20:31:39 +08:00
|
|
|
if (!opt->graph)
|
2011-03-10 22:45:03 +08:00
|
|
|
put_revision_mark(opt, commit);
|
2009-02-14 06:10:41 +08:00
|
|
|
fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit),
|
2006-12-17 07:31:25 +08:00
|
|
|
stdout);
|
2008-05-04 18:36:52 +08:00
|
|
|
if (opt->print_parents)
|
2006-05-07 05:42:08 +08:00
|
|
|
show_parents(commit, abbrev_commit);
|
2011-10-04 22:02:03 +08:00
|
|
|
if (opt->children.name)
|
|
|
|
show_children(opt, commit, abbrev_commit);
|
2006-05-25 03:19:47 +08:00
|
|
|
if (parent)
|
2006-04-19 07:45:27 +08:00
|
|
|
printf(" (from %s)",
|
2009-02-14 06:10:41 +08:00
|
|
|
find_unique_abbrev(parent->object.sha1,
|
2006-04-19 07:45:27 +08:00
|
|
|
abbrev_commit));
|
2008-10-28 03:51:59 +08:00
|
|
|
show_decorations(opt, commit);
|
2007-11-11 03:05:14 +08:00
|
|
|
printf("%s", diff_get_color_opt(&opt->diffopt, DIFF_RESET));
|
2008-05-04 18:36:54 +08:00
|
|
|
if (opt->commit_format == CMIT_FMT_ONELINE) {
|
|
|
|
putchar(' ');
|
|
|
|
} else {
|
|
|
|
putchar('\n');
|
|
|
|
graph_show_oneline(opt->graph);
|
|
|
|
}
|
2007-01-28 11:40:36 +08:00
|
|
|
if (opt->reflog_info) {
|
2008-05-04 18:36:54 +08:00
|
|
|
/*
|
|
|
|
* setup_revisions() ensures that opt->reflog_info
|
|
|
|
* and opt->graph cannot both be set,
|
|
|
|
* so we don't need to worry about printing the
|
|
|
|
* graph info here.
|
|
|
|
*/
|
2007-01-20 16:51:41 +08:00
|
|
|
show_reflog_message(opt->reflog_info,
|
2012-05-08 05:11:32 +08:00
|
|
|
opt->commit_format == CMIT_FMT_ONELINE,
|
|
|
|
opt->date_mode,
|
|
|
|
opt->date_mode_explicit);
|
2008-04-29 16:32:59 +08:00
|
|
|
if (opt->commit_format == CMIT_FMT_ONELINE)
|
2007-01-28 11:40:36 +08:00
|
|
|
return;
|
|
|
|
}
|
2006-04-19 07:45:27 +08:00
|
|
|
}
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
|
2012-01-05 05:51:28 +08:00
|
|
|
if (opt->show_signature) {
|
2011-10-19 06:53:23 +08:00
|
|
|
show_signature(opt, commit);
|
2012-01-05 05:51:28 +08:00
|
|
|
show_mergetag(opt, commit);
|
|
|
|
}
|
2011-10-19 06:53:23 +08:00
|
|
|
|
Add "--show-all" revision walker flag for debugging
It's really not very easy to visualize the commit walker, because - on
purpose - it obvously doesn't show the uninteresting commits!
This adds a "--show-all" flag to the revision walker, which will make
it show uninteresting commits too, and they'll have a '^' in front of
them (it also fixes a logic error for !verbose_header for boundary
commits - we should show the '-' even if left_right isn't shown).
A separate patch to gitk to teach it the new '^' was sent
to paulus. With the change in place, it actually is interesting
even for the cases that git doesn't have any problems with, ie
for the kernel you can do:
gitk -d --show-all v2.6.24..
and you see just how far down it has to parse things to see it all. The
use of "-d" is a good idea, since the date-ordered toposort is much better
at showing why it goes deep down (ie the date of some of those commits
after 2.6.24 is much older, because they were merged from trees that
weren't rebased).
So I think this is a useful feature even for non-debugging - just to
visualize what git does internally more.
When it actually breaks out due to the "everybody_uninteresting()"
case, it adds the uninteresting commits (both the one it's looking at
now, and the list of pending ones) to the list
This way, we really list *all* the commits we've looked at.
Because we now end up listing commits we may not even have been parsed
at all "show_log" and "show_commit" need to protect against commits
that don't have a commit buffer entry.
That second part is debatable just how it should work. Maybe we shouldn't
show such entries at all (with this patch those entries do get shown, they
just don't get any message shown with them). But I think this is a useful
case.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-10 06:02:07 +08:00
|
|
|
if (!commit->buffer)
|
|
|
|
return;
|
|
|
|
|
2012-10-18 09:51:47 +08:00
|
|
|
if (opt->show_notes) {
|
|
|
|
int raw;
|
|
|
|
struct strbuf notebuf = STRBUF_INIT;
|
|
|
|
|
|
|
|
raw = (opt->commit_format == CMIT_FMT_USERFORMAT);
|
|
|
|
format_display_notes(commit->object.sha1, ¬ebuf,
|
|
|
|
get_log_output_encoding(), raw);
|
|
|
|
ctx.notes_message = notebuf.len
|
|
|
|
? strbuf_detach(¬ebuf, NULL)
|
|
|
|
: xcalloc(1, 1);
|
|
|
|
}
|
|
|
|
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
/*
|
|
|
|
* And then the pretty-printed message itself
|
|
|
|
*/
|
2013-02-12 18:17:38 +08:00
|
|
|
if (ctx.need_8bit_cte >= 0 && opt->add_signoff)
|
|
|
|
ctx.need_8bit_cte =
|
|
|
|
has_non_ascii(fmt_name(getenv("GIT_COMMITTER_NAME"),
|
|
|
|
getenv("GIT_COMMITTER_EMAIL")));
|
2009-10-19 23:48:08 +08:00
|
|
|
ctx.date_mode = opt->date_mode;
|
log: respect date_mode_explicit with --format:%gd
When we show a reflog selector (e.g., via "git log -g"), we
perform some DWIM magic: while we normally show the entry's
index (e.g., HEAD@{1}), if the user has given us a date
with "--date", then we show a date-based select (e.g.,
HEAD@{yesterday}).
However, we don't want to trigger this magic if the
alternate date format we got was from the "log.date"
configuration; that is not sufficiently strong context for
us to invoke this particular magic. To fix this, commit
f4ea32f (improve reflog date/number heuristic, 2009-09-24)
introduced a "date_mode_explicit" flag in rev_info. This
flag is set only when we see a "--date" option on the
command line, and we a vanilla date to the reflog code if
the date was not explicit.
Later, commit 8f8f547 (Introduce new pretty formats %g[sdD]
for reflog information, 2009-10-19) added another way to
show selectors, and it did not respect the date_mode_explicit
flag from f4ea32f.
This patch propagates the date_mode_explicit flag to the
pretty-print code, which can then use it to pass the
appropriate date field to the reflog code. This brings the
behavior of "%gd" in line with the other formats, and means
that its output is independent of any user configuration.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-04 13:25:18 +08:00
|
|
|
ctx.date_mode_explicit = opt->date_mode_explicit;
|
2009-10-19 23:48:08 +08:00
|
|
|
ctx.abbrev = opt->diffopt.abbrev;
|
|
|
|
ctx.after_subject = extra_headers;
|
2011-05-27 06:28:17 +08:00
|
|
|
ctx.preserve_subject = opt->preserve_subject;
|
2009-10-19 23:48:10 +08:00
|
|
|
ctx.reflog_info = opt->reflog_info;
|
2011-05-27 06:27:49 +08:00
|
|
|
ctx.fmt = opt->commit_format;
|
2013-01-06 05:26:41 +08:00
|
|
|
ctx.mailmap = opt->mailmap;
|
2012-12-18 06:56:49 +08:00
|
|
|
ctx.color = opt->diffopt.use_color;
|
2011-05-27 06:27:49 +08:00
|
|
|
pretty_print_commit(&ctx, commit, &msgbuf);
|
2012-10-18 11:48:25 +08:00
|
|
|
|
|
|
|
if (opt->add_signoff)
|
2013-02-12 18:17:38 +08:00
|
|
|
append_signoff(&msgbuf, 0, APPEND_SIGNOFF_DEDUP);
|
2012-10-18 11:48:25 +08:00
|
|
|
|
2012-10-18 10:02:46 +08:00
|
|
|
if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
|
2012-10-18 12:27:22 +08:00
|
|
|
ctx.notes_message && *ctx.notes_message) {
|
|
|
|
if (ctx.fmt == CMIT_FMT_EMAIL) {
|
|
|
|
strbuf_addstr(&msgbuf, "---\n");
|
|
|
|
opt->shown_dashes = 1;
|
|
|
|
}
|
2012-10-18 10:02:46 +08:00
|
|
|
strbuf_addstr(&msgbuf, ctx.notes_message);
|
2012-10-18 12:27:22 +08:00
|
|
|
}
|
2006-06-01 06:11:49 +08:00
|
|
|
|
2008-05-04 18:36:54 +08:00
|
|
|
if (opt->show_log_size) {
|
2007-09-10 18:35:06 +08:00
|
|
|
printf("log size %i\n", (int)msgbuf.len);
|
2008-05-04 18:36:54 +08:00
|
|
|
graph_show_oneline(opt->graph);
|
|
|
|
}
|
2007-07-21 02:15:13 +08:00
|
|
|
|
2008-05-04 18:36:54 +08:00
|
|
|
/*
|
|
|
|
* Set opt->missing_newline if msgbuf doesn't
|
|
|
|
* end in a newline (including if it is empty)
|
|
|
|
*/
|
|
|
|
if (!msgbuf.len || msgbuf.buf[msgbuf.len - 1] != '\n')
|
|
|
|
opt->missing_newline = 1;
|
|
|
|
else
|
|
|
|
opt->missing_newline = 0;
|
|
|
|
|
|
|
|
if (opt->graph)
|
|
|
|
graph_show_commit_msg(opt->graph, &msgbuf);
|
|
|
|
else
|
2008-03-21 23:05:06 +08:00
|
|
|
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
|
2008-05-04 18:36:54 +08:00
|
|
|
if (opt->use_terminator) {
|
|
|
|
if (!opt->missing_newline)
|
|
|
|
graph_show_padding(opt->graph);
|
2012-05-01 04:28:25 +08:00
|
|
|
putchar(opt->diffopt.line_termination);
|
2008-05-04 18:36:54 +08:00
|
|
|
}
|
|
|
|
|
2007-09-10 18:35:06 +08:00
|
|
|
strbuf_release(&msgbuf);
|
2012-10-18 09:51:47 +08:00
|
|
|
free(ctx.notes_message);
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
}
|
|
|
|
|
Common option parsing for "git log --diff" and friends
This basically does a few things that are sadly somewhat interdependent,
and nontrivial to split out
- get rid of "struct log_tree_opt"
The fields in "log_tree_opt" are moved into "struct rev_info", and all
users of log_tree_opt are changed to use the rev_info struct instead.
- add the parsing for the log_tree_opt arguments to "setup_revision()"
- make setup_revision set a flag (revs->diff) if the diff-related
arguments were used. This allows "git log" to decide whether it wants
to show diffs or not.
- make setup_revision() also initialize the diffopt part of rev_info
(which we had from before, but we just didn't initialize it)
- make setup_revision() do all the "finishing touches" on it all (it will
do the proper flag combination logic, and call "diff_setup_done()")
Now, that was the easy and straightforward part.
The slightly more involved part is that some of the programs that want to
use the new-and-improved rev_info parsing don't actually want _commits_,
they may want tree'ish arguments instead. That meant that I had to change
setup_revision() to parse the arguments not into the "revs->commits" list,
but into the "revs->pending_objects" list.
Then, when we do "prepare_revision_walk()", we walk that list, and create
the sorted commit list from there.
This actually cleaned some stuff up, but it's the less obvious part of the
patch, and re-organized the "revision.c" logic somewhat. It actually paves
the way for splitting argument parsing _entirely_ out of "revision.c",
since now the argument parsing really is totally independent of the commit
walking: that didn't use to be true, since there was lots of overlap with
get_commit_reference() handling etc, now the _only_ overlap is the shared
(and trivial) "add_pending_object()" thing.
However, I didn't do that file split, just because I wanted the diff
itself to be smaller, and show the actual changes more clearly. If this
gets accepted, I'll do further cleanups then - that includes the file
split, but also using the new infrastructure to do a nicer "git diff" etc.
Even in this form, it actually ends up removing more lines than it adds.
It's nice to note how simple and straightforward this makes the built-in
"git log" command, even though it continues to support all the diff flags
too. It doesn't get much simpler that this.
I think this is worth merging soonish, because it does allow for future
cleanup and even more sharing of code. However, it obviously touches
"revision.c", which is subtle. I've tested that it passes all the tests we
have, and it passes my "looks sane" detector, but somebody else should
also give it a good look-over.
[jc: squashed the original and three "oops this too" updates, with
another fix-up.]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-15 07:52:13 +08:00
|
|
|
int log_tree_diff_flush(struct rev_info *opt)
|
2006-04-09 16:11:11 +08:00
|
|
|
{
|
2012-10-18 12:27:22 +08:00
|
|
|
opt->shown_dashes = 0;
|
2006-04-09 16:11:11 +08:00
|
|
|
diffcore_std(&opt->diffopt);
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
|
2006-04-09 16:11:11 +08:00
|
|
|
if (diff_queue_is_empty()) {
|
|
|
|
int saved_fmt = opt->diffopt.output_format;
|
|
|
|
opt->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT;
|
|
|
|
diff_flush(&opt->diffopt);
|
|
|
|
opt->diffopt.output_format = saved_fmt;
|
|
|
|
return 0;
|
|
|
|
}
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
|
2006-06-28 06:08:19 +08:00
|
|
|
if (opt->loginfo && !opt->no_commit_id) {
|
2008-04-29 16:32:59 +08:00
|
|
|
show_log(opt);
|
2007-10-10 00:35:22 +08:00
|
|
|
if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&
|
|
|
|
opt->verbose_header &&
|
2006-06-28 06:08:19 +08:00
|
|
|
opt->commit_format != CMIT_FMT_ONELINE) {
|
2012-11-14 02:09:07 +08:00
|
|
|
/*
|
|
|
|
* When showing a verbose header (i.e. log message),
|
|
|
|
* and not in --pretty=oneline format, we would want
|
|
|
|
* an extra newline between the end of log and the
|
|
|
|
* diff/diffstat output for readability.
|
|
|
|
*/
|
2006-06-28 06:08:19 +08:00
|
|
|
int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
|
2010-05-26 15:08:03 +08:00
|
|
|
if (opt->diffopt.output_prefix) {
|
|
|
|
struct strbuf *msg = NULL;
|
|
|
|
msg = opt->diffopt.output_prefix(&opt->diffopt,
|
|
|
|
opt->diffopt.output_prefix_data);
|
|
|
|
fwrite(msg->buf, msg->len, 1, stdout);
|
|
|
|
}
|
2012-11-14 02:09:07 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We may have shown three-dashes line early
|
|
|
|
* between notes and the log message, in which
|
|
|
|
* case we only want a blank line after the
|
|
|
|
* notes without (an extra) three-dashes line.
|
|
|
|
* Otherwise, we show the three-dashes line if
|
|
|
|
* we are showing the patch with diffstat, but
|
|
|
|
* in that case, there is no extra blank line
|
|
|
|
* after the three-dashes line.
|
|
|
|
*/
|
|
|
|
if (!opt->shown_dashes &&
|
|
|
|
(pch & opt->diffopt.output_format) == pch)
|
|
|
|
printf("---");
|
|
|
|
putchar('\n');
|
2006-06-28 06:08:19 +08:00
|
|
|
}
|
|
|
|
}
|
2006-04-09 16:11:11 +08:00
|
|
|
diff_flush(&opt->diffopt);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Common option parsing for "git log --diff" and friends
This basically does a few things that are sadly somewhat interdependent,
and nontrivial to split out
- get rid of "struct log_tree_opt"
The fields in "log_tree_opt" are moved into "struct rev_info", and all
users of log_tree_opt are changed to use the rev_info struct instead.
- add the parsing for the log_tree_opt arguments to "setup_revision()"
- make setup_revision set a flag (revs->diff) if the diff-related
arguments were used. This allows "git log" to decide whether it wants
to show diffs or not.
- make setup_revision() also initialize the diffopt part of rev_info
(which we had from before, but we just didn't initialize it)
- make setup_revision() do all the "finishing touches" on it all (it will
do the proper flag combination logic, and call "diff_setup_done()")
Now, that was the easy and straightforward part.
The slightly more involved part is that some of the programs that want to
use the new-and-improved rev_info parsing don't actually want _commits_,
they may want tree'ish arguments instead. That meant that I had to change
setup_revision() to parse the arguments not into the "revs->commits" list,
but into the "revs->pending_objects" list.
Then, when we do "prepare_revision_walk()", we walk that list, and create
the sorted commit list from there.
This actually cleaned some stuff up, but it's the less obvious part of the
patch, and re-organized the "revision.c" logic somewhat. It actually paves
the way for splitting argument parsing _entirely_ out of "revision.c",
since now the argument parsing really is totally independent of the commit
walking: that didn't use to be true, since there was lots of overlap with
get_commit_reference() handling etc, now the _only_ overlap is the shared
(and trivial) "add_pending_object()" thing.
However, I didn't do that file split, just because I wanted the diff
itself to be smaller, and show the actual changes more clearly. If this
gets accepted, I'll do further cleanups then - that includes the file
split, but also using the new infrastructure to do a nicer "git diff" etc.
Even in this form, it actually ends up removing more lines than it adds.
It's nice to note how simple and straightforward this makes the built-in
"git log" command, even though it continues to support all the diff flags
too. It doesn't get much simpler that this.
I think this is worth merging soonish, because it does allow for future
cleanup and even more sharing of code. However, it obviously touches
"revision.c", which is subtle. I've tested that it passes all the tests we
have, and it passes my "looks sane" detector, but somebody else should
also give it a good look-over.
[jc: squashed the original and three "oops this too" updates, with
another fix-up.]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-15 07:52:13 +08:00
|
|
|
static int do_diff_combined(struct rev_info *opt, struct commit *commit)
|
2006-04-09 16:11:11 +08:00
|
|
|
{
|
2011-12-17 18:20:07 +08:00
|
|
|
diff_tree_combined_merge(commit, opt->dense_combined_merges, opt);
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
return !opt->loginfo;
|
2006-04-09 16:11:11 +08:00
|
|
|
}
|
|
|
|
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
/*
|
|
|
|
* Show the diff of a commit.
|
|
|
|
*
|
|
|
|
* Return true if we printed any log info messages
|
|
|
|
*/
|
|
|
|
static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log_info *log)
|
2006-04-09 16:11:11 +08:00
|
|
|
{
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
int showed_log;
|
2006-04-09 16:11:11 +08:00
|
|
|
struct commit_list *parents;
|
2013-03-28 16:19:34 +08:00
|
|
|
unsigned const char *sha1;
|
2006-04-09 16:11:11 +08:00
|
|
|
|
2008-08-11 14:46:25 +08:00
|
|
|
if (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
return 0;
|
|
|
|
|
2013-03-28 16:19:34 +08:00
|
|
|
parse_commit(commit);
|
|
|
|
sha1 = commit->tree->object.sha1;
|
|
|
|
|
2006-04-09 16:11:11 +08:00
|
|
|
/* Root commit? */
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
parents = commit->parents;
|
|
|
|
if (!parents) {
|
2006-10-27 00:52:39 +08:00
|
|
|
if (opt->show_root_diff) {
|
|
|
|
diff_root_tree_sha1(sha1, "", &opt->diffopt);
|
|
|
|
log_tree_diff_flush(opt);
|
|
|
|
}
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
return !opt->loginfo;
|
2006-04-09 16:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* More than one parent? */
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
if (parents && parents->next) {
|
2006-04-09 16:11:11 +08:00
|
|
|
if (opt->ignore_merges)
|
|
|
|
return 0;
|
|
|
|
else if (opt->combine_merges)
|
|
|
|
return do_diff_combined(opt, commit);
|
2010-02-10 09:11:49 +08:00
|
|
|
else if (opt->first_parent_only) {
|
|
|
|
/*
|
|
|
|
* Generate merge log entry only for the first
|
|
|
|
* parent, showing summary diff of the others
|
|
|
|
* we merged _in_.
|
|
|
|
*/
|
2013-03-28 16:19:34 +08:00
|
|
|
parse_commit(parents->item);
|
|
|
|
diff_tree_sha1(parents->item->tree->object.sha1,
|
|
|
|
sha1, "", &opt->diffopt);
|
2010-02-10 09:11:49 +08:00
|
|
|
log_tree_diff_flush(opt);
|
|
|
|
return !opt->loginfo;
|
|
|
|
}
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
|
|
|
|
/* If we show individual diffs, show the parent info */
|
|
|
|
log->parent = parents->item;
|
2006-04-09 16:11:11 +08:00
|
|
|
}
|
|
|
|
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
showed_log = 0;
|
|
|
|
for (;;) {
|
2006-04-09 16:11:11 +08:00
|
|
|
struct commit *parent = parents->item;
|
|
|
|
|
2013-03-28 16:19:34 +08:00
|
|
|
parse_commit(parent);
|
|
|
|
diff_tree_sha1(parent->tree->object.sha1,
|
|
|
|
sha1, "", &opt->diffopt);
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
log_tree_diff_flush(opt);
|
|
|
|
|
|
|
|
showed_log |= !opt->loginfo;
|
|
|
|
|
|
|
|
/* Set up the log info for the next parent, if any.. */
|
|
|
|
parents = parents->next;
|
|
|
|
if (!parents)
|
|
|
|
break;
|
|
|
|
log->parent = parents->item;
|
|
|
|
opt->loginfo = log;
|
|
|
|
}
|
|
|
|
return showed_log;
|
|
|
|
}
|
|
|
|
|
|
|
|
int log_tree_commit(struct rev_info *opt, struct commit *commit)
|
|
|
|
{
|
|
|
|
struct log_info log;
|
2006-04-19 07:45:27 +08:00
|
|
|
int shown;
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
|
|
|
|
log.commit = commit;
|
|
|
|
log.parent = NULL;
|
|
|
|
opt->loginfo = &log;
|
|
|
|
|
2006-04-19 07:45:27 +08:00
|
|
|
shown = log_tree_diff(opt, commit, &log);
|
|
|
|
if (!shown && opt->loginfo && opt->always_show_header) {
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
log.parent = NULL;
|
2008-04-29 16:32:59 +08:00
|
|
|
show_log(opt);
|
2006-04-19 07:45:27 +08:00
|
|
|
shown = 1;
|
2006-04-09 16:11:11 +08:00
|
|
|
}
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18 02:59:32 +08:00
|
|
|
opt->loginfo = NULL;
|
2007-06-30 01:40:46 +08:00
|
|
|
maybe_flush_or_die(stdout, "stdout");
|
2006-04-19 07:45:27 +08:00
|
|
|
return shown;
|
2006-04-09 16:11:11 +08:00
|
|
|
}
|