From 85176d725134446ca2b8585d85f8fbd2daf45515 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 17 Nov 2013 23:12:43 -0500 Subject: [PATCH 1/8] test-lib.sh: convert $TEST_DIRECTORY to an absolute path If $TEST_DIRECTORY is specified in the environment, convert the value to an absolute path to ensure that it remains valid even when 'cd' is used. Signed-off-by: Felipe Contreras Reviewed-by: Richard Hansen Signed-off-by: Richard Hansen Signed-off-by: Junio C Hamano --- t/test-lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/t/test-lib.sh b/t/test-lib.sh index b25249ec4c..d303e6c943 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -26,6 +26,10 @@ then # outside of t/, e.g. for running tests on the test library # itself. TEST_DIRECTORY=$(pwd) +else + # ensure that TEST_DIRECTORY is an absolute path so that it + # is valid even if the current working directory is changed + TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1 fi if test -z "$TEST_OUTPUT_DIRECTORY" then From d3243d738ddcf1a9cf6c8bd63f66c57080f1040b Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Sun, 17 Nov 2013 23:12:44 -0500 Subject: [PATCH 2/8] test-bzr.sh, test-hg.sh: allow running from any dir Set TEST_DIRECTORY to the t/ directory (if TEST_DIRECTORY is not already set) so that the user doesn't already have to be in the test directory to run these test scripts. Signed-off-by: Felipe Contreras Based-on-patch-by: Richard Hansen Reviewed-by: Richard Hansen Signed-off-by: Richard Hansen Signed-off-by: Junio C Hamano --- contrib/remote-helpers/test-bzr.sh | 3 ++- contrib/remote-helpers/test-hg.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh index 5c50251783..1e850c313d 100755 --- a/contrib/remote-helpers/test-bzr.sh +++ b/contrib/remote-helpers/test-bzr.sh @@ -5,7 +5,8 @@ test_description='Test remote-bzr' -. ./test-lib.sh +test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=${0%/*}/../../t +. "$TEST_DIRECTORY"/test-lib.sh if ! test_have_prereq PYTHON then diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh index 72f745d63f..fa7d17b224 100755 --- a/contrib/remote-helpers/test-hg.sh +++ b/contrib/remote-helpers/test-hg.sh @@ -8,7 +8,8 @@ test_description='Test remote-hg' -. ./test-lib.sh +test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=${0%/*}/../../t +. "$TEST_DIRECTORY"/test-lib.sh if ! test_have_prereq PYTHON then From 4945725c647a513326c3ce31dd99b91eefd97ede Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 17 Nov 2013 23:12:45 -0500 Subject: [PATCH 3/8] test-bzr.sh, test-hg.sh: prepare for change to push.default=simple Change 'git push ' to 'git push ' in one of the test-bzr.sh tests to ensure that the test continues to pass when the default value of push.default changes to simple. Signed-off-by: Richard Hansen Reviewed-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/remote-helpers/test-bzr.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/remote-helpers/test-bzr.sh b/contrib/remote-helpers/test-bzr.sh index 1e850c313d..1e53ff9a58 100755 --- a/contrib/remote-helpers/test-bzr.sh +++ b/contrib/remote-helpers/test-bzr.sh @@ -379,7 +379,7 @@ test_expect_success 'export utf-8 authors' ' git add content && git commit -m one && git remote add bzr "bzr::../bzrrepo" && - git push bzr + git push bzr master ) && ( From 5105edd411bc472015d63eadaf1f826bebdc92e5 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 17 Nov 2013 23:12:46 -0500 Subject: [PATCH 4/8] test-hg.sh: eliminate 'local' bashism Unlike bash, POSIX shell does not specify a 'local' command for declaring function-local variable scope. Except for IFS, the variable names are not used anywhere else in the script so simply remove the 'local'. For IFS, move the assignment to the 'read' command to prevent it from affecting code outside the function. Signed-off-by: Richard Hansen Reviewed-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/remote-helpers/test-hg.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh index fa7d17b224..ceef6b1917 100755 --- a/contrib/remote-helpers/test-hg.sh +++ b/contrib/remote-helpers/test-hg.sh @@ -54,14 +54,14 @@ check_bookmark () { } check_push () { - local expected_ret=$1 ret=0 ref_ret=0 IFS=':' + expected_ret=$1 ret=0 ref_ret=0 shift git push origin "$@" 2>error ret=$? cat error - while read branch kind + while IFS=':' read branch kind do case "$kind" in 'new') From 25607db2c30c618a18f66350f01b1ccb05c551c6 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 17 Nov 2013 23:12:47 -0500 Subject: [PATCH 5/8] test-hg.sh: avoid obsolete 'test' syntax The POSIX spec says that the '-a', '-o', and parentheses operands to the 'test' utility are obsolete extensions due to the potential for ambiguity. Replace '-o' with '|| test' to avoid unspecified behavior. Signed-off-by: Richard Hansen Reviewed-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/remote-helpers/test-hg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh index ceef6b1917..5535e8c9be 100755 --- a/contrib/remote-helpers/test-hg.sh +++ b/contrib/remote-helpers/test-hg.sh @@ -83,7 +83,7 @@ check_push () { test $ref_ret -ne 0 && echo "match for '$branch' failed" && break done - if test $expected_ret -ne $ret -o $ref_ret -ne 0 + if test $expected_ret -ne $ret || test $ref_ret -ne 0 then return 1 fi From 962df3dab78a2f5f583f096814ae952fc4426498 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 17 Nov 2013 23:12:48 -0500 Subject: [PATCH 6/8] test-hg.sh: fix duplicate content strings in author tests "beta" was used twice. Change the second copy to "gamma" and increment the remaining content strings. Signed-off-by: Richard Hansen Reviewed-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/remote-helpers/test-hg.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh index 5535e8c9be..eb72db8b6d 100755 --- a/contrib/remote-helpers/test-hg.sh +++ b/contrib/remote-helpers/test-hg.sh @@ -207,15 +207,15 @@ test_expect_success 'authors' ' >../expected && author_test alpha "" "H G Wells " && author_test beta "test" "test " && - author_test beta "test (comment)" "test " && - author_test gamma "" "Unknown " && - author_test delta "name" "name " && - author_test epsilon "name " && - author_test zeta " test " "test " && - author_test eta "test < test@example.com >" "test " && - author_test theta "test >test@example.com>" "test " && - author_test iota "test < test example com>" "test " && - author_test kappa "test@example.com" "Unknown " + author_test gamma "test (comment)" "test " && + author_test delta "" "Unknown " && + author_test epsilon "name" "name " && + author_test zeta "name " && + author_test eta " test " "test " && + author_test theta "test < test@example.com >" "test " && + author_test iota "test >test@example.com>" "test " && + author_test kappa "test < test example com>" "test " && + author_test lambda "test@example.com" "Unknown " ) && git clone "hg::hgrepo" gitrepo && From b2bff43170d052cf3a0ecc69dd03c0467b5782d0 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 17 Nov 2013 23:12:49 -0500 Subject: [PATCH 7/8] test-hg.sh: help user correlate verbose output with email test It's hard to tell which author conversion test failed when the email addresses look similar. Signed-off-by: Richard Hansen Reviewed-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/remote-helpers/test-hg.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh index eb72db8b6d..642ad938cd 100755 --- a/contrib/remote-helpers/test-hg.sh +++ b/contrib/remote-helpers/test-hg.sh @@ -206,16 +206,16 @@ test_expect_success 'authors' ' >../expected && author_test alpha "" "H G Wells " && - author_test beta "test" "test " && - author_test gamma "test (comment)" "test " && - author_test delta "" "Unknown " && - author_test epsilon "name" "name " && - author_test zeta "name " && - author_test eta " test " "test " && - author_test theta "test < test@example.com >" "test " && - author_test iota "test >test@example.com>" "test " && - author_test kappa "test < test example com>" "test " && - author_test lambda "test@example.com" "Unknown " + author_test beta "beta" "beta " && + author_test gamma "gamma (comment)" "gamma " && + author_test delta "" "Unknown " && + author_test epsilon "epsilon" "epsilon " && + author_test zeta "zeta " && + author_test eta " eta " "eta " && + author_test theta "theta < test@example.com >" "theta " && + author_test iota "iota >test@example.com>" "iota " && + author_test kappa "kappa < test example com>" "kappa " && + author_test lambda "lambda@example.com" "Unknown " ) && git clone "hg::hgrepo" gitrepo && From 6c68a404e6e9eec850b298f98fa30c5a25aa846e Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 17 Nov 2013 23:12:50 -0500 Subject: [PATCH 8/8] remote-bzr, remote-hg: fix email address regular expression Before, strings like "foo.bar@example.com" would be converted to "foo. " when they should be "unknown ". Signed-off-by: Richard Hansen Reviewed-by: Felipe Contreras Signed-off-by: Junio C Hamano --- contrib/remote-helpers/git-remote-bzr | 7 +++---- contrib/remote-helpers/git-remote-hg | 7 +++---- contrib/remote-helpers/test-hg.sh | 3 ++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr index 054161ae21..7e345320ad 100755 --- a/contrib/remote-helpers/git-remote-bzr +++ b/contrib/remote-helpers/git-remote-bzr @@ -44,8 +44,8 @@ import StringIO import atexit, shutil, hashlib, urlparse, subprocess NAME_RE = re.compile('^([^<>]+)') -AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$') -EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)') +AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)') +EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)') RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)') def die(msg, *args): @@ -193,8 +193,7 @@ def fixup_user(user): else: m = EMAIL_RE.match(user) if m: - name = m.group(1) - mail = m.group(2) + mail = m.group(1) else: m = NAME_RE.match(user) if m: diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg index c6026b9bed..30402d5532 100755 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@ -51,8 +51,8 @@ import time as ptime # NAME_RE = re.compile('^([^<>]+)') -AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$') -EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)') +AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)') +EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)') AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$') RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)') @@ -316,8 +316,7 @@ def fixup_user_git(user): else: m = EMAIL_RE.match(user) if m: - name = m.group(1) - mail = m.group(2) + mail = m.group(1) else: m = NAME_RE.match(user) if m: diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh index 642ad938cd..347e812923 100755 --- a/contrib/remote-helpers/test-hg.sh +++ b/contrib/remote-helpers/test-hg.sh @@ -215,7 +215,8 @@ test_expect_success 'authors' ' author_test theta "theta < test@example.com >" "theta " && author_test iota "iota >test@example.com>" "iota " && author_test kappa "kappa < test example com>" "kappa " && - author_test lambda "lambda@example.com" "Unknown " + author_test lambda "lambda@example.com" "Unknown " && + author_test mu "mu.mu@example.com" "Unknown " ) && git clone "hg::hgrepo" gitrepo &&