mirror of
https://github.com/git-for-windows/git.git
synced 2026-03-17 13:23:05 -05:00
Merge branch 'js/http-custom-headers'
Update tests for "http.extraHeaders=<header>" to be portable back to Apache 2.2 (the original depended on <RequireAll/> which is a more recent feature). * js/http-custom-headers: submodule: ensure that -c http.extraheader is heeded t5551: make the test for extra HTTP headers more robust tests: adjust the configuration for Apache 2.2 Rebased-and-signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -1683,6 +1683,12 @@ http.emptyAuth::
|
||||
a username in the URL, as libcurl normally requires a username for
|
||||
authentication.
|
||||
|
||||
http.extraHeader::
|
||||
Pass an additional HTTP header when communicating with a server. If
|
||||
more than one such entry exists, all of them are added as extra
|
||||
headers. To allow overriding the settings inherited from the system
|
||||
config, an empty value will reset the extra headers to the empty list.
|
||||
|
||||
http.cookieFile::
|
||||
The pathname of a file containing previously stored cookie lines,
|
||||
which should be used
|
||||
|
||||
@@ -118,6 +118,7 @@ static int module_name(int argc, const char **argv, const char *prefix)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int clone_submodule(const char *path, const char *gitdir, const char *url,
|
||||
const char *depth, const char *reference, int quiet)
|
||||
{
|
||||
@@ -139,7 +140,7 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
|
||||
argv_array_push(&cp.args, path);
|
||||
|
||||
cp.git_cmd = 1;
|
||||
cp.env = local_repo_env;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
cp.no_stdin = 1;
|
||||
|
||||
return run_command(&cp);
|
||||
@@ -180,8 +181,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
|
||||
|
||||
const char *const git_submodule_helper_usage[] = {
|
||||
N_("git submodule--helper clone [--prefix=<path>] [--quiet] "
|
||||
"[--reference <repository>] [--name <name>] [--url <url>]"
|
||||
"[--depth <depth>] [--] [<path>...]"),
|
||||
"[--reference <repository>] [--name <name>] [--depth <depth>] "
|
||||
"--url <url> --path <path>"),
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -191,6 +192,10 @@ static int module_clone(int argc, const char **argv, const char *prefix)
|
||||
if (!path || !*path)
|
||||
die(_("submodule--helper: unspecified or empty --path"));
|
||||
|
||||
if (argc || !url)
|
||||
usage_with_options(git_submodule_helper_usage,
|
||||
module_clone_options);
|
||||
|
||||
strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
|
||||
sm_gitdir = xstrdup(absolute_path(sb.buf));
|
||||
strbuf_reset(&sb);
|
||||
|
||||
2
config.c
2
config.c
@@ -162,7 +162,7 @@ void git_config_push_parameter(const char *text)
|
||||
{
|
||||
struct strbuf env = STRBUF_INIT;
|
||||
const char *old = getenv(CONFIG_DATA_ENVIRONMENT);
|
||||
if (old) {
|
||||
if (old && *old) {
|
||||
strbuf_addstr(&env, old);
|
||||
strbuf_addch(&env, ' ');
|
||||
}
|
||||
|
||||
@@ -192,6 +192,17 @@ isnumber()
|
||||
n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1"
|
||||
}
|
||||
|
||||
# Sanitize the local git environment for use within a submodule. We
|
||||
# can't simply use clear_local_git_env since we want to preserve some
|
||||
# of the settings from GIT_CONFIG_PARAMETERS.
|
||||
sanitize_submodule_env()
|
||||
{
|
||||
save_config=$GIT_CONFIG_PARAMETERS
|
||||
clear_local_git_env
|
||||
GIT_CONFIG_PARAMETERS=$save_config
|
||||
export GIT_CONFIG_PARAMETERS
|
||||
}
|
||||
|
||||
#
|
||||
# Add a new submodule to the working tree, .gitmodules and the index
|
||||
#
|
||||
@@ -347,9 +358,9 @@ Use -f if you really want to add it." >&2
|
||||
echo "$(eval_gettext "Reactivating local git directory for submodule '\$sm_name'.")"
|
||||
fi
|
||||
fi
|
||||
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" "$reference" "$depth" || exit
|
||||
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${depth:+"$depth"} || exit
|
||||
(
|
||||
clear_local_git_env
|
||||
sanitize_submodule_env
|
||||
cd "$sm_path" &&
|
||||
# ash fails to wordsplit ${branch:+-b "$branch"...}
|
||||
case "$branch" in
|
||||
@@ -418,7 +429,7 @@ cmd_foreach()
|
||||
name=$(git submodule--helper name "$sm_path")
|
||||
(
|
||||
prefix="$prefix$sm_path/"
|
||||
clear_local_git_env
|
||||
sanitize_submodule_env
|
||||
cd "$sm_path" &&
|
||||
sm_path=$(relative_path "$sm_path") &&
|
||||
# we make $path available to scripts ...
|
||||
@@ -601,14 +612,14 @@ cmd_deinit()
|
||||
}
|
||||
|
||||
is_tip_reachable () (
|
||||
clear_local_git_env
|
||||
sanitize_submodule_env &&
|
||||
cd "$1" &&
|
||||
rev=$(git rev-list -n 1 "$2" --not --all 2>/dev/null) &&
|
||||
test -z "$rev"
|
||||
)
|
||||
|
||||
fetch_in_submodule () (
|
||||
clear_local_git_env
|
||||
sanitize_submodule_env &&
|
||||
cd "$1" &&
|
||||
case "$2" in
|
||||
'')
|
||||
@@ -736,11 +747,11 @@ Maybe you want to use 'update --init'?")"
|
||||
|
||||
if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
|
||||
then
|
||||
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" "$reference" "$depth" || exit
|
||||
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" ${reference:+"$reference"} ${depth:+"$depth"} || exit
|
||||
cloned_modules="$cloned_modules;$name"
|
||||
subsha1=
|
||||
else
|
||||
subsha1=$(clear_local_git_env; cd "$sm_path" &&
|
||||
subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
|
||||
git rev-parse --verify HEAD) ||
|
||||
die "$(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")"
|
||||
fi
|
||||
@@ -750,11 +761,11 @@ Maybe you want to use 'update --init'?")"
|
||||
if test -z "$nofetch"
|
||||
then
|
||||
# Fetch remote before determining tracking $sha1
|
||||
(clear_local_git_env; cd "$sm_path" && git-fetch) ||
|
||||
(sanitize_submodule_env; cd "$sm_path" && git-fetch) ||
|
||||
die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"
|
||||
fi
|
||||
remote_name=$(clear_local_git_env; cd "$sm_path" && get_default_remote)
|
||||
sha1=$(clear_local_git_env; cd "$sm_path" &&
|
||||
remote_name=$(sanitize_submodule_env; cd "$sm_path" && get_default_remote)
|
||||
sha1=$(sanitize_submodule_env; cd "$sm_path" &&
|
||||
git rev-parse --verify "${remote_name}/${branch}") ||
|
||||
die "$(eval_gettext "Unable to find current ${remote_name}/${branch} revision in submodule path '\$sm_path'")"
|
||||
fi
|
||||
@@ -819,7 +830,7 @@ Maybe you want to use 'update --init'?")"
|
||||
die "$(eval_gettext "Invalid update mode '$update_module' for submodule '$name'")"
|
||||
esac
|
||||
|
||||
if (clear_local_git_env; cd "$sm_path" && $command "$sha1")
|
||||
if (sanitize_submodule_env; cd "$sm_path" && $command "$sha1")
|
||||
then
|
||||
say "$say_msg"
|
||||
elif test -n "$must_die_on_failure"
|
||||
@@ -835,7 +846,7 @@ Maybe you want to use 'update --init'?")"
|
||||
then
|
||||
(
|
||||
prefix="$prefix$sm_path/"
|
||||
clear_local_git_env
|
||||
sanitize_submodule_env
|
||||
cd "$sm_path" &&
|
||||
eval cmd_update
|
||||
)
|
||||
@@ -873,7 +884,7 @@ Maybe you want to use 'update --init'?")"
|
||||
|
||||
set_name_rev () {
|
||||
revname=$( (
|
||||
clear_local_git_env
|
||||
sanitize_submodule_env
|
||||
cd "$1" && {
|
||||
git describe "$2" 2>/dev/null ||
|
||||
git describe --tags "$2" 2>/dev/null ||
|
||||
@@ -1157,7 +1168,7 @@ cmd_status()
|
||||
else
|
||||
if test -z "$cached"
|
||||
then
|
||||
sha1=$(clear_local_git_env; cd "$sm_path" && git rev-parse --verify HEAD)
|
||||
sha1=$(sanitize_submodule_env; cd "$sm_path" && git rev-parse --verify HEAD)
|
||||
fi
|
||||
set_name_rev "$sm_path" "$sha1"
|
||||
say "+$sha1 $displaypath$revname"
|
||||
@@ -1167,7 +1178,7 @@ cmd_status()
|
||||
then
|
||||
(
|
||||
prefix="$displaypath/"
|
||||
clear_local_git_env
|
||||
sanitize_submodule_env
|
||||
wt_prefix=
|
||||
cd "$sm_path" &&
|
||||
eval cmd_status
|
||||
@@ -1242,7 +1253,7 @@ cmd_sync()
|
||||
if test -e "$sm_path"/.git
|
||||
then
|
||||
(
|
||||
clear_local_git_env
|
||||
sanitize_submodule_env
|
||||
cd "$sm_path"
|
||||
remote=$(get_default_remote)
|
||||
git config remote."$remote".url "$sub_origin_url"
|
||||
|
||||
10
http-push.c
10
http-push.c
@@ -211,7 +211,7 @@ static void curl_setup_http(CURL *curl, const char *url,
|
||||
static struct curl_slist *get_dav_token_headers(struct remote_lock *lock, enum dav_header_flag options)
|
||||
{
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
struct curl_slist *dav_headers = NULL;
|
||||
struct curl_slist *dav_headers = http_copy_default_headers();
|
||||
|
||||
if (options & DAV_HEADER_IF) {
|
||||
strbuf_addf(&buf, "If: (<%s>)", lock->token);
|
||||
@@ -417,7 +417,7 @@ static void start_put(struct transfer_request *request)
|
||||
static void start_move(struct transfer_request *request)
|
||||
{
|
||||
struct active_request_slot *slot;
|
||||
struct curl_slist *dav_headers = NULL;
|
||||
struct curl_slist *dav_headers = http_copy_default_headers();
|
||||
|
||||
slot = get_active_slot();
|
||||
slot->callback_func = process_response;
|
||||
@@ -845,7 +845,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
|
||||
char *ep;
|
||||
char timeout_header[25];
|
||||
struct remote_lock *lock = NULL;
|
||||
struct curl_slist *dav_headers = NULL;
|
||||
struct curl_slist *dav_headers = http_copy_default_headers();
|
||||
struct xml_ctx ctx;
|
||||
char *escaped;
|
||||
|
||||
@@ -1126,7 +1126,7 @@ static void remote_ls(const char *path, int flags,
|
||||
struct slot_results results;
|
||||
struct strbuf in_buffer = STRBUF_INIT;
|
||||
struct buffer out_buffer = { STRBUF_INIT, 0 };
|
||||
struct curl_slist *dav_headers = NULL;
|
||||
struct curl_slist *dav_headers = http_copy_default_headers();
|
||||
struct xml_ctx ctx;
|
||||
struct remote_ls_ctx ls;
|
||||
|
||||
@@ -1204,7 +1204,7 @@ static int locking_available(void)
|
||||
struct slot_results results;
|
||||
struct strbuf in_buffer = STRBUF_INIT;
|
||||
struct buffer out_buffer = { STRBUF_INIT, 0 };
|
||||
struct curl_slist *dav_headers = NULL;
|
||||
struct curl_slist *dav_headers = http_copy_default_headers();
|
||||
struct xml_ctx ctx;
|
||||
int lock_flags = 0;
|
||||
char *escaped;
|
||||
|
||||
35
http.c
35
http.c
@@ -114,6 +114,7 @@ static unsigned long http_auth_methods = CURLAUTH_ANY;
|
||||
|
||||
static struct curl_slist *pragma_header;
|
||||
static struct curl_slist *no_pragma_header;
|
||||
static struct curl_slist *extra_http_headers;
|
||||
|
||||
static struct active_request_slot *active_queue_head;
|
||||
|
||||
@@ -323,6 +324,19 @@ static int http_options(const char *var, const char *value, void *cb)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!strcmp("http.extraheader", var)) {
|
||||
if (!value) {
|
||||
return config_error_nonbool(var);
|
||||
} else if (!*value) {
|
||||
curl_slist_free_all(extra_http_headers);
|
||||
extra_http_headers = NULL;
|
||||
} else {
|
||||
extra_http_headers =
|
||||
curl_slist_append(extra_http_headers, value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Fall back on the default ones */
|
||||
return git_default_config(var, value, cb);
|
||||
}
|
||||
@@ -678,8 +692,10 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
|
||||
if (remote)
|
||||
var_override(&http_proxy_authmethod, remote->http_proxy_authmethod);
|
||||
|
||||
pragma_header = curl_slist_append(pragma_header, "Pragma: no-cache");
|
||||
no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
|
||||
pragma_header = curl_slist_append(http_copy_default_headers(),
|
||||
"Pragma: no-cache");
|
||||
no_pragma_header = curl_slist_append(http_copy_default_headers(),
|
||||
"Pragma:");
|
||||
|
||||
#ifdef USE_CURL_MULTI
|
||||
{
|
||||
@@ -765,6 +781,9 @@ void http_cleanup(void)
|
||||
#endif
|
||||
curl_global_cleanup();
|
||||
|
||||
curl_slist_free_all(extra_http_headers);
|
||||
extra_http_headers = NULL;
|
||||
|
||||
curl_slist_free_all(pragma_header);
|
||||
pragma_header = NULL;
|
||||
|
||||
@@ -1163,6 +1182,16 @@ int run_one_slot(struct active_request_slot *slot,
|
||||
return handle_curl_result(results);
|
||||
}
|
||||
|
||||
struct curl_slist *http_copy_default_headers(void)
|
||||
{
|
||||
struct curl_slist *headers = NULL, *h;
|
||||
|
||||
for (h = extra_http_headers; h; h = h->next)
|
||||
headers = curl_slist_append(headers, h->data);
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
static CURLcode curlinfo_strbuf(CURL *curl, CURLINFO info, struct strbuf *buf)
|
||||
{
|
||||
char *ptr;
|
||||
@@ -1380,7 +1409,7 @@ static int http_request(const char *url,
|
||||
{
|
||||
struct active_request_slot *slot;
|
||||
struct slot_results results;
|
||||
struct curl_slist *headers = NULL;
|
||||
struct curl_slist *headers = http_copy_default_headers();
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
const char *accept_language;
|
||||
int ret;
|
||||
|
||||
1
http.h
1
http.h
@@ -106,6 +106,7 @@ extern void step_active_slots(void);
|
||||
extern void http_init(struct remote *remote, const char *url,
|
||||
int proactive_auth);
|
||||
extern void http_cleanup(void);
|
||||
extern struct curl_slist *http_copy_default_headers(void);
|
||||
|
||||
extern long int git_curl_ipresolve;
|
||||
extern int active_requests;
|
||||
|
||||
13
quote.c
13
quote.c
@@ -43,6 +43,19 @@ void sq_quote_buf(struct strbuf *dst, const char *src)
|
||||
free(to_free);
|
||||
}
|
||||
|
||||
void sq_quotef(struct strbuf *dst, const char *fmt, ...)
|
||||
{
|
||||
struct strbuf src = STRBUF_INIT;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
strbuf_vaddf(&src, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
sq_quote_buf(dst, src.buf);
|
||||
strbuf_release(&src);
|
||||
}
|
||||
|
||||
void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
|
||||
{
|
||||
int i;
|
||||
|
||||
3
quote.h
3
quote.h
@@ -25,10 +25,13 @@ struct strbuf;
|
||||
* sq_quote_buf() writes to an existing buffer of specified size; it
|
||||
* will return the number of characters that would have been written
|
||||
* excluding the final null regardless of the buffer size.
|
||||
*
|
||||
* sq_quotef() quotes the entire formatted string as a single result.
|
||||
*/
|
||||
|
||||
extern void sq_quote_buf(struct strbuf *, const char *src);
|
||||
extern void sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen);
|
||||
extern void sq_quotef(struct strbuf *, const char *fmt, ...);
|
||||
|
||||
/* This unwraps what sq_quote() produces in place, but returns
|
||||
* NULL if the input does not look like what sq_quote would have
|
||||
|
||||
@@ -474,7 +474,7 @@ static int run_slot(struct active_request_slot *slot,
|
||||
static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
|
||||
{
|
||||
struct active_request_slot *slot;
|
||||
struct curl_slist *headers = NULL;
|
||||
struct curl_slist *headers = http_copy_default_headers();
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
int err;
|
||||
|
||||
@@ -503,7 +503,7 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
|
||||
static int post_rpc(struct rpc_state *rpc)
|
||||
{
|
||||
struct active_request_slot *slot;
|
||||
struct curl_slist *headers = NULL;
|
||||
struct curl_slist *headers = http_copy_default_headers();
|
||||
int use_gzip = rpc->gzip_request;
|
||||
char *gzip_body = NULL;
|
||||
size_t gzip_size = 0;
|
||||
|
||||
25
submodule.c
25
submodule.c
@@ -13,6 +13,7 @@
|
||||
#include "argv-array.h"
|
||||
#include "blob.h"
|
||||
#include "thread-utils.h"
|
||||
#include "quote.h"
|
||||
|
||||
static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
|
||||
static struct string_list changed_submodule_paths;
|
||||
@@ -366,7 +367,7 @@ static int submodule_needs_pushing(const char *path, const unsigned char sha1[20
|
||||
|
||||
argv[1] = sha1_to_hex(sha1);
|
||||
cp.argv = argv;
|
||||
cp.env = local_repo_env;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
cp.git_cmd = 1;
|
||||
cp.no_stdin = 1;
|
||||
cp.out = -1;
|
||||
@@ -453,7 +454,7 @@ static int push_submodule(const char *path)
|
||||
const char *argv[] = {"push", NULL};
|
||||
|
||||
cp.argv = argv;
|
||||
cp.env = local_repo_env;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
cp.git_cmd = 1;
|
||||
cp.no_stdin = 1;
|
||||
cp.dir = path;
|
||||
@@ -499,7 +500,7 @@ static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
|
||||
|
||||
argv[3] = sha1_to_hex(sha1);
|
||||
cp.argv = argv;
|
||||
cp.env = local_repo_env;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
cp.git_cmd = 1;
|
||||
cp.no_stdin = 1;
|
||||
cp.dir = path;
|
||||
@@ -682,7 +683,7 @@ static int get_next_submodule(struct child_process *cp,
|
||||
if (is_directory(git_dir)) {
|
||||
child_process_init(cp);
|
||||
cp->dir = strbuf_detach(&submodule_path, NULL);
|
||||
cp->env = local_repo_env;
|
||||
prepare_submodule_repo_env(&cp->env_array);
|
||||
cp->git_cmd = 1;
|
||||
if (!spf->quiet)
|
||||
strbuf_addf(err, "Fetching submodule %s%s\n",
|
||||
@@ -794,7 +795,7 @@ unsigned is_submodule_modified(const char *path, int ignore_untracked)
|
||||
argv[2] = "-uno";
|
||||
|
||||
cp.argv = argv;
|
||||
cp.env = local_repo_env;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
cp.git_cmd = 1;
|
||||
cp.no_stdin = 1;
|
||||
cp.out = -1;
|
||||
@@ -855,7 +856,7 @@ int submodule_uses_gitfile(const char *path)
|
||||
|
||||
/* Now test that all nested submodules use a gitfile too */
|
||||
cp.argv = argv;
|
||||
cp.env = local_repo_env;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
cp.git_cmd = 1;
|
||||
cp.no_stdin = 1;
|
||||
cp.no_stderr = 1;
|
||||
@@ -888,7 +889,7 @@ int ok_to_remove_submodule(const char *path)
|
||||
return 0;
|
||||
|
||||
cp.argv = argv;
|
||||
cp.env = local_repo_env;
|
||||
prepare_submodule_repo_env(&cp.env_array);
|
||||
cp.git_cmd = 1;
|
||||
cp.no_stdin = 1;
|
||||
cp.out = -1;
|
||||
@@ -1094,3 +1095,13 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
|
||||
strbuf_release(&rel_path);
|
||||
free((void *)real_work_tree);
|
||||
}
|
||||
|
||||
void prepare_submodule_repo_env(struct argv_array *out)
|
||||
{
|
||||
const char * const *var;
|
||||
|
||||
for (var = local_repo_env; *var; var++) {
|
||||
if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
|
||||
argv_array_push(out, *var);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,11 @@ int find_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_nam
|
||||
int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name);
|
||||
void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
|
||||
|
||||
/*
|
||||
* Prepare the "env_array" parameter of a "struct child_process" for executing
|
||||
* a submodule by clearing any repo-specific envirionment variables, but
|
||||
* retaining any config in the environment.
|
||||
*/
|
||||
void prepare_submodule_repo_env(struct argv_array *out);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,6 +102,10 @@ Alias /auth/dumb/ www/auth/dumb/
|
||||
SetEnv GIT_HTTP_EXPORT_ALL
|
||||
Header set Set-Cookie name=value
|
||||
</LocationMatch>
|
||||
<LocationMatch /smart_headers/>
|
||||
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
|
||||
SetEnv GIT_HTTP_EXPORT_ALL
|
||||
</LocationMatch>
|
||||
ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
|
||||
ScriptAlias /broken_smart/ broken-smart-http.sh/
|
||||
ScriptAlias /error/ error.sh/
|
||||
@@ -128,6 +132,18 @@ RewriteRule ^/ftp-redir/(.*)$ ftp://localhost:1000/$1 [R=302]
|
||||
RewriteRule ^/loop-redir/x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-(.*) /$1 [R=302]
|
||||
RewriteRule ^/loop-redir/(.*)$ /loop-redir/x-$1 [R=302]
|
||||
|
||||
# Apache 2.2 does not understand <RequireAll>, so we use RewriteCond.
|
||||
# And as RewriteCond does not allow testing for non-matches, we match
|
||||
# the desired case first (one has abra, two has cadabra), and let it
|
||||
# pass by marking the RewriteRule as [L], "last rule, do not process
|
||||
# any other matching RewriteRules after this"), and then have another
|
||||
# RewriteRule that matches all other cases and lets them fail via '[F]',
|
||||
# "fail the request".
|
||||
RewriteCond %{HTTP:x-magic-one} =abra
|
||||
RewriteCond %{HTTP:x-magic-two} =cadabra
|
||||
RewriteRule ^/smart_headers/.* - [L]
|
||||
RewriteRule ^/smart_headers/.* - [F]
|
||||
|
||||
<IfDefine SSL>
|
||||
LoadModule ssl_module modules/mod_ssl.so
|
||||
|
||||
|
||||
@@ -1087,6 +1087,20 @@ test_expect_success 'git -c complains about empty key and value' '
|
||||
test_must_fail git -c "" rev-parse
|
||||
'
|
||||
|
||||
test_expect_success 'multiple git -c appends config' '
|
||||
test_config alias.x "!git -c x.two=2 config --get-regexp ^x\.*" &&
|
||||
cat >expect <<-\EOF &&
|
||||
x.one 1
|
||||
x.two 2
|
||||
EOF
|
||||
git -c x.one=1 x >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'git -c is not confused by empty environment' '
|
||||
GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
|
||||
'
|
||||
|
||||
test_expect_success 'git config --edit works' '
|
||||
git config -f tmp test.value no &&
|
||||
echo test.value=yes >expect &&
|
||||
|
||||
@@ -91,6 +91,55 @@ test_expect_success 'configured username does not override URL' '
|
||||
expect_askpass pass user@host
|
||||
'
|
||||
|
||||
test_expect_success 'set up repo with http submodules' '
|
||||
git init super &&
|
||||
set_askpass user@host pass@host &&
|
||||
(
|
||||
cd super &&
|
||||
git submodule add "$HTTPD_URL/auth/dumb/repo.git" sub &&
|
||||
git commit -m "add submodule"
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'cmdline credential config passes to submodule via clone' '
|
||||
set_askpass wrong pass@host &&
|
||||
test_must_fail git clone --recursive super super-clone &&
|
||||
rm -rf super-clone &&
|
||||
|
||||
set_askpass wrong pass@host &&
|
||||
git -c "credential.$HTTPD_URL.username=user@host" \
|
||||
clone --recursive super super-clone &&
|
||||
expect_askpass pass user@host
|
||||
'
|
||||
|
||||
test_expect_success 'cmdline credential config passes submodule via fetch' '
|
||||
set_askpass wrong pass@host &&
|
||||
test_must_fail git -C super-clone fetch --recurse-submodules &&
|
||||
|
||||
set_askpass wrong pass@host &&
|
||||
git -C super-clone \
|
||||
-c "credential.$HTTPD_URL.username=user@host" \
|
||||
fetch --recurse-submodules &&
|
||||
expect_askpass pass user@host
|
||||
'
|
||||
|
||||
test_expect_success 'cmdline credential config passes submodule update' '
|
||||
# advance the submodule HEAD so that a fetch is required
|
||||
git commit --allow-empty -m foo &&
|
||||
git push "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git" HEAD &&
|
||||
sha1=$(git rev-parse HEAD) &&
|
||||
git -C super-clone update-index --cacheinfo 160000,$sha1,sub &&
|
||||
|
||||
set_askpass wrong pass@host &&
|
||||
test_must_fail git -C super-clone submodule update &&
|
||||
|
||||
set_askpass wrong pass@host &&
|
||||
git -C super-clone \
|
||||
-c "credential.$HTTPD_URL.username=user@host" \
|
||||
submodule update &&
|
||||
expect_askpass pass user@host
|
||||
'
|
||||
|
||||
test_expect_success 'fetch changes via http' '
|
||||
echo content >>file &&
|
||||
git commit -a -m two &&
|
||||
|
||||
@@ -282,5 +282,22 @@ test_expect_success EXPENSIVE 'http can handle enormous ref negotiation' '
|
||||
test_line_count = 100000 tags
|
||||
'
|
||||
|
||||
test_expect_success 'custom http headers' '
|
||||
test_must_fail git -c http.extraheader="x-magic-two: cadabra" \
|
||||
fetch "$HTTPD_URL/smart_headers/repo.git" &&
|
||||
git -c http.extraheader="x-magic-one: abra" \
|
||||
-c http.extraheader="x-magic-two: cadabra" \
|
||||
fetch "$HTTPD_URL/smart_headers/repo.git" &&
|
||||
git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&
|
||||
git config -f .gitmodules submodule.sub.path sub &&
|
||||
git config -f .gitmodules submodule.sub.url \
|
||||
"$HTTPD_URL/smart_headers/repo.git" &&
|
||||
git submodule init sub &&
|
||||
test_must_fail git submodule update sub &&
|
||||
git -c http.extraheader="x-magic-one: abra" \
|
||||
-c http.extraheader="x-magic-two: cadabra" \
|
||||
submodule update sub
|
||||
'
|
||||
|
||||
stop_httpd
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user