From: Junio C Hamano Date: Mon, 22 Jul 2013 18:24:14 +0000 (-0700) Subject: Merge branch 'es/check-mailmap' X-Git-Tag: v1.8.4-rc0~20 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/e683889b75a32b8c2bf11c8fa0cf851087bc5415?ds=inline;hp=-c Merge branch 'es/check-mailmap' 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 --- e683889b75a32b8c2bf11c8fa0cf851087bc5415 diff --combined .gitignore index efa8db0035,62300976ff..6b1fd1bfb0 --- a/.gitignore +++ b/.gitignore @@@ -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 @@@ -191,7 -192,6 +192,7 @@@ /test-mktemp /test-parse-options /test-path-utils +/test-prio-queue /test-read-cache /test-regex /test-revision-walking diff --combined Makefile index 0600eb46db,18f1c448b9..ef442ebad0 --- a/Makefile +++ 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))),) diff --combined contrib/completion/git-completion.bash index fa3ae1e853,28f50d14b0..cd509a5d63 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -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 @@@ -2511,7 -2513,6 +2512,7 @@@ --exec-path --exec-path= --html-path + --man-path --info-path --work-tree= --namespace= diff --combined git.c index 6104d5eefc,02c3035d02..2025f77d01 --- a/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 c32df80f14,b7476f2220..baa4685dcc --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@@ -13,6 -13,11 +13,11 @@@ fuzz_blame () } test_expect_success setup ' + cat >contacts <<-\EOF && + A U Thor + nick1 + EOF + echo one >one && git add one && test_tick && @@@ -23,6 -28,44 +28,44 @@@ git commit --author "nick1 " -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 + nick1 + EOF + git check-mailmap \ + "A U Thor " \ + "nick1 " >actual && + test_cmp expect actual + ' + + test_expect_success 'check-mailmap --stdin' ' + cat >expect <<-\EOF && + A U Thor + nick1 + EOF + git check-mailmap --stdin actual && + test_cmp expect actual + ' + + test_expect_success 'check-mailmap --stdin arguments' ' + cat >expect <<-\EOF && + Internal Guy + EOF + cat >expect && + git check-mailmap --stdin "Internal Guy " \ + 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 " >expect && + echo " 1 nick1 " >>expect && + echo "A " >.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 " >expect && + echo " 1 nick1 " >>expect && + echo " " >.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 (1):