threads / discuss / 14448

Re: [git pull] core/softirq for v2.6.27

Subject: Re: [git pull] core/softirq for v2.6.27

## tl;dr

5 messages between Jul 14, 2008 and Jul 14, 2008.

replies: 4people: 2as markdown or json

Linus Torvalds· Jul 14, 2008, 17:11 UTC · lore
On Mon, 14 Jul 2008, Andrew Morton wrote:
> 
> This was a git-shortlog feature request ;)
Heh. You should cc git or Junio if so.

The way shortlog is done (very different from regular logs, due to the whole organize-by-name etc thing) that is sadly pretty ugly to do: we don't support the pretty-formats etc. And the way things are done, adding support for the generic "--pretty=xyz" (including custom formats) would be pretty painful.

So it would have to be a total special-case.

Junio, git people - what Andrew is asking for is for git shortlog to show the commit ID (in shortened form) at the end:

Show 5 quoted lines
> > It would be nice if these short-form summaries were to include the
> > commit IDs.  eg:
> > 
> > Carlos R. Mafra (1):
> >       Remove argument from open_softirq which is always NULL (962cf36)

and I do think it would be nice. I've had some other things I would find shortlog format additions useful for (size of patch etc), so if it could be somehow generalized that would be wonderful.

As it is, that is one ugly function that only takes the one-liner thing - at least partly because of how it traditionally worked (as a a filter over the log messages, rather than as a "git shortlog xyz..abc" kind of stand-alone thing).

		Linus
Linus Torvalds· Jul 14, 2008, 17:23 UTC · re: Linus Torvalds · lore
On Mon, 14 Jul 2008, Linus Torvalds wrote:
Show 5 quoted lines
> 
> As it is, that is one ugly function that only takes the one-liner thing - 
> at least partly because of how it traditionally worked (as a a filter over 
> the log messages, rather than as a "git shortlog xyz..abc" kind of 
> stand-alone thing).

Heh. I guess you _could_ use the filter capability here (but it will sometimes truncate the line, so..)

Some really ugly scripting like this will do it:
	#!/bin/sh
	git log --pretty='format:commit %H
	Author: %an <%ae>
	
	  %s (%h)
	' $@ | git shortlog

where we use the regular "git log" with a user-supplied format to generate a log with the subject line and the shortened hash appended (the "%s (%h)" part) and then we use "git shortlog" as a filter to sort things together by author etc.

There is absolutely _nothing_ that git won't do with a little bit of scripting, but I do have to admit that this one isn't a wonderfully beautiful script ;)

		Linus
Johannes Schindelin· Jul 14, 2008, 17:46 UTC · re: Linus Torvalds · lore
Hi,
On Mon, 14 Jul 2008, Linus Torvalds wrote:
Show 5 quoted lines
> 	git log --pretty='format:commit %H
> 	Author: %an <%ae>
> 	
> 	  %s (%h)
> 	' $@ | git shortlog
Surely you meant
 	git log --pretty='format:commit %H%nAuthor: %an <%ae>%n%n    %s (%h)' \
		$@ | git shortlog

Note that I do not think it would be all that hard to teach shortlog the --pretty option.

Ciao, Dscho

Johannes Schindelin· Jul 14, 2008, 18:08 UTC · re: Johannes Schindelin · lore

[PATCH] shortlog: support --pretty=format: option

With this patch, the user can override the default setting, to print the commit messages using a user format instead of the onelines of the commits. Example:

	$ git shortlog --pretty='format:%s (%h)' <commit>..

Note that shortlog will only respect a user format setting, as the other formats do not make much sense.

Wished for by Andrew Morton.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Mon, 14 Jul 2008, Johannes Schindelin wrote:
	> Note that I do not think it would be all that hard to teach 
	> shortlog the --pretty option.
	Well...
 builtin-shortlog.c |   11 +++++++++++
 shortlog.h         |    1 +
 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 0136202..f8bcbfc 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -154,6 +154,15 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
 	if (!author)
 		die("Missing author: %s",
 		    sha1_to_hex(commit->object.sha1));
+	if (log->user_format) {
+		struct strbuf buf = STRBUF_INIT;
+
+		pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,
+			DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
+		insert_one_record(log, author, buf.buf);
+		strbuf_release(&buf);
+		return;
+	}
 	if (*buffer)
 		buffer++;
 	insert_one_record(log, author, !*buffer ? "<none>" : buffer);
@@ -271,6 +280,8 @@ parse_done:
 		usage_with_options(shortlog_usage, options);
 	}
 
+	log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
+
 	/* assume HEAD if from a tty */
 	if (!nongit && !rev.pending.nr && isatty(0))
 		add_head_to_pending(&rev);
diff --git a/shortlog.h b/shortlog.h
index 31ff491..6608ee8 100644
--- a/shortlog.h
+++ b/shortlog.h
@@ -11,6 +11,7 @@ struct shortlog {
 	int wrap;
 	int in1;
 	int in2;
+	int user_format;
 
 	char *common_repo_prefix;
 	int email;
-- 
1.5.6.2.511.ge432a
Linus Torvalds· Jul 14, 2008, 17:46 UTC · re: Linus Torvalds · lore
On Mon, 14 Jul 2008, Linus Torvalds wrote:
Show 6 quoted lines
> 
> Some really ugly scripting like this will do it:
> 
> 	#!/bin/sh
> 	git log --pretty='format:commit %H
> 	Author: %an <%ae>
Side note: you can make it a one-liner with '%n' (not \n') if you want, ie
	#!/bin/sh
	git log --pretty='format:commit %H%nAuthor: %an <%ae>%n%n %s (%h)%n' $@ | git shortlog
if you want to make it look even more like line noise.

And if you want to be _really_ fancy, you can even make it a git alias. Just add somethign like this to your ~/.gitconfig file:

	[alias]
		mylog=!GIT_PAGER='git --no-pager shortlog' git log --pretty='format:commit %H%nAuthor: %an <%ae>%n%n %s (%h)%n'
which is the _real_ git-mans way to do it.

It does the "shortlog" output by using "git shortlog" as a pager, but then to avoid recursion, we have to turn off paging of shortlog output itself. Heh. And the reason to do that is that the arguments always go to the end, so since we want to give the args to "git log", we can't put the pipe at the end.

I will have to go wash up after writing the above.
		Linus

← back to recent threads