aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--credential.c14
-rw-r--r--credential.h3
-rwxr-xr-xt/t0300-credentials.sh29
-rwxr-xr-xt/t5550-http-fetch.sh2
4 files changed, 46 insertions, 2 deletions
diff --git a/credential.c b/credential.c
index 3c17ea197..a17eafea5 100644
--- a/credential.c
+++ b/credential.c
@@ -69,16 +69,30 @@ static int credential_config_callback(const char *var, const char *value,
if (!c->username)
c->username = xstrdup(value);
}
+ else if (!strcmp(key, "usehttppath"))
+ c->use_http_path = git_config_bool(var, value);
return 0;
}
+static int proto_is_http(const char *s)
+{
+ if (!s)
+ return 0;
+ return !strcmp(s, "https") || !strcmp(s, "http");
+}
+
static void credential_apply_config(struct credential *c)
{
if (c->configured)
return;
git_config(credential_config_callback, c);
c->configured = 1;
+
+ if (!c->use_http_path && proto_is_http(c->protocol)) {
+ free(c->path);
+ c->path = NULL;
+ }
}
static void credential_describe(struct credential *c, struct strbuf *out)
diff --git a/credential.h b/credential.h
index e5042723a..96ea41bd1 100644
--- a/credential.h
+++ b/credential.h
@@ -6,7 +6,8 @@
struct credential {
struct string_list helpers;
unsigned approved:1,
- configured:1;
+ configured:1,
+ use_http_path:1;
char *username;
char *password;
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index 53e94bc03..885af8fb6 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -247,4 +247,33 @@ test_expect_success 'pull username from config' '
EOF
'
+test_expect_success 'http paths can be part of context' '
+ check fill "verbatim foo bar" <<-\EOF &&
+ protocol=https
+ host=example.com
+ path=foo.git
+ --
+ username=foo
+ password=bar
+ --
+ verbatim: get
+ verbatim: protocol=https
+ verbatim: host=example.com
+ EOF
+ test_config credential.https://example.com.useHttpPath true &&
+ check fill "verbatim foo bar" <<-\EOF
+ protocol=https
+ host=example.com
+ path=foo.git
+ --
+ username=foo
+ password=bar
+ --
+ verbatim: get
+ verbatim: protocol=https
+ verbatim: host=example.com
+ verbatim: path=foo.git
+ EOF
+'
+
test_done
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index 3262f903e..95a133d69 100755
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
@@ -53,7 +53,7 @@ test_expect_success 'setup askpass helpers' '
'
expect_askpass() {
- dest=$HTTPD_DEST/auth/repo.git
+ dest=$HTTPD_DEST
{
case "$1" in
none)