Skip to content

Commit

Permalink
Add --log-size to git log to print message size
Browse files Browse the repository at this point in the history
With this option git-log prints log message size
just before the corresponding message.

Porcelain tools could use this to speedup parsing
of git-log output.

Note that size refers to log message only. If also
patch content is shown its size is not included.

In case it is not possible to know the size upfront
size value is set to zero.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
mcostalba authored and gitster committed Aug 14, 2007
1 parent fb13227 commit 9fa3465
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Documentation/git-log.txt
Expand Up @@ -64,6 +64,13 @@ include::pretty-options.txt[]
--follow::
Continue listing the history of a file beyond renames.

--log-size::
Before the log message print out its size in bytes. Intended
mainly for porcelain tools consumption. If git is unable to
produce a valid value size is set to zero.
Note that only message is considered, if also a diff is shown
its size is not included.

<paths>...::
Show only commits that affect the specified paths.

Expand Down
3 changes: 3 additions & 0 deletions log-tree.c
Expand Up @@ -295,6 +295,9 @@ void show_log(struct rev_info *opt, const char *sep)
if (opt->add_signoff)
len = append_signoff(&msgbuf, &msgbuf_len, len,
opt->add_signoff);
if (opt->show_log_size)
printf("log size %i\n", len);

printf("%s%s%s", msgbuf, extra, sep);
free(msgbuf);
}
Expand Down
4 changes: 4 additions & 0 deletions revision.c
Expand Up @@ -1150,6 +1150,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
die("unknown date format %s", arg);
continue;
}
if (!strcmp(arg, "--log-size")) {
revs->show_log_size = 1;
continue;
}

/*
* Grepping the commit log
Expand Down
1 change: 1 addition & 0 deletions revision.h
Expand Up @@ -81,6 +81,7 @@ struct rev_info {
const char *log_reencode;
const char *subject_prefix;
int no_inline;
int show_log_size;

/* Filter by commit log message */
struct grep_opt *grep_filter;
Expand Down

0 comments on commit 9fa3465

Please sign in to comment.