All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] git-shortlog: make common repository prefix configurable with .mailmap
@ 2006-11-25  8:11 Junio C Hamano
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 51+ messages in thread
From: Junio C Hamano @ 2006-11-25  8:11 UTC (permalink / raw)
  To: git

The code had "/pub/scm/linux/kernel/git/" hardcoded which was
too specific to the kernel project.

With this, a line in the .mailmap file:

	# repo-abbrev: /pub/scm/linux/kernel/git/

can be used to cause the substring to be abbreviated to /.../
on the title line of the commit message.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 builtin-shortlog.c    |   24 ++++++++++++++++++++++--
 contrib/mailmap.linux |    2 ++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index bdd952c..b5b13de 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -9,6 +9,8 @@
 static const char shortlog_usage[] =
 "git-shortlog [-n] [-s] [<commit-id>... ]";
 
+static char *common_repo_prefix;
+
 static int compare_by_number(const void *a1, const void *a2)
 {
 	const struct path_list_item *i1 = a1, *i2 = a2;
@@ -35,8 +37,26 @@ static int read_mailmap(const char *filename)
 		char *end_of_name, *left_bracket, *right_bracket;
 		char *name, *email;
 		int i;
-		if (buffer[0] == '#')
+		if (buffer[0] == '#') {
+			static const char abbrev[] = "# repo-abbrev:";
+			int abblen = sizeof(abbrev) - 1;
+			int len = strlen(buffer);
+
+			if (len && buffer[len - 1] == '\n')
+				buffer[--len] = 0;
+			if (!strncmp(buffer, abbrev, abblen)) {
+				char *cp;
+
+				if (common_repo_prefix)
+					free(common_repo_prefix);
+				common_repo_prefix = xmalloc(len);
+
+				for (cp = buffer + abblen; isspace(*cp); cp++)
+					; /* nothing */
+				strcpy(common_repo_prefix, cp);
+			}
 			continue;
+		}
 		if ((left_bracket = strchr(buffer, '<')) == NULL)
 			continue;
 		if ((right_bracket = strchr(left_bracket + 1, '>')) == NULL)
@@ -87,7 +107,7 @@ static void insert_author_oneline(struct path_list *list,
 		const char *author, int authorlen,
 		const char *oneline, int onelinelen)
 {
-	const char *dot3 = "/pub/scm/linux/kernel/git/";
+	const char *dot3 = common_repo_prefix;
 	char *buffer, *p;
 	struct path_list_item *item;
 	struct path_list *onelines;
diff --git a/contrib/mailmap.linux b/contrib/mailmap.linux
index 83927c9..e4907f8 100644
--- a/contrib/mailmap.linux
+++ b/contrib/mailmap.linux
@@ -3,6 +3,8 @@
 # So have an email->real name table to translate the
 # (hopefully few) missing names
 #
+# repo-abbrev: /pub/scm/linux/kernel/git/
+#
 Adrian Bunk <bunk@stusta.de>
 Andreas Herrmann <aherrman@de.ibm.com>
 Andrew Morton <akpm@osdl.org>
-- 
1.4.4.1.g61fba


^ permalink raw reply related	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2021-01-26  0:07 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-25  8:11 [PATCH 2/2] git-shortlog: make common repository prefix configurable with .mailmap Junio C Hamano
2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
2021-01-05 19:18   ` Linus Torvalds
2021-01-26  0:04     ` [PATCH] mailmap: remove the "repo-abbrev" comment Ævar Arnfjörð Bjarmason
2021-01-05 21:15   ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Martin Ågren
2021-01-05 23:06   ` Junio C Hamano
2021-01-12 20:17   ` [PATCH 00/22] mailmap: doc + test fixes Ævar Arnfjörð Bjarmason
2021-01-12 22:34     ` Junio C Hamano
2021-01-14  8:59       ` Ævar Arnfjörð Bjarmason
2021-01-14 23:02     ` [PATCH 0/2] mailmap: test cleanup Denton Liu
2021-01-14 23:02       ` [PATCH 1/2] test-lib-functions.sh: fix usage for test_commit() Denton Liu
2021-01-15  0:19         ` Ævar Arnfjörð Bjarmason
2021-01-14 23:02       ` [PATCH 2/2] t4203: stop losing return codes of git commands Denton Liu
2021-01-15  0:20         ` Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page Ævar Arnfjörð Bjarmason
2021-01-14 17:41     ` Philippe Blain
2021-01-14 19:58       ` Junio C Hamano
2021-01-15  2:38         ` Philippe Blain
2021-01-15  3:18           ` Junio C Hamano
2021-01-15  3:36             ` Philippe Blain
2021-01-15  5:53               ` Junio C Hamano
2021-01-15  2:34     ` [PATCH] fixup! " Philippe Blain
2021-01-15  3:28       ` [PATCH v2] mailmap doc: use correct environment variable 'GIT_WORK_TREE' Philippe Blain
2021-01-12 20:17   ` [PATCH 02/22] mailmap doc: quote config variables `like.this` Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 03/22] check-mailmap doc: note config options Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 04/22] mailmap doc: start by mentioning the comment syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 05/22] mailmap tests: use our preferred whitespace syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 06/22] mailmap tests: modernize syntax & test idioms Ævar Arnfjörð Bjarmason
2021-01-14  7:51     ` Denton Liu
2021-01-14 20:00       ` Junio C Hamano
2021-01-12 20:17   ` [PATCH 07/22] mailmap tests: improve --stdin tests Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 08/22] mailmap tests: remove redundant entry in test Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 09/22] mailmap tests: add a test for "not a blob" error Ævar Arnfjörð Bjarmason
2021-01-12 22:34     ` Junio C Hamano
2021-01-12 20:17   ` [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing Ævar Arnfjörð Bjarmason
2021-01-12 22:34     ` Junio C Hamano
2021-01-14 20:21       ` Junio C Hamano
2021-01-12 20:17   ` [PATCH 11/22] mailmap: test for silent exiting on missing file/blob Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 12/22] test-lib functions: expand "test_commit" comment template Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 13/22] test-lib functions: document arguments to test_commit Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 14/22] test-lib functions: add --author support " Ævar Arnfjörð Bjarmason
2021-01-12 22:34     ` Junio C Hamano
2021-01-14  7:40     ` Denton Liu
2021-01-12 20:17   ` [PATCH 15/22] test-lib functions: add an --append option " Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 16/22] tests: refactor a few tests to use "test_commit --append" Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 17/22] mailmap doc + tests: add better examples & test them Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 18/22] mailmap tests: add a test for comment syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 19/22] mailmap tests: add tests for whitespace syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 20/22] mailmap tests: add tests for empty "<>" syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 21/22] mailmap doc + tests: document and test for case-insensitivity Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 22/22] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason

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.