Skip to contentSkip to conversation

add git-check-mailmap command

PATCH New Eric Sunshine 1 participant 3 messages Jun 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover add git-check-mailmap command

This is a re-roll of v2 [1] which introduces git-check-mailmap. The primary motivation for this command is to expose git's stable, well-tested C-implementation of .mailmap functionality to scripts and porcelains, thus relieving them of the need to re-implement support themselves. The git-contacts [2] script (currently at es/contacts in 'pu') would be one such client.

v3 addresses comments from reviewers [1].

Changes since v2:

* Drop -z/--null option.

* Simplify grammar of DESCRIPTION and OUTPUT sections of Documentation/git-check-mailmap.txt.

* Normalize wrapped code indentation to match standard Git style.

* Drop v2 patches [3/4] and [4/4] which convert t4203-mailmap.sh to test low-level mailmap functionality directly via git-check-mailmap rather than indirectly via git-shortlog.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/230105/
[2]: http://thread.gmane.org/gmane.comp.version-control.git/229533/

Eric Sunshine (2):
builtin: add git-check-mailmap command
t4203: test check-mailmap command invocation

 .gitignore                             |  1 +
 Documentation/git-check-mailmap.txt    | 47 ++++++++++++++++++++++++
 Makefile                               |  1 +
 builtin.h                              |  1 +
 builtin/check-mailmap.c                | 66 ++++++++++++++++++++++++++++++++++
 command-list.txt                       |  1 +
 contrib/completion/git-completion.bash |  1 +
 git.c                                  |  1 +
 t/t4203-mailmap.sh                     | 43 ++++++++++++++++++++++
 9 files changed, 162 insertions(+)
 create mode 100644 Documentation/git-check-mailmap.txt
 create mode 100644 builtin/check-mailmap.c
Signature · 1 line
1.8.3.2.804.g0da7a53
#1 lore raw

PATCH v3 1/2 builtin: add git-check-mailmap command

Introduce command check-mailmap, similar to check-attr and check-ignore, which allows direct testing of .mailmap configuration.

As plumbing accessible to scripts and other porcelain, check-mailmap publishes the stable, well-tested .mailmap functionality employed by built-in Git commands. Consequently, script authors need not re-implement .mailmap functionality manually, thus avoiding potential quirks and behavioral differences.

---
 .gitignore                             |  1 +
 Documentation/git-check-mailmap.txt    | 47 ++++++++++++++++++++++++
 Makefile                               |  1 +
 builtin.h                              |  1 +
 builtin/check-mailmap.c                | 66 ++++++++++++++++++++++++++++++++++
 command-list.txt                       |  1 +
 contrib/completion/git-completion.bash |  1 +
 git.c                                  |  1 +
 8 files changed, 119 insertions(+)
 create mode 100644 Documentation/git-check-mailmap.txt
 create mode 100644 builtin/check-mailmap.c
.gitignore +1 -0
index efa8db0..6b1fd1b 100644
@@ -23,6 +23,7 @@
 /git-cat-file
 /git-check-attr
 /git-check-ignore
+/git-check-mailmap
 /git-check-ref-format
 /git-checkout
 /git-checkout-index
Documentation/git-check-mailmap.txt new file +47 -0

47 lines not on this page · raw message

Makefile +1 -0
index 0600eb4..ef442eb 100644
@@ -912,6 +912,7 @@ BUILTIN_OBJS += builtin/bundle.o
 BUILTIN_OBJS += builtin/cat-file.o
 BUILTIN_OBJS += builtin/check-attr.o
 BUILTIN_OBJS += builtin/check-ignore.o
+BUILTIN_OBJS += builtin/check-mailmap.o
 BUILTIN_OBJS += builtin/check-ref-format.o
 BUILTIN_OBJS += builtin/checkout-index.o
 BUILTIN_OBJS += builtin/checkout.o
