log: add %S option (like --source) to log --format

Make it possible to write for example

        git log --format="%H,%S"

where the %S at the end is a new placeholder that prints out the ref
(tag/branch) for each commit.

Using %d might seem like an alternative but it only shows the ref for the last
commit in the branch.

Signed-off-by: Issac Trotts <issactrotts@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Issac Trotts
2019-01-10 22:30:46 -08:00
committed by Junio C Hamano
parent ecbdaf0899
commit ad6f028f06
7 changed files with 71 additions and 1 deletions

View File

@ -203,7 +203,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
rev->diffopt.filter || rev->diffopt.flags.follow_renames)
rev->always_show_header = 0;
if (source) {
if (source || w.source) {
init_revision_sources(&revision_sources);
rev->sources = &revision_sources;
}