aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-04-18 11:46:41 -0700
committerJunio C Hamano <gitster@pobox.com>2013-04-18 11:46:42 -0700
commit5734fa4608ada9c1df20ac27988715ee27b36613 (patch)
treee4a4d14a051ca510d076c834e454511f81e5e6fc /t
parentbd1184c6dedacb5f76513c299ae07019d6bed963 (diff)
parentddc996d767025a4ffcb52a813d32a5095f357e44 (diff)
downloadgit-5734fa4608ada9c1df20ac27988715ee27b36613.tar.gz
git-5734fa4608ada9c1df20ac27988715ee27b36613.tar.xz
Merge branch 'fc/completion'
In addition to a user visible change to offer more options to cherry-pick, generally cleans up and simplifies the code. * fc/completion: completion: small optimization completion: inline __gitcomp_1 to its sole callsite completion: get rid of compgen completion: add __gitcomp_nl tests completion: add new __gitcompadd helper completion: get rid of empty COMPREPLY assignments completion: trivial test improvement completion: add more cherry-pick options
Diffstat (limited to 't')
-rwxr-xr-xt/t9902-completion.sh65
1 files changed, 63 insertions, 2 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index adc1372b3..6d9d1418a 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -69,6 +69,7 @@ run_completion ()
local -a COMPREPLY _words
local _cword
_words=( $1 )
+ test "${1: -1}" == ' ' && _words+=('')
(( _cword = ${#_words[@]} - 1 ))
__git_wrap__git_main && print_comp
}
@@ -104,6 +105,23 @@ test_gitcomp ()
test_cmp expected out
}
+# Test __gitcomp_nl
+# Arguments are:
+# 1: current word (cur)
+# -: the rest are passed to __gitcomp_nl
+test_gitcomp_nl ()
+{
+ local -a COMPREPLY &&
+ sed -e 's/Z$//' >expected &&
+ cur="$1" &&
+ shift &&
+ __gitcomp_nl "$@" &&
+ print_comp &&
+ test_cmp expected out
+}
+
+invalid_variable_name='${foo.bar}'
+
test_expect_success '__gitcomp - trailing space - options' '
test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
--reset-author" <<-EOF
@@ -147,8 +165,51 @@ test_expect_success '__gitcomp - suffix' '
EOF
'
+test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
+ __gitcomp "$invalid_variable_name"
+'
+
+read -r -d "" refs <<-\EOF
+maint
+master
+next
+pu
+EOF
+
+test_expect_success '__gitcomp_nl - trailing space' '
+ test_gitcomp_nl "m" "$refs" <<-EOF
+ maint Z
+ master Z
+ EOF
+'
+
+test_expect_success '__gitcomp_nl - prefix' '
+ test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF
+ --fixup=maint Z
+ --fixup=master Z
+ EOF
+'
+
+test_expect_success '__gitcomp_nl - suffix' '
+ test_gitcomp_nl "branch.ma" "$refs" "branch." "ma" "." <<-\EOF
+ branch.maint.Z
+ branch.master.Z
+ EOF
+'
+
+test_expect_success '__gitcomp_nl - no suffix' '
+ test_gitcomp_nl "ma" "$refs" "" "ma" "" <<-\EOF
+ maintZ
+ masterZ
+ EOF
+'
+
+test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name' '
+ __gitcomp_nl "$invalid_variable_name"
+'
+
test_expect_success 'basic' '
- run_completion "git \"\"" &&
+ run_completion "git " &&
# built-in
grep -q "^add \$" out &&
# script
@@ -271,7 +332,7 @@ test_expect_success 'complete tree filename with spaces' '
EOF
'
-test_expect_failure 'complete tree filename with metacharacters' '
+test_expect_success 'complete tree filename with metacharacters' '
echo content >"name with \${meta}" &&
git add . &&
git commit -m meta &&