builtin.h +1 -0
index 1ed8edb..8afa2de 100644
@@ -40,6 +40,7 @@ extern int cmd_checkout(int argc, const char **argv, const char *prefix);
 extern int cmd_checkout_index(int argc, const char **argv, const char *prefix);
 extern int cmd_check_attr(int argc, const char **argv, const char *prefix);
 extern int cmd_check_ignore(int argc, const char **argv, const char *prefix);
+extern int cmd_check_mailmap(int argc, const char **argv, const char *prefix);
 extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix);
 extern int cmd_cherry(int argc, const char **argv, const char *prefix);
 extern int cmd_cherry_pick(int argc, const char **argv, const char *prefix);
builtin/check-mailmap.c new file +66 -0

66 lines not on this page · raw message

command-list.txt +1 -0
index bf83303..08b04e2 100644
@@ -13,6 +13,7 @@ git-bundle                              mainporcelain
 git-cat-file                            plumbinginterrogators
 git-check-attr                          purehelpers
 git-check-ignore                        purehelpers
+git-check-mailmap                       purehelpers
 git-checkout                            mainporcelain common
 git-checkout-index                      plumbingmanipulators
 git-check-ref-format                    purehelpers
contrib/completion/git-completion.bash +1 -0
index fa3ae1e..cd509a5 100644
@@ -648,6 +648,7 @@ __git_list_porcelain_commands ()
 		cat-file)         : plumbing;;
 		check-attr)       : plumbing;;
 		check-ignore)     : plumbing;;
+		check-mailmap)    : plumbing;;
 		check-ref-format) : plumbing;;
 		checkout-index)   : plumbing;;
 		commit-tree)      : plumbing;;
git.c +1 -0
index 4359086..02c3035 100644
@@ -324,6 +324,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "cat-file", cmd_cat_file, RUN_SETUP },
 		{ "check-attr", cmd_check_attr, RUN_SETUP },
 		{ "check-ignore", cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE },
+		{ "check-mailmap", cmd_check_mailmap, RUN_SETUP },
 		{ "check-ref-format", cmd_check_ref_format },
 		{ "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
 		{ "checkout-index", cmd_checkout_index,
Signature · 1 line
1.8.3.2.804.g0da7a53
#2 lore raw

PATCH v3 2/2 t4203: test check-mailmap command invocation

In reply to Eric Sunshine

Test the command-line interface of check-mailmap.

(Actual .mailmap functionality is already covered by existing tests.)

---
 t/t4203-mailmap.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
t/t4203-mailmap.sh +43 -0
index 842b754..b7476f2 100755
@@ -13,6 +13,11 @@ fuzz_blame () {
 }
 
 test_expect_success setup '
+	cat >contacts <<-\EOF &&
+	A U Thor <[email protected]>
+	nick1 <[email protected]>
+	EOF
+
 	echo one >one &&
 	git add one &&
 	test_tick &&
@@ -23,6 +28,44 @@ test_expect_success setup '
 	git commit --author "nick1 <[email protected]>" -m second
 '
 
+test_expect_success 'check-mailmap no arguments' '
+	test_must_fail git check-mailmap
+'
+
+test_expect_success 'check-mailmap arguments' '
+	cat >expect <<-\EOF &&
+	A U Thor <[email protected]>
+	nick1 <[email protected]>
+	EOF
+	git check-mailmap \
+		"A U Thor <[email protected]>" \
+		"nick1 <[email protected]>" >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'check-mailmap --stdin' '
+	cat >expect <<-\EOF &&
+	A U Thor <[email protected]>
+	nick1 <[email protected]>
+	EOF
+	git check-mailmap --stdin <contacts >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'check-mailmap --stdin arguments' '
+	cat >expect <<-\EOF &&
+	Internal Guy <[email protected]>
+	EOF
+	cat <contacts >>expect &&
+	git check-mailmap --stdin "Internal Guy <[email protected]>" \
+		<contacts >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'check-mailmap bogus contact' '
+	test_must_fail git check-mailmap bogus
+'
+
 cat >expect <<\EOF
 A U Thor (1):
       initial
Signature · 1 line
1.8.3.2.804.g0da7a53