From e30b2feb1b50c2d14d32dc3e6e41f7b20a677ff2 Mon Sep 17 00:00:00 2001 From: Javier Roucher Iglesias Date: Sun, 24 Jun 2012 13:39:59 +0200 Subject: add 'git credential' plumbing command The credential API is in C, and not available to scripting languages. Expose the functionalities of the API by wrapping them into a new plumbing command "git credentials". In other words, replace the internal "test-credential" by an official Git command. Most documentation writen by: Jeff King Signed-off-by: Pavel Volek Signed-off-by: Kim Thuat Nguyen Signed-off-by: Javier Roucher Iglesias Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- t/lib-credential.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 't/lib-credential.sh') diff --git a/t/lib-credential.sh b/t/lib-credential.sh index 4a37cd79e5..7c4826e4ee 100755 --- a/t/lib-credential.sh +++ b/t/lib-credential.sh @@ -4,10 +4,20 @@ # stdout and stderr should be provided on stdin, # separated by "--". check() { + credential_opts= + credential_cmd=$1 + shift + for arg in "$@"; do + credential_opts="$credential_opts -c credential.helper='$arg'" + done read_chunk >stdin && read_chunk >expect-stdout && read_chunk >expect-stderr && - test-credential "$@" stdout 2>stderr && + if ! eval "git $credential_opts credential $credential_cmd stdout 2>stderr"; then + echo "git credential failed with code $?" && + cat stderr && + false + fi && test_cmp expect-stdout stdout && test_cmp expect-stderr stderr } @@ -41,7 +51,7 @@ reject() { echo protocol=$2 echo host=$3 echo username=$4 - ) | test-credential reject $1 + ) | git -c credential.helper=$1 credential reject } helper_test() { -- cgit v1.2.1 From 2d6dc182b8fa171a6b283ce6e8e75a35e13ea67a Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Sun, 24 Jun 2012 13:40:00 +0200 Subject: git credential fill: output the whole 'struct credential' Instead of outputing only the username and password, print all the attributes, even those that already appeared in the input. This is closer to what the C API does, and allows one to take the exact output of "git credential fill" as input to "git credential approve" or "git credential reject". Signed-off-by: Junio C Hamano --- t/lib-credential.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 't/lib-credential.sh') diff --git a/t/lib-credential.sh b/t/lib-credential.sh index 7c4826e4ee..957ae936e8 100755 --- a/t/lib-credential.sh +++ b/t/lib-credential.sh @@ -62,6 +62,8 @@ helper_test() { protocol=https host=example.com -- + protocol=https + host=example.com username=askpass-username password=askpass-password -- @@ -84,6 +86,8 @@ helper_test() { protocol=https host=example.com -- + protocol=https + host=example.com username=store-user password=store-pass -- @@ -95,6 +99,8 @@ helper_test() { protocol=http host=example.com -- + protocol=http + host=example.com username=askpass-username password=askpass-password -- @@ -108,6 +114,8 @@ helper_test() { protocol=https host=other.tld -- + protocol=https + host=other.tld username=askpass-username password=askpass-password -- @@ -122,6 +130,8 @@ helper_test() { host=example.com username=other -- + protocol=https + host=example.com username=other password=askpass-password -- @@ -143,6 +153,9 @@ helper_test() { host=path.tld path=bar.git -- + protocol=http + host=path.tld + path=bar.git username=askpass-username password=askpass-password -- @@ -160,6 +173,8 @@ helper_test() { protocol=https host=example.com -- + protocol=https + host=example.com username=askpass-username password=askpass-password -- @@ -186,6 +201,8 @@ helper_test() { host=example.com username=user1 -- + protocol=https + host=example.com username=user1 password=pass1 EOF @@ -194,6 +211,8 @@ helper_test() { host=example.com username=user2 -- + protocol=https + host=example.com username=user2 password=pass2 EOF @@ -210,6 +229,8 @@ helper_test() { host=example.com username=user1 -- + protocol=https + host=example.com username=user1 password=askpass-password -- @@ -223,6 +244,8 @@ helper_test() { host=example.com username=user2 -- + protocol=https + host=example.com username=user2 password=pass2 EOF @@ -244,6 +267,8 @@ helper_test_timeout() { protocol=https host=timeout.tld -- + protocol=https + host=timeout.tld username=askpass-username password=askpass-password -- -- cgit v1.2.1 From a6253da0f30c5bee1ecb9bea313881dc8e50efda Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Fri, 27 Jul 2012 19:10:06 +0200 Subject: contrib: add win32 credential-helper Since the Windows port of Git expects binary pipes, we need to make sure the helper-end also sets up binary pipes. Side-step CRLF-issue in test to make it pass. Signed-off-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- t/lib-credential.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 't/lib-credential.sh') diff --git a/t/lib-credential.sh b/t/lib-credential.sh index 957ae936e8..3c43ff11b3 100755 --- a/t/lib-credential.sh +++ b/t/lib-credential.sh @@ -18,6 +18,10 @@ check() { cat stderr && false fi && + if test_have_prereq MINGW + then + dos2unix -q stderr + fi && test_cmp expect-stdout stdout && test_cmp expect-stderr stderr } -- cgit v1.2.1