Merge branch 'es/check-mailmap'
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Jul 2013 18:24:14 +0000 (11:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Jul 2013 18:24:14 +0000 (11:24 -0700)
A new command to allow scripts to query the mailmap information.

* es/check-mailmap:
t4203: test check-mailmap command invocation
builtin: add git-check-mailmap command

1  2 
.gitignore
Makefile
contrib/completion/git-completion.bash
git.c
t/t4203-mailmap.sh
diff --combined .gitignore
index efa8db00358772852e637af8758f8f76719dec01,62300976ff2470e38f6fcf0794ed793211bbcb38..6b1fd1bfb060c438d7b70684612cef08fc1a5859
@@@ -23,6 -23,7 +23,7 @@@
  /git-cat-file
  /git-check-attr
  /git-check-ignore
+ /git-check-mailmap
  /git-check-ref-format
  /git-checkout
  /git-checkout-index
  /test-mktemp
  /test-parse-options
  /test-path-utils
 +/test-prio-queue
  /test-read-cache
  /test-regex
  /test-revision-walking
diff --combined Makefile
index 0600eb46db487c88e24dc3b4089db062ad6350ac,18f1c448b97a070d943a5e74c9bc30301170f9c9..ef442ebad097a47bb19ea75037e62c51d9bb5d8b
+++ b/Makefile
@@@ -569,7 -569,6 +569,7 @@@ TEST_PROGRAMS_NEED_X += test-mergesor
  TEST_PROGRAMS_NEED_X += test-mktemp
  TEST_PROGRAMS_NEED_X += test-parse-options
  TEST_PROGRAMS_NEED_X += test-path-utils
 +TEST_PROGRAMS_NEED_X += test-prio-queue
  TEST_PROGRAMS_NEED_X += test-read-cache
  TEST_PROGRAMS_NEED_X += test-regex
  TEST_PROGRAMS_NEED_X += test-revision-walking
@@@ -706,7 -705,6 +706,7 @@@ LIB_H += parse-options.
  LIB_H += patch-ids.h
  LIB_H += pathspec.h
  LIB_H += pkt-line.h
 +LIB_H += prio-queue.h
  LIB_H += progress.h
  LIB_H += prompt.h
  LIB_H += quote.h
@@@ -848,7 -846,6 +848,7 @@@ LIB_OBJS += pathspec.
  LIB_OBJS += pkt-line.o
  LIB_OBJS += preload-index.o
  LIB_OBJS += pretty.o
 +LIB_OBJS += prio-queue.o
  LIB_OBJS += progress.o
  LIB_OBJS += prompt.o
  LIB_OBJS += quote.o
@@@ -912,6 -909,7 +912,7 @@@ BUILTIN_OBJS += builtin/bundle.
  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
@@@ -2305,6 -2303,9 +2306,6 @@@ check: common-cmds.
                exit 1; \
        fi
  
 -remove-dashes:
 -      ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
 -
  ### Installation rules
  
  ifneq ($(filter /%,$(firstword $(template_dir))),)
index fa3ae1e8535c786dc724ab7a73cccb6f3bfca8de,28f50d14b036073e240f6a3e4dea85d6aadca4bc..cd509a5d63922e05d5c2f5239a8acdd7baab3047
@@@ -33,6 -33,8 +33,6 @@@ esa
  # returns location of .git repo
  __gitdir ()
  {
 -      # Note: this function is duplicated in git-prompt.sh
 -      # When updating it, make sure you update the other one to match.
        if [ -z "${1-}" ]; then
                if [ -n "${__git_dir-}" ]; then
                        echo "$__git_dir"
@@@ -648,6 -650,7 +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;;
@@@ -2490,10 -2493,9 +2491,10 @@@ __git_main (
                i="${words[c]}"
                case "$i" in
                --git-dir=*) __git_dir="${i#--git-dir=}" ;;
 +              --git-dir)   ((c++)) ; __git_dir="${words[c]}" ;;
                --bare)      __git_dir="." ;;
                --help) command="help"; break ;;
 -              -c) c=$((++c)) ;;
 +              -c|--work-tree|--namespace) ((c++)) ;;
                -*) ;;
                *) command="$i"; break ;;
                esac
                        --exec-path
                        --exec-path=
                        --html-path
 +                      --man-path
                        --info-path
                        --work-tree=
                        --namespace=
diff --combined git.c
index 6104d5eefc882cdbf978b5a141c93c20b78fcb2b,02c3035d02d2156ace33c100ebffea75f532106b..2025f77d0181ba646e3c793a693e5d71348b966c
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -324,6 -324,7 +324,7 @@@ static void handle_internal_command(in
                { "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,
@@@ -525,13 -526,6 +526,13 @@@ int main(int argc, char **av
        if (!cmd)
                cmd = "git-help";
  
 +      /*
 +       * Always open file descriptors 0/1/2 to avoid clobbering files
 +       * in die().  It also avoids messing up when the pipes are dup'ed
 +       * onto stdin/stdout/stderr in the child processes we spawn.
 +       */
 +      sanitize_stdfds();
 +
        git_setup_gettext();
  
        /*
diff --combined t/t4203-mailmap.sh
index c32df80f1435faa73351bce867196b2ceede4ff5,b7476f22209133829f334a56b6a83ac5944b8b40..baa4685dcce59f17223161706a8cf059ecdabcd1
@@@ -13,6 -13,11 +13,11 @@@ fuzz_blame () 
  }
  
  test_expect_success setup '
+       cat >contacts <<-\EOF &&
+       A U Thor <author@example.com>
+       nick1 <bugs@company.xx>
+       EOF
        echo one >one &&
        git add one &&
        test_tick &&
        git commit --author "nick1 <bugs@company.xx>" -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 <author@example.com>
+       nick1 <bugs@company.xx>
+       EOF
+       git check-mailmap \
+               "A U Thor <author@example.com>" \
+               "nick1 <bugs@company.xx>" >actual &&
+       test_cmp expect actual
+ '
+ test_expect_success 'check-mailmap --stdin' '
+       cat >expect <<-\EOF &&
+       A U Thor <author@example.com>
+       nick1 <bugs@company.xx>
+       EOF
+       git check-mailmap --stdin <contacts >actual &&
+       test_cmp expect actual
+ '
+ test_expect_success 'check-mailmap --stdin arguments' '
+       cat >expect <<-\EOF &&
+       Internal Guy <bugs@company.xy>
+       EOF
+       cat <contacts >>expect &&
+       git check-mailmap --stdin "Internal Guy <bugs@company.xy>" \
+               <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
@@@ -247,24 -290,6 +290,24 @@@ test_expect_success 'cleanup after mail
        rm -f .mailmap
  '
  
 +test_expect_success 'single-character name' '
 +      echo "     1    A <author@example.com>" >expect &&
 +      echo "     1    nick1 <bugs@company.xx>" >>expect &&
 +      echo "A <author@example.com>" >.mailmap &&
 +      test_when_finished "rm .mailmap" &&
 +      git shortlog -es HEAD >actual &&
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'preserve canonical email case' '
 +      echo "     1    A U Thor <AUTHOR@example.com>" >expect &&
 +      echo "     1    nick1 <bugs@company.xx>" >>expect &&
 +      echo "<AUTHOR@example.com> <author@example.com>" >.mailmap &&
 +      test_when_finished "rm .mailmap" &&
 +      git shortlog -es HEAD >actual &&
 +      test_cmp expect actual
 +'
 +
  # Extended mailmap configurations should give us the following output for shortlog
  cat >expect <<\EOF
  A U Thor <author@example.com> (1):