All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Will Palmer <wmpalmer@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH 4/5] shortlog: Document and test --format option
Date: Mon, 3 May 2010 21:59:55 -0500	[thread overview]
Message-ID: <20100504025954.GE7322@progeny.tock> (raw)
In-Reply-To: <20100504025217.GA7322@progeny.tock>

Do not document the --pretty synonym, since it takes too long to
explain the name to people.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 - Pass HEAD to shortlog
 - Use {asterisk} helper for manual

 Documentation/git-shortlog.txt |    8 ++++++
 t/t4201-shortlog.sh            |   53 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt
index f11ea90..a820fcb 100644
--- a/Documentation/git-shortlog.txt
+++ b/Documentation/git-shortlog.txt
@@ -44,6 +44,14 @@ OPTIONS
 --email::
 	Show the email address of each author.
 
+--format[='<format>']::
+	Instead of the commit subject, use some other information to
+	describe each commit.  '<format>' can be any string accepted
+	by the `--format` option of 'git log', such as '{asterisk} [%h] %s'.
+	(See the "PRETTY FORMATS" section of linkgit:git-log[1].)
+
+	Each pretty-printed commit will be rewrapped before it is shown.
+
 -w[<width>[,<indent1>[,<indent2>]]]::
 	Linewrap the output by wrapping each line at `width`.  The first
 	line of each entry is indented by `indent1` spaces, and the second
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index 6bfd0c0..13fdeb2 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -39,7 +39,58 @@ test_expect_success 'setup' '
 
 	echo 6 >a1 &&
 	git commit --quiet -m "Commit by someone else" \
-		--author="Someone else <not!me>" a1
+		--author="Someone else <not!me>" a1 &&
+
+	cat >expect.template <<-\EOF
+	A U Thor (5):
+	      SUBJECT
+	      SUBJECT
+	      SUBJECT
+	      SUBJECT
+	      SUBJECT
+
+	Someone else (1):
+	      SUBJECT
+
+	EOF
+'
+
+fuzz() {
+	file=$1 &&
+	sed "
+			s/$_x40/OBJECT_NAME/g
+			s/$_x05/OBJID/g
+			s/^ \{6\}[CTa].*/      SUBJECT/g
+			s/^ \{8\}[^ ].*/        CONTINUATION/g
+		" <"$file" >"$file.fuzzy" &&
+	sed "/CONTINUATION/ d" <"$file.fuzzy"
+}
+
+test_expect_success 'default output format' '
+	git shortlog HEAD >log &&
+	fuzz log >log.predictable &&
+	test_cmp expect.template log.predictable
+'
+
+test_expect_success 'pretty format' '
+	sed s/SUBJECT/OBJECT_NAME/ expect.template >expect &&
+	git shortlog --format="%H" HEAD >log &&
+	fuzz log >log.predictable &&
+	test_cmp expect log.predictable
+'
+
+test_expect_failure '--abbrev' '
+	sed s/SUBJECT/OBJID/ expect.template >expect &&
+	git shortlog --format="%h" --abbrev=5 HEAD >log &&
+	fuzz log >log.predictable &&
+	test_cmp expect log.predictable
+'
+
+test_expect_success 'output from user-defined format is re-wrapped' '
+	sed "s/SUBJECT/two lines/" expect.template >expect &&
+	git shortlog --format="two%nlines" HEAD >log &&
+	fuzz log >log.predictable &&
+	test_cmp expect log.predictable
 '
 
 test_expect_success 'shortlog wrapping' '
-- 
1.6.5

  parent reply	other threads:[~2010-05-04  2:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-02 16:12 What's cooking in git.git (May 2010, #01; Sun, 2) Junio C Hamano
2010-05-02 20:01 ` Johannes Sixt
2010-05-08 15:13   ` [PATCH 1/2] Have set_try_to_free_routine return the previous routine Johannes Sixt
2010-05-08 15:18     ` [PATCH 2/2] Do not call release_pack_memory in malloc wrappers when GIT_TRACE is used Johannes Sixt
2010-05-03 12:48 ` What's cooking in git.git (May 2010, #01; Sun, 2) Jakub Narebski
2010-05-03 18:54 ` Will Palmer
2010-05-04  0:25   ` jn/shortlog (Re: What's cooking in git.git (May 2010, #01; Sun, 2)) Jonathan Nieder
2010-05-04  1:56     ` jn/shortlog Jonathan Nieder
2010-05-04  2:52       ` [PATCH v2 0/5] jn/shortlog Jonathan Nieder
2010-05-04  2:57         ` [PATCH 1/5] Documentation/shortlog: scripted users should not rely on implicit HEAD Jonathan Nieder
2010-05-04  2:57         ` [PATCH 2/5] t4201 (shortlog): guard setup with test_expect_success Jonathan Nieder
2010-05-04  2:58         ` [PATCH 3/5] t4201 (shortlog): Test output format with multiple authors Jonathan Nieder
2010-05-04  2:59         ` Jonathan Nieder [this message]
2010-05-04  3:18         ` [PATCH 5/5] pretty: Respect --abbrev option Jonathan Nieder
2010-05-04  8:34           ` Jonathan Nieder
2010-05-08 16:43 ` What's cooking in git.git (May 2010, #01; Sun, 2) Clemens Buchacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100504025954.GE7322@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=wmpalmer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.