Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
ecf9b4a443 | |||
122512967e | |||
abd4d67ab0 | |||
0ca6ead81e | |||
71ad7fe1bc | |||
32696a4cbe | |||
a1d4f67c12 | |||
f4a32a550f | |||
0d3beb71da | |||
0f21b8f468 | |||
225d2d50cc | |||
ac7e57fa28 | |||
f8d510ed0b | |||
99f4abb8da | |||
8a96dbcb33 | |||
7de0c306f7 | |||
6f054f9fb3 | |||
5b1c746c35 | |||
2f8809f9a1 | |||
88b7be68a4 | |||
3b0bf27049 | |||
b779214eaf | |||
6b11e3d52e | |||
b9063afda1 | |||
ae9abbb63e | |||
5f1a3fec8c |
12
Documentation/RelNotes/2.30.5.txt
Normal file
12
Documentation/RelNotes/2.30.5.txt
Normal file
@ -0,0 +1,12 @@
|
||||
Git v2.30.5 Release Notes
|
||||
=========================
|
||||
|
||||
This release contains minor fix-ups for the changes that went into
|
||||
Git 2.30.3 and 2.30.4, addressing CVE-2022-29187.
|
||||
|
||||
* The safety check that verifies a safe ownership of the Git
|
||||
worktree is now extended to also cover the ownership of the Git
|
||||
directory (and the `.git` file, if there is any).
|
||||
|
||||
Carlo Marcelo Arenas Belón (1):
|
||||
setup: tighten ownership checks post CVE-2022-24765
|
60
Documentation/RelNotes/2.30.6.txt
Normal file
60
Documentation/RelNotes/2.30.6.txt
Normal file
@ -0,0 +1,60 @@
|
||||
Git v2.30.6 Release Notes
|
||||
=========================
|
||||
|
||||
This release addresses the security issues CVE-2022-39253 and
|
||||
CVE-2022-39260.
|
||||
|
||||
Fixes since v2.30.5
|
||||
-------------------
|
||||
|
||||
* CVE-2022-39253:
|
||||
When relying on the `--local` clone optimization, Git dereferences
|
||||
symbolic links in the source repository before creating hardlinks
|
||||
(or copies) of the dereferenced link in the destination repository.
|
||||
This can lead to surprising behavior where arbitrary files are
|
||||
present in a repository's `$GIT_DIR` when cloning from a malicious
|
||||
repository.
|
||||
|
||||
Git will no longer dereference symbolic links via the `--local`
|
||||
clone mechanism, and will instead refuse to clone repositories that
|
||||
have symbolic links present in the `$GIT_DIR/objects` directory.
|
||||
|
||||
Additionally, the value of `protocol.file.allow` is changed to be
|
||||
"user" by default.
|
||||
|
||||
* CVE-2022-39260:
|
||||
An overly-long command string given to `git shell` can result in
|
||||
overflow in `split_cmdline()`, leading to arbitrary heap writes and
|
||||
remote code execution when `git shell` is exposed and the directory
|
||||
`$HOME/git-shell-commands` exists.
|
||||
|
||||
`git shell` is taught to refuse interactive commands that are
|
||||
longer than 4MiB in size. `split_cmdline()` is hardened to reject
|
||||
inputs larger than 2GiB.
|
||||
|
||||
Credit for finding CVE-2022-39253 goes to Cory Snider of Mirantis. The
|
||||
fix was authored by Taylor Blau, with help from Johannes Schindelin.
|
||||
|
||||
Credit for finding CVE-2022-39260 goes to Kevin Backhouse of GitHub.
|
||||
The fix was authored by Kevin Backhouse, Jeff King, and Taylor Blau.
|
||||
|
||||
|
||||
Jeff King (2):
|
||||
shell: add basic tests
|
||||
shell: limit size of interactive commands
|
||||
|
||||
Kevin Backhouse (1):
|
||||
alias.c: reject too-long cmdline strings in split_cmdline()
|
||||
|
||||
Taylor Blau (11):
|
||||
builtin/clone.c: disallow `--local` clones with symlinks
|
||||
t/lib-submodule-update.sh: allow local submodules
|
||||
t/t1NNN: allow local submodules
|
||||
t/2NNNN: allow local submodules
|
||||
t/t3NNN: allow local submodules
|
||||
t/t4NNN: allow local submodules
|
||||
t/t5NNN: allow local submodules
|
||||
t/t6NNN: allow local submodules
|
||||
t/t7NNN: allow local submodules
|
||||
t/t9NNN: allow local submodules
|
||||
transport: make `protocol.file.allow` be "user" by default
|
6
Documentation/RelNotes/2.31.4.txt
Normal file
6
Documentation/RelNotes/2.31.4.txt
Normal file
@ -0,0 +1,6 @@
|
||||
Git v2.31.4 Release Notes
|
||||
=========================
|
||||
|
||||
This release merges up the fixes that appear in v2.30.5 to address
|
||||
the security issue CVE-2022-29187; see the release notes for that
|
||||
version for details.
|
5
Documentation/RelNotes/2.31.5.txt
Normal file
5
Documentation/RelNotes/2.31.5.txt
Normal file
@ -0,0 +1,5 @@
|
||||
Git v2.31.5 Release Notes
|
||||
=========================
|
||||
|
||||
This release merges the security fix that appears in v2.30.6; see
|
||||
the release notes for that version for details.
|
@ -1,10 +1,10 @@
|
||||
protocol.allow::
|
||||
If set, provide a user defined default policy for all protocols which
|
||||
don't explicitly have a policy (`protocol.<name>.allow`). By default,
|
||||
if unset, known-safe protocols (http, https, git, ssh, file) have a
|
||||
if unset, known-safe protocols (http, https, git, ssh) have a
|
||||
default policy of `always`, known-dangerous protocols (ext) have a
|
||||
default policy of `never`, and all other protocols have a default
|
||||
policy of `user`. Supported policies:
|
||||
default policy of `never`, and all other protocols (including file)
|
||||
have a default policy of `user`. Supported policies:
|
||||
+
|
||||
--
|
||||
|
||||
|
@ -26,3 +26,17 @@ directory was listed in the `safe.directory` list. If `safe.directory=*`
|
||||
is set in system config and you want to re-enable this protection, then
|
||||
initialize your list with an empty value before listing the repositories
|
||||
that you deem safe.
|
||||
+
|
||||
As explained, Git only allows you to access repositories owned by
|
||||
yourself, i.e. the user who is running Git, by default. When Git
|
||||
is running as 'root' in a non Windows platform that provides sudo,
|
||||
however, git checks the SUDO_UID environment variable that sudo creates
|
||||
and will allow access to the uid recorded as its value in addition to
|
||||
the id from 'root'.
|
||||
This is to make it easy to perform a common sequence during installation
|
||||
"make && sudo make install". A git process running under 'sudo' runs as
|
||||
'root' but the 'sudo' command exports the environment variable to record
|
||||
which id the original user has.
|
||||
If that is not what you would prefer and want git to only trust
|
||||
repositories that are owned by root instead, then you can remove
|
||||
the `SUDO_UID` variable from root's environment before invoking git.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
GVF=GIT-VERSION-FILE
|
||||
DEF_VER=v2.31.3
|
||||
DEF_VER=v2.31.5
|
||||
|
||||
LF='
|
||||
'
|
||||
|
11
alias.c
11
alias.c
@ -46,14 +46,16 @@ void list_aliases(struct string_list *list)
|
||||
|
||||
#define SPLIT_CMDLINE_BAD_ENDING 1
|
||||
#define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
|
||||
#define SPLIT_CMDLINE_ARGC_OVERFLOW 3
|
||||
static const char *split_cmdline_errors[] = {
|
||||
N_("cmdline ends with \\"),
|
||||
N_("unclosed quote")
|
||||
N_("unclosed quote"),
|
||||
N_("too many arguments"),
|
||||
};
|
||||
|
||||
int split_cmdline(char *cmdline, const char ***argv)
|
||||
{
|
||||
int src, dst, count = 0, size = 16;
|
||||
size_t src, dst, count = 0, size = 16;
|
||||
char quoted = 0;
|
||||
|
||||
ALLOC_ARRAY(*argv, size);
|
||||
@ -96,6 +98,11 @@ int split_cmdline(char *cmdline, const char ***argv)
|
||||
return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
|
||||
}
|
||||
|
||||
if (count >= INT_MAX) {
|
||||
FREE_AND_NULL(*argv);
|
||||
return -SPLIT_CMDLINE_ARGC_OVERFLOW;
|
||||
}
|
||||
|
||||
ALLOC_GROW(*argv, count + 1, size);
|
||||
(*argv)[count] = NULL;
|
||||
|
||||
|
@ -420,13 +420,11 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
|
||||
int src_len, dest_len;
|
||||
struct dir_iterator *iter;
|
||||
int iter_status;
|
||||
unsigned int flags;
|
||||
struct strbuf realpath = STRBUF_INIT;
|
||||
|
||||
mkdir_if_missing(dest->buf, 0777);
|
||||
|
||||
flags = DIR_ITERATOR_PEDANTIC | DIR_ITERATOR_FOLLOW_SYMLINKS;
|
||||
iter = dir_iterator_begin(src->buf, flags);
|
||||
iter = dir_iterator_begin(src->buf, DIR_ITERATOR_PEDANTIC);
|
||||
|
||||
if (!iter)
|
||||
die_errno(_("failed to start iterator over '%s'"), src->buf);
|
||||
@ -442,6 +440,10 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
|
||||
strbuf_setlen(dest, dest_len);
|
||||
strbuf_addstr(dest, iter->relative_path);
|
||||
|
||||
if (S_ISLNK(iter->st.st_mode))
|
||||
die(_("symlink '%s' exists, refusing to clone with --local"),
|
||||
iter->relative_path);
|
||||
|
||||
if (S_ISDIR(iter->st.st_mode)) {
|
||||
mkdir_if_missing(dest->buf, 0777);
|
||||
continue;
|
||||
|
@ -393,12 +393,68 @@ static inline int git_offset_1st_component(const char *path)
|
||||
#endif
|
||||
|
||||
#ifndef is_path_owned_by_current_user
|
||||
|
||||
#ifdef __TANDEM
|
||||
#define ROOT_UID 65535
|
||||
#else
|
||||
#define ROOT_UID 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Do not use this function when
|
||||
* (1) geteuid() did not say we are running as 'root', or
|
||||
* (2) using this function will compromise the system.
|
||||
*
|
||||
* PORTABILITY WARNING:
|
||||
* This code assumes uid_t is unsigned because that is what sudo does.
|
||||
* If your uid_t type is signed and all your ids are positive then it
|
||||
* should all work fine.
|
||||
* If your version of sudo uses negative values for uid_t or it is
|
||||
* buggy and return an overflowed value in SUDO_UID, then git might
|
||||
* fail to grant access to your repository properly or even mistakenly
|
||||
* grant access to someone else.
|
||||
* In the unlikely scenario this happened to you, and that is how you
|
||||
* got to this message, we would like to know about it; so sent us an
|
||||
* email to git@vger.kernel.org indicating which platform you are
|
||||
* using and which version of sudo, so we can improve this logic and
|
||||
* maybe provide you with a patch that would prevent this issue again
|
||||
* in the future.
|
||||
*/
|
||||
static inline void extract_id_from_env(const char *env, uid_t *id)
|
||||
{
|
||||
const char *real_uid = getenv(env);
|
||||
|
||||
/* discard anything empty to avoid a more complex check below */
|
||||
if (real_uid && *real_uid) {
|
||||
char *endptr = NULL;
|
||||
unsigned long env_id;
|
||||
|
||||
errno = 0;
|
||||
/* silent overflow errors could trigger a bug here */
|
||||
env_id = strtoul(real_uid, &endptr, 10);
|
||||
if (!*endptr && !errno)
|
||||
*id = env_id;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int is_path_owned_by_current_uid(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
uid_t euid;
|
||||
|
||||
if (lstat(path, &st))
|
||||
return 0;
|
||||
return st.st_uid == geteuid();
|
||||
|
||||
euid = geteuid();
|
||||
if (euid == ROOT_UID)
|
||||
{
|
||||
if (st.st_uid == ROOT_UID)
|
||||
return 1;
|
||||
else
|
||||
extract_id_from_env("SUDO_UID", &euid);
|
||||
}
|
||||
|
||||
return st.st_uid == euid;
|
||||
}
|
||||
|
||||
#define is_path_owned_by_current_user is_path_owned_by_current_uid
|
||||
|
69
setup.c
69
setup.c
@ -1054,14 +1054,32 @@ static int safe_directory_cb(const char *key, const char *value, void *d)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ensure_valid_ownership(const char *path)
|
||||
/*
|
||||
* Check if a repository is safe, by verifying the ownership of the
|
||||
* worktree (if any), the git directory, and the gitfile (if any).
|
||||
*
|
||||
* Exemptions for known-safe repositories can be added via `safe.directory`
|
||||
* config settings; for non-bare repositories, their worktree needs to be
|
||||
* added, for bare ones their git directory.
|
||||
*/
|
||||
static int ensure_valid_ownership(const char *gitfile,
|
||||
const char *worktree, const char *gitdir)
|
||||
{
|
||||
struct safe_directory_data data = { .path = path };
|
||||
struct safe_directory_data data = {
|
||||
.path = worktree ? worktree : gitdir
|
||||
};
|
||||
|
||||
if (!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0) &&
|
||||
is_path_owned_by_current_user(path))
|
||||
(!gitfile || is_path_owned_by_current_user(gitfile)) &&
|
||||
(!worktree || is_path_owned_by_current_user(worktree)) &&
|
||||
(!gitdir || is_path_owned_by_current_user(gitdir)))
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* data.path is the "path" that identifies the repository and it is
|
||||
* constant regardless of what failed above. data.is_safe should be
|
||||
* initialized to false, and might be changed by the callback.
|
||||
*/
|
||||
read_very_early_config(safe_directory_cb, &data);
|
||||
|
||||
return data.is_safe;
|
||||
@ -1149,6 +1167,8 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
|
||||
current_device = get_device_or_die(dir->buf, NULL, 0);
|
||||
for (;;) {
|
||||
int offset = dir->len, error_code = 0;
|
||||
char *gitdir_path = NULL;
|
||||
char *gitfile = NULL;
|
||||
|
||||
if (offset > min_offset)
|
||||
strbuf_addch(dir, '/');
|
||||
@ -1159,21 +1179,50 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
|
||||
if (die_on_error ||
|
||||
error_code == READ_GITFILE_ERR_NOT_A_FILE) {
|
||||
/* NEEDSWORK: fail if .git is not file nor dir */
|
||||
if (is_git_directory(dir->buf))
|
||||
if (is_git_directory(dir->buf)) {
|
||||
gitdirenv = DEFAULT_GIT_DIR_ENVIRONMENT;
|
||||
gitdir_path = xstrdup(dir->buf);
|
||||
}
|
||||
} else if (error_code != READ_GITFILE_ERR_STAT_FAILED)
|
||||
return GIT_DIR_INVALID_GITFILE;
|
||||
}
|
||||
} else
|
||||
gitfile = xstrdup(dir->buf);
|
||||
/*
|
||||
* Earlier, we tentatively added DEFAULT_GIT_DIR_ENVIRONMENT
|
||||
* to check that directory for a repository.
|
||||
* Now trim that tentative addition away, because we want to
|
||||
* focus on the real directory we are in.
|
||||
*/
|
||||
strbuf_setlen(dir, offset);
|
||||
if (gitdirenv) {
|
||||
if (!ensure_valid_ownership(dir->buf))
|
||||
return GIT_DIR_INVALID_OWNERSHIP;
|
||||
enum discovery_result ret;
|
||||
|
||||
if (ensure_valid_ownership(gitfile,
|
||||
dir->buf,
|
||||
(gitdir_path ? gitdir_path : gitdirenv))) {
|
||||
strbuf_addstr(gitdir, gitdirenv);
|
||||
return GIT_DIR_DISCOVERED;
|
||||
ret = GIT_DIR_DISCOVERED;
|
||||
} else
|
||||
ret = GIT_DIR_INVALID_OWNERSHIP;
|
||||
|
||||
/*
|
||||
* Earlier, during discovery, we might have allocated
|
||||
* string copies for gitdir_path or gitfile so make
|
||||
* sure we don't leak by freeing them now, before
|
||||
* leaving the loop and function.
|
||||
*
|
||||
* Note: gitdirenv will be non-NULL whenever these are
|
||||
* allocated, therefore we need not take care of releasing
|
||||
* them outside of this conditional block.
|
||||
*/
|
||||
free(gitdir_path);
|
||||
free(gitfile);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (is_git_directory(dir->buf)) {
|
||||
if (!ensure_valid_ownership(dir->buf))
|
||||
if (!ensure_valid_ownership(NULL, NULL, dir->buf))
|
||||
return GIT_DIR_INVALID_OWNERSHIP;
|
||||
strbuf_addstr(gitdir, ".");
|
||||
return GIT_DIR_BARE;
|
||||
@ -1306,7 +1355,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
|
||||
struct strbuf quoted = STRBUF_INIT;
|
||||
|
||||
sq_quote_buf_pretty("ed, dir.buf);
|
||||
die(_("unsafe repository ('%s' is owned by someone else)\n"
|
||||
die(_("detected dubious ownership in repository at '%s'\n"
|
||||
"To add an exception for this directory, call:\n"
|
||||
"\n"
|
||||
"\tgit config --global --add safe.directory %s"),
|
||||
|
34
shell.c
34
shell.c
@ -47,6 +47,8 @@ static void cd_to_homedir(void)
|
||||
die("could not chdir to user's home directory");
|
||||
}
|
||||
|
||||
#define MAX_INTERACTIVE_COMMAND (4*1024*1024)
|
||||
|
||||
static void run_shell(void)
|
||||
{
|
||||
int done = 0;
|
||||
@ -67,22 +69,46 @@ static void run_shell(void)
|
||||
run_command_v_opt(help_argv, RUN_SILENT_EXEC_FAILURE);
|
||||
|
||||
do {
|
||||
struct strbuf line = STRBUF_INIT;
|
||||
const char *prog;
|
||||
char *full_cmd;
|
||||
char *rawargs;
|
||||
size_t len;
|
||||
char *split_args;
|
||||
const char **argv;
|
||||
int code;
|
||||
int count;
|
||||
|
||||
fprintf(stderr, "git> ");
|
||||
if (git_read_line_interactively(&line) == EOF) {
|
||||
|
||||
/*
|
||||
* Avoid using a strbuf or git_read_line_interactively() here.
|
||||
* We don't want to allocate arbitrary amounts of memory on
|
||||
* behalf of a possibly untrusted client, and we're subject to
|
||||
* OS limits on command length anyway.
|
||||
*/
|
||||
fflush(stdout);
|
||||
rawargs = xmalloc(MAX_INTERACTIVE_COMMAND);
|
||||
if (!fgets(rawargs, MAX_INTERACTIVE_COMMAND, stdin)) {
|
||||
fprintf(stderr, "\n");
|
||||
strbuf_release(&line);
|
||||
free(rawargs);
|
||||
break;
|
||||
}
|
||||
rawargs = strbuf_detach(&line, NULL);
|
||||
len = strlen(rawargs);
|
||||
|
||||
/*
|
||||
* If we truncated due to our input buffer size, reject the
|
||||
* command. That's better than running bogus input, and
|
||||
* there's a good chance it's just malicious garbage anyway.
|
||||
*/
|
||||
if (len >= MAX_INTERACTIVE_COMMAND - 1)
|
||||
die("invalid command format: input too long");
|
||||
|
||||
if (len > 0 && rawargs[len - 1] == '\n') {
|
||||
if (--len > 0 && rawargs[len - 1] == '\r')
|
||||
--len;
|
||||
rawargs[len] = '\0';
|
||||
}
|
||||
|
||||
split_args = xstrdup(rawargs);
|
||||
count = split_cmdline(split_args, &argv);
|
||||
if (count < 0) {
|
||||
|
@ -196,6 +196,7 @@ test_git_directory_exists () {
|
||||
# the submodule repo if it doesn't exist and configures the most problematic
|
||||
# settings for diff.ignoreSubmodules.
|
||||
prolog () {
|
||||
test_config_global protocol.file.allow always &&
|
||||
(test -d submodule_update_repo || create_lib_submodule_repo) &&
|
||||
test_config_global diff.ignoreSubmodules all &&
|
||||
test_config diff.ignoreSubmodules all
|
||||
|
15
t/lib-sudo.sh
Normal file
15
t/lib-sudo.sh
Normal file
@ -0,0 +1,15 @@
|
||||
# Helpers for running git commands under sudo.
|
||||
|
||||
# Runs a scriplet passed through stdin under sudo.
|
||||
run_with_sudo () {
|
||||
local ret
|
||||
local RUN="$TEST_DIRECTORY/$$.sh"
|
||||
write_script "$RUN" "$TEST_SHELL_PATH"
|
||||
# avoid calling "$RUN" directly so sudo doesn't get a chance to
|
||||
# override the shell, add aditional restrictions or even reject
|
||||
# running the script because its security policy deem it unsafe
|
||||
sudo "$TEST_SHELL_PATH" -c "\"$RUN\""
|
||||
ret=$?
|
||||
rm -f "$RUN"
|
||||
return $ret
|
||||
}
|
93
t/t0034-root-safe-directory.sh
Executable file
93
t/t0034-root-safe-directory.sh
Executable file
@ -0,0 +1,93 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='verify safe.directory checks while running as root'
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-sudo.sh
|
||||
|
||||
if [ "$GIT_TEST_ALLOW_SUDO" != "YES" ]
|
||||
then
|
||||
skip_all="You must set env var GIT_TEST_ALLOW_SUDO=YES in order to run this test"
|
||||
test_done
|
||||
fi
|
||||
|
||||
if ! test_have_prereq NOT_ROOT
|
||||
then
|
||||
skip_all="These tests do not support running as root"
|
||||
test_done
|
||||
fi
|
||||
|
||||
test_lazy_prereq SUDO '
|
||||
sudo -n id -u >u &&
|
||||
id -u root >r &&
|
||||
test_cmp u r &&
|
||||
command -v git >u &&
|
||||
sudo command -v git >r &&
|
||||
test_cmp u r
|
||||
'
|
||||
|
||||
if ! test_have_prereq SUDO
|
||||
then
|
||||
skip_all="Your sudo/system configuration is either too strict or unsupported"
|
||||
test_done
|
||||
fi
|
||||
|
||||
test_expect_success SUDO 'setup' '
|
||||
sudo rm -rf root &&
|
||||
mkdir -p root/r &&
|
||||
(
|
||||
cd root/r &&
|
||||
git init
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success SUDO 'sudo git status as original owner' '
|
||||
(
|
||||
cd root/r &&
|
||||
git status &&
|
||||
sudo git status
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success SUDO 'setup root owned repository' '
|
||||
sudo mkdir -p root/p &&
|
||||
sudo git init root/p
|
||||
'
|
||||
|
||||
test_expect_success 'cannot access if owned by root' '
|
||||
(
|
||||
cd root/p &&
|
||||
test_must_fail git status
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'can access if addressed explicitly' '
|
||||
(
|
||||
cd root/p &&
|
||||
GIT_DIR=.git GIT_WORK_TREE=. git status
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success SUDO 'can access with sudo if root' '
|
||||
(
|
||||
cd root/p &&
|
||||
sudo git status
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success SUDO 'can access with sudo if root by removing SUDO_UID' '
|
||||
(
|
||||
cd root/p &&
|
||||
run_with_sudo <<-END
|
||||
unset SUDO_UID &&
|
||||
git status
|
||||
END
|
||||
)
|
||||
'
|
||||
|
||||
# this MUST be always the last test
|
||||
test_expect_success SUDO 'cleanup' '
|
||||
sudo rm -rf root
|
||||
'
|
||||
|
||||
test_done
|
@ -452,7 +452,8 @@ test_expect_success 'interaction with submodules' '
|
||||
(
|
||||
cd super &&
|
||||
mkdir modules &&
|
||||
git submodule add ../repo modules/child &&
|
||||
git -c protocol.file.allow=always \
|
||||
submodule add ../repo modules/child &&
|
||||
git add . &&
|
||||
git commit -m "add submodule" &&
|
||||
git sparse-checkout init --cone &&
|
||||
|
@ -221,7 +221,8 @@ test_expect_success 'showing the superproject correctly' '
|
||||
test_commit -C super test_commit &&
|
||||
test_create_repo sub &&
|
||||
test_commit -C sub test_commit &&
|
||||
git -C super submodule add ../sub dir/sub &&
|
||||
git -c protocol.file.allow=always \
|
||||
-C super submodule add ../sub dir/sub &&
|
||||
echo $(pwd)/super >expect &&
|
||||
git -C super/dir/sub rev-parse --show-superproject-working-tree >out &&
|
||||
test_cmp expect out &&
|
||||
|
@ -600,6 +600,7 @@ test_expect_success '"add" should not fail because of another bad worktree' '
|
||||
'
|
||||
|
||||
test_expect_success '"add" with uninitialized submodule, with submodule.recurse unset' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
test_create_repo submodule &&
|
||||
test_commit -C submodule first &&
|
||||
test_create_repo project &&
|
||||
@ -615,6 +616,7 @@ test_expect_success '"add" with uninitialized submodule, with submodule.recurse
|
||||
'
|
||||
|
||||
test_expect_success '"add" with initialized submodule, with submodule.recurse unset' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
git -C project-clone submodule update --init &&
|
||||
git -C project-clone worktree add ../project-4
|
||||
'
|
||||
|
@ -138,7 +138,8 @@ test_expect_success 'move a repo with uninitialized submodule' '
|
||||
(
|
||||
cd withsub &&
|
||||
test_commit initial &&
|
||||
git submodule add "$PWD"/.git sub &&
|
||||
git -c protocol.file.allow=always \
|
||||
submodule add "$PWD"/.git sub &&
|
||||
git commit -m withsub &&
|
||||
git worktree add second HEAD &&
|
||||
git worktree move second third
|
||||
@ -148,7 +149,7 @@ test_expect_success 'move a repo with uninitialized submodule' '
|
||||
test_expect_success 'not move a repo with initialized submodule' '
|
||||
(
|
||||
cd withsub &&
|
||||
git -C third submodule update &&
|
||||
git -c protocol.file.allow=always -C third submodule update &&
|
||||
test_must_fail git worktree move third forth
|
||||
)
|
||||
'
|
||||
@ -227,6 +228,7 @@ test_expect_success 'remove cleans up .git/worktrees when empty' '
|
||||
'
|
||||
|
||||
test_expect_success 'remove a repo with uninitialized submodule' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
(
|
||||
cd withsub &&
|
||||
git worktree add to-remove HEAD &&
|
||||
@ -235,6 +237,7 @@ test_expect_success 'remove a repo with uninitialized submodule' '
|
||||
'
|
||||
|
||||
test_expect_success 'not remove a repo with initialized submodule' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
(
|
||||
cd withsub &&
|
||||
git worktree add to-remove HEAD &&
|
||||
|
@ -10,6 +10,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
base_path=$(pwd -P)
|
||||
|
||||
test_expect_success 'setup: create origin repos' '
|
||||
git config --global protocol.file.allow always &&
|
||||
git init origin/sub &&
|
||||
test_commit -C origin/sub file1 &&
|
||||
git init origin/main &&
|
||||
|
@ -282,6 +282,7 @@ test_expect_success 'deleting checked-out branch from repo that is a submodule'
|
||||
git init repo1 &&
|
||||
git init repo1/sub &&
|
||||
test_commit -C repo1/sub x &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git -C repo1 submodule add ./sub &&
|
||||
git -C repo1 commit -m "adding sub" &&
|
||||
|
||||
|
@ -310,7 +310,7 @@ test_expect_success 'autostash is saved on editor failure with conflict' '
|
||||
test_expect_success 'autostash with dirty submodules' '
|
||||
test_when_finished "git reset --hard && git checkout main" &&
|
||||
git checkout -b with-submodule &&
|
||||
git submodule add ./ sub &&
|
||||
git -c protocol.file.allow=always submodule add ./ sub &&
|
||||
test_tick &&
|
||||
git commit -m add-submodule &&
|
||||
echo changed >sub/file0 &&
|
||||
|
@ -47,7 +47,8 @@ test_expect_success 'rebase interactive ignores modified submodules' '
|
||||
git init sub &&
|
||||
git -C sub commit --allow-empty -m "Initial commit" &&
|
||||
git init super &&
|
||||
git -C super submodule add ../sub &&
|
||||
git -c protocol.file.allow=always \
|
||||
-C super submodule add ../sub &&
|
||||
git -C super config submodule.sub.ignore dirty &&
|
||||
>super/foo &&
|
||||
git -C super add foo &&
|
||||
|
@ -13,6 +13,8 @@ KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
|
||||
test_submodule_switch "cherry-pick"
|
||||
|
||||
test_expect_success 'unrelated submodule/file conflict is ignored' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
|
||||
test_create_repo sub &&
|
||||
|
||||
touch sub/file &&
|
||||
|
@ -336,7 +336,7 @@ test_expect_success 'rm removes empty submodules from work tree' '
|
||||
|
||||
test_expect_success 'rm removes removed submodule from index and .gitmodules' '
|
||||
git reset --hard &&
|
||||
git submodule update &&
|
||||
git -c protocol.file.allow=always submodule update &&
|
||||
rm -rf submod &&
|
||||
git rm submod &&
|
||||
git status -s -uno --ignore-submodules=none >actual &&
|
||||
@ -642,6 +642,7 @@ cat >expect.deepmodified <<EOF
|
||||
EOF
|
||||
|
||||
test_expect_success 'setup subsubmodule' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
git reset --hard &&
|
||||
git submodule update &&
|
||||
(
|
||||
|
@ -36,7 +36,7 @@ setup_basic () {
|
||||
git init main &&
|
||||
(
|
||||
cd main &&
|
||||
git submodule add ../sub &&
|
||||
git -c protocol.file.allow=always submodule add ../sub &&
|
||||
test_commit main_file
|
||||
)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ test_expect_success 'setup - submodules' '
|
||||
'
|
||||
|
||||
test_expect_success 'setup - git submodule add' '
|
||||
git submodule add ./sm2 sm1 &&
|
||||
git -c protocol.file.allow=always submodule add ./sm2 sm1 &&
|
||||
commit_file sm1 .gitmodules &&
|
||||
git diff-tree -p --no-commit-id --submodule=log HEAD -- sm1 >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
|
@ -759,9 +759,9 @@ test_expect_success 'diff --submodule=diff with .git file' '
|
||||
'
|
||||
|
||||
test_expect_success 'setup nested submodule' '
|
||||
git submodule add -f ./sm2 &&
|
||||
git -c protocol.file.allow=always submodule add -f ./sm2 &&
|
||||
git commit -a -m "add sm2" &&
|
||||
git -C sm2 submodule add ../sm2 nested &&
|
||||
git -c protocol.file.allow=always -C sm2 submodule add ../sm2 nested &&
|
||||
git -C sm2 commit -a -m "nested sub" &&
|
||||
head10=$(git -C sm2 rev-parse --short --verify HEAD)
|
||||
'
|
||||
|
@ -77,6 +77,7 @@ test_expect_success 'diff skips same-OID blobs' '
|
||||
|
||||
test_expect_success 'when fetching missing objects, diff skips GITLINKs' '
|
||||
test_when_finished "rm -rf sub server client trace" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
|
||||
test_create_repo sub &&
|
||||
test_commit -C sub first &&
|
||||
|
@ -124,6 +124,7 @@ test_expect_success 'command line pathspec parsing for "git log"' '
|
||||
|
||||
test_expect_success 'tree_entry_interesting does not match past submodule boundaries' '
|
||||
test_when_finished "rm -rf repo submodule" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git init submodule &&
|
||||
test_commit -C submodule initial &&
|
||||
git init repo &&
|
||||
|
@ -782,6 +782,7 @@ test_expect_success 'fetch.writeCommitGraph' '
|
||||
'
|
||||
|
||||
test_expect_success 'fetch.writeCommitGraph with submodules' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
git clone dups super &&
|
||||
(
|
||||
cd super &&
|
||||
|
@ -38,6 +38,7 @@ add_upstream_commit() {
|
||||
}
|
||||
|
||||
test_expect_success setup '
|
||||
git config --global protocol.file.allow always &&
|
||||
mkdir deepsubmodule &&
|
||||
(
|
||||
cd deepsubmodule &&
|
||||
|
@ -116,6 +116,7 @@ test_expect_success 'push options and submodules' '
|
||||
test_commit -C parent one &&
|
||||
git -C parent push --mirror up &&
|
||||
|
||||
test_config_global protocol.file.allow always &&
|
||||
git -C parent submodule add ../upstream workbench &&
|
||||
git -C parent/workbench remote add up ../../upstream &&
|
||||
git -C parent commit -m "add submodule" &&
|
||||
|
@ -46,6 +46,10 @@ KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
|
||||
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
|
||||
test_submodule_switch_func "git_pull_noff"
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'pull --recurse-submodule setup' '
|
||||
test_create_repo child &&
|
||||
test_commit -C child bar &&
|
||||
|
@ -741,6 +741,7 @@ test_expect_success 'batch missing blob request does not inadvertently try to fe
|
||||
echo aa >server/a &&
|
||||
echo bb >server/b &&
|
||||
# Also add a gitlink pointing to an arbitrary repository
|
||||
test_config_global protocol.file.allow always &&
|
||||
git -C server submodule add "$(pwd)/repo_for_submodule" c &&
|
||||
git -C server add a b c &&
|
||||
git -C server commit -m x &&
|
||||
|
@ -303,8 +303,6 @@ test_expect_success SYMLINKS 'setup repo with manually symlinked or unknown file
|
||||
ln -s ../an-object $obj &&
|
||||
|
||||
cd ../ &&
|
||||
find . -type f | sort >../../../T.objects-files.raw &&
|
||||
find . -type l | sort >../../../T.objects-symlinks.raw &&
|
||||
echo unknown_content >unknown_file
|
||||
) &&
|
||||
git -C T fsck &&
|
||||
@ -313,19 +311,27 @@ test_expect_success SYMLINKS 'setup repo with manually symlinked or unknown file
|
||||
|
||||
|
||||
test_expect_success SYMLINKS 'clone repo with symlinked or unknown files at objects/' '
|
||||
for option in --local --no-hardlinks --shared --dissociate
|
||||
# None of these options work when cloning locally, since T has
|
||||
# symlinks in its `$GIT_DIR/objects` directory
|
||||
for option in --local --no-hardlinks --dissociate
|
||||
do
|
||||
git clone $option T T$option || return 1 &&
|
||||
git -C T$option fsck || return 1 &&
|
||||
git -C T$option rev-list --all --objects >T$option.objects &&
|
||||
test_cmp T.objects T$option.objects &&
|
||||
(
|
||||
cd T$option/.git/objects &&
|
||||
find . -type f | sort >../../../T$option.objects-files.raw &&
|
||||
find . -type l | sort >../../../T$option.objects-symlinks.raw
|
||||
)
|
||||
test_must_fail git clone $option T T$option 2>err || return 1 &&
|
||||
test_i18ngrep "symlink.*exists" err || return 1
|
||||
done &&
|
||||
|
||||
# But `--shared` clones should still work, even when specifying
|
||||
# a local path *and* that repository has symlinks present in its
|
||||
# `$GIT_DIR/objects` directory.
|
||||
git clone --shared T T--shared &&
|
||||
git -C T--shared fsck &&
|
||||
git -C T--shared rev-list --all --objects >T--shared.objects &&
|
||||
test_cmp T.objects T--shared.objects &&
|
||||
(
|
||||
cd T--shared/.git/objects &&
|
||||
find . -type f | sort >../../../T--shared.objects-files.raw &&
|
||||
find . -type l | sort >../../../T--shared.objects-symlinks.raw
|
||||
) &&
|
||||
|
||||
for raw in $(ls T*.raw)
|
||||
do
|
||||
sed -e "s!/../!/Y/!; s![0-9a-f]\{38,\}!Z!" -e "/commit-graph/d" \
|
||||
@ -333,26 +339,6 @@ test_expect_success SYMLINKS 'clone repo with symlinked or unknown files at obje
|
||||
sort $raw.de-sha-1 >$raw.de-sha || return 1
|
||||
done &&
|
||||
|
||||
cat >expected-files <<-EOF &&
|
||||
./Y/Z
|
||||
./Y/Z
|
||||
./Y/Z
|
||||
./a-loose-dir/Z
|
||||
./an-object
|
||||
./info/packs
|
||||
./pack/pack-Z.idx
|
||||
./pack/pack-Z.pack
|
||||
./packs/pack-Z.idx
|
||||
./packs/pack-Z.pack
|
||||
./unknown_file
|
||||
EOF
|
||||
|
||||
for option in --local --no-hardlinks --dissociate
|
||||
do
|
||||
test_cmp expected-files T$option.objects-files.raw.de-sha || return 1 &&
|
||||
test_must_be_empty T$option.objects-symlinks.raw.de-sha || return 1
|
||||
done &&
|
||||
|
||||
echo ./info/alternates >expected-files &&
|
||||
test_cmp expected-files T--shared.objects-files.raw &&
|
||||
test_must_be_empty T--shared.objects-symlinks.raw
|
||||
|
@ -24,6 +24,7 @@ test_expect_success 'setup' '
|
||||
|
||||
test_expect_success 'nonshallow clone implies nonshallow submodule' '
|
||||
test_when_finished "rm -rf super_clone" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git clone --recurse-submodules "file://$pwd/." super_clone &&
|
||||
git -C super_clone log --oneline >lines &&
|
||||
test_line_count = 3 lines &&
|
||||
@ -33,6 +34,7 @@ test_expect_success 'nonshallow clone implies nonshallow submodule' '
|
||||
|
||||
test_expect_success 'shallow clone with shallow submodule' '
|
||||
test_when_finished "rm -rf super_clone" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone &&
|
||||
git -C super_clone log --oneline >lines &&
|
||||
test_line_count = 2 lines &&
|
||||
@ -42,6 +44,7 @@ test_expect_success 'shallow clone with shallow submodule' '
|
||||
|
||||
test_expect_success 'shallow clone does not imply shallow submodule' '
|
||||
test_when_finished "rm -rf super_clone" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
|
||||
git -C super_clone log --oneline >lines &&
|
||||
test_line_count = 2 lines &&
|
||||
@ -51,6 +54,7 @@ test_expect_success 'shallow clone does not imply shallow submodule' '
|
||||
|
||||
test_expect_success 'shallow clone with non shallow submodule' '
|
||||
test_when_finished "rm -rf super_clone" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git clone --recurse-submodules --depth 2 --no-shallow-submodules "file://$pwd/." super_clone &&
|
||||
git -C super_clone log --oneline >lines &&
|
||||
test_line_count = 2 lines &&
|
||||
@ -60,6 +64,7 @@ test_expect_success 'shallow clone with non shallow submodule' '
|
||||
|
||||
test_expect_success 'non shallow clone with shallow submodule' '
|
||||
test_when_finished "rm -rf super_clone" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git clone --recurse-submodules --no-local --shallow-submodules "file://$pwd/." super_clone &&
|
||||
git -C super_clone log --oneline >lines &&
|
||||
test_line_count = 3 lines &&
|
||||
@ -69,6 +74,7 @@ test_expect_success 'non shallow clone with shallow submodule' '
|
||||
|
||||
test_expect_success 'clone follows shallow recommendation' '
|
||||
test_when_finished "rm -rf super_clone" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git config -f .gitmodules submodule.sub.shallow true &&
|
||||
git add .gitmodules &&
|
||||
git commit -m "recommend shallow for sub" &&
|
||||
@ -87,6 +93,7 @@ test_expect_success 'clone follows shallow recommendation' '
|
||||
|
||||
test_expect_success 'get unshallow recommended shallow submodule' '
|
||||
test_when_finished "rm -rf super_clone" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git clone --no-local "file://$pwd/." super_clone &&
|
||||
(
|
||||
cd super_clone &&
|
||||
@ -103,6 +110,7 @@ test_expect_success 'get unshallow recommended shallow submodule' '
|
||||
|
||||
test_expect_success 'clone follows non shallow recommendation' '
|
||||
test_when_finished "rm -rf super_clone" &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git config -f .gitmodules submodule.sub.shallow false &&
|
||||
git add .gitmodules &&
|
||||
git commit -m "recommend non shallow for sub" &&
|
||||
|
@ -174,6 +174,8 @@ test_expect_success 'partial clone with transfer.fsckobjects=1 works with submod
|
||||
test_config -C src_with_sub uploadpack.allowfilter 1 &&
|
||||
test_config -C src_with_sub uploadpack.allowanysha1inwant 1 &&
|
||||
|
||||
test_config_global protocol.file.allow always &&
|
||||
|
||||
git -C src_with_sub submodule add "file://$(pwd)/submodule" mysub &&
|
||||
git -C src_with_sub commit -m "commit with submodule" &&
|
||||
|
||||
|
@ -10,6 +10,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
pwd=$(pwd)
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always &&
|
||||
git checkout -b main &&
|
||||
test_commit commit1 &&
|
||||
mkdir sub &&
|
||||
|
@ -26,7 +26,7 @@ test_expect_success 'setup' '
|
||||
|
||||
: > super-file &&
|
||||
git add super-file &&
|
||||
git submodule add "$(pwd)" sub &&
|
||||
git -c protocol.file.allow=always submodule add "$(pwd)" sub &&
|
||||
git symbolic-ref HEAD refs/heads/super &&
|
||||
test_tick &&
|
||||
git commit -m super-initial &&
|
||||
|
@ -9,7 +9,7 @@ test_expect_success 'setup a submodule' '
|
||||
: >pretzel/a &&
|
||||
git -C pretzel add a &&
|
||||
git -C pretzel commit -m "add a file" -- a &&
|
||||
git submodule add ./pretzel sub &&
|
||||
git -c protocol.file.allow=always submodule add ./pretzel sub &&
|
||||
git commit -a -m "add submodule" &&
|
||||
git submodule deinit --all
|
||||
'
|
||||
|
@ -304,6 +304,7 @@ test_expect_success SYMLINKS 'check moved symlink' '
|
||||
rm -f moved symlink
|
||||
|
||||
test_expect_success 'setup submodule' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
git commit -m initial &&
|
||||
git reset --hard &&
|
||||
git submodule add ./. sub &&
|
||||
@ -489,6 +490,7 @@ test_expect_success 'moving a submodule in nested directories' '
|
||||
'
|
||||
|
||||
test_expect_success 'moving nested submodules' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
git commit -am "cleanup commit" &&
|
||||
mkdir sub_nested_nested &&
|
||||
(
|
||||
|
@ -465,6 +465,7 @@ test_expect_success 'create and add submodule, submodule appears clean (A. S...)
|
||||
git checkout initial-branch &&
|
||||
git clone . sub_repo &&
|
||||
git clone . super_repo &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
( cd super_repo &&
|
||||
git submodule add ../sub_repo sub1 &&
|
||||
|
||||
|
@ -480,6 +480,7 @@ test_expect_success 'should not clean submodules' '
|
||||
git init &&
|
||||
test_commit msg hello.world
|
||||
) &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git submodule add ./repo/.git sub1 &&
|
||||
git commit -m "sub1" &&
|
||||
git branch before_sub2 &&
|
||||
|
@ -14,6 +14,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup - enable local submodules' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'submodule deinit works on empty repository' '
|
||||
git submodule deinit --all
|
||||
'
|
||||
|
@ -14,6 +14,8 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success setup '
|
||||
git config --global protocol.file.allow always &&
|
||||
|
||||
echo file >file &&
|
||||
git add file &&
|
||||
test_tick &&
|
||||
|
@ -25,6 +25,7 @@ compare_head()
|
||||
|
||||
|
||||
test_expect_success 'setup a submodule tree' '
|
||||
git config --global protocol.file.allow always &&
|
||||
echo file > file &&
|
||||
git add file &&
|
||||
test_tick &&
|
||||
|
@ -16,6 +16,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
|
||||
test_expect_success 'setup a submodule tree' '
|
||||
git config --global protocol.file.allow always &&
|
||||
echo file > file &&
|
||||
git add file &&
|
||||
test_tick &&
|
||||
|
@ -17,6 +17,10 @@ test_alternate_is_used () {
|
||||
test_cmp expect actual
|
||||
}
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'preparing first repository' '
|
||||
test_create_repo A &&
|
||||
(
|
||||
|
@ -15,6 +15,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'submodule on detached working tree' '
|
||||
git init --bare remote &&
|
||||
test_create_repo bundle1 &&
|
||||
|
@ -12,6 +12,9 @@ from the database and from the worktree works.
|
||||
TEST_NO_CREATE_REPO=1
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
test_expect_success 'submodule config cache setup' '
|
||||
mkdir submodule &&
|
||||
(cd submodule &&
|
||||
|
@ -9,6 +9,7 @@ submodules which are "active" and interesting to the user.
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always &&
|
||||
git init sub &&
|
||||
test_commit -C sub initial &&
|
||||
git init super &&
|
||||
|
@ -30,7 +30,8 @@ test_expect_success 'no warning when updating entry' '
|
||||
|
||||
test_expect_success 'submodule add does not warn' '
|
||||
test_when_finished "git rm -rf submodule .gitmodules" &&
|
||||
git submodule add ./embed submodule 2>stderr &&
|
||||
git -c protocol.file.allow=always \
|
||||
submodule add ./embed submodule 2>stderr &&
|
||||
test_i18ngrep ! warning stderr
|
||||
'
|
||||
|
||||
|
@ -8,6 +8,10 @@ real-world setup that confirms we catch this in practice.
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-pack.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'check names' '
|
||||
cat >expect <<-\EOF &&
|
||||
valid
|
||||
|
@ -3,6 +3,10 @@
|
||||
test_description='check handling of disallowed .gitmodule urls'
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'create submodule with protected dash in url' '
|
||||
git init upstream &&
|
||||
git -C upstream commit --allow-empty -m base &&
|
||||
|
@ -6,6 +6,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'create submodule with dash in path' '
|
||||
git init upstream &&
|
||||
git -C upstream commit --allow-empty -m base &&
|
||||
|
@ -14,6 +14,10 @@ also by committing .gitmodules and then just removing it from the filesystem.
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'sparse checkout setup which hides .gitmodules' '
|
||||
git init upstream &&
|
||||
git init submodule &&
|
||||
|
@ -12,6 +12,10 @@ as expected.
|
||||
TEST_NO_CREATE_REPO=1
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'submodule config cache setup' '
|
||||
mkdir submodule &&
|
||||
(cd submodule &&
|
||||
|
@ -12,6 +12,10 @@ as expected.
|
||||
TEST_NO_CREATE_REPO=1
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'submodule config cache setup' '
|
||||
mkdir submodule &&
|
||||
(
|
||||
|
@ -12,6 +12,10 @@ while making sure to add submodules using `git submodule add` instead of
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'summary test environment setup' '
|
||||
git init sm &&
|
||||
test_commit -C sm "add file" file file-content file-tag &&
|
||||
|
@ -251,6 +251,7 @@ test_expect_success 'status with merge conflict in .gitmodules' '
|
||||
test_create_repo_with_commit sub1 &&
|
||||
test_tick &&
|
||||
test_create_repo_with_commit sub2 &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
(
|
||||
cd super &&
|
||||
prev=$(git rev-parse HEAD) &&
|
||||
@ -326,6 +327,7 @@ test_expect_success 'diff --submodule with merge conflict in .gitmodules' '
|
||||
# sub2 will have an untracked file
|
||||
# sub3 will have an untracked repository
|
||||
test_expect_success 'setup superproject with untracked file in nested submodule' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
(
|
||||
cd super &&
|
||||
git clean -dfx &&
|
||||
|
@ -74,6 +74,7 @@ test_expect_success 'diff in message is retained with -v' '
|
||||
|
||||
test_expect_success 'submodule log is stripped out too with -v' '
|
||||
git config diff.submodule log &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git submodule add ./. sub &&
|
||||
git commit -m "sub added" &&
|
||||
(
|
||||
|
@ -629,6 +629,7 @@ test_expect_success 'difftool --no-symlinks detects conflict ' '
|
||||
|
||||
test_expect_success 'difftool properly honors gitlink and core.worktree' '
|
||||
test_when_finished rm -rf submod/ule &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git submodule add ./. submod/ule &&
|
||||
test_config -C submod/ule diff.tool checktrees &&
|
||||
test_config -C submod/ule difftool.checktrees.cmd '\''
|
||||
|
@ -193,6 +193,7 @@ test_expect_success !MINGW 'grep recurse submodule colon in name' '
|
||||
git -C "su:b" commit -m "add fi:le" &&
|
||||
test_tick &&
|
||||
|
||||
test_config_global protocol.file.allow always &&
|
||||
git -C parent submodule add "../su:b" "su:b" &&
|
||||
git -C parent commit -m "add submodule" &&
|
||||
test_tick &&
|
||||
@ -227,6 +228,7 @@ test_expect_success 'grep history with moved submoules' '
|
||||
git -C sub commit -m "add file" &&
|
||||
test_tick &&
|
||||
|
||||
test_config_global protocol.file.allow always &&
|
||||
git -C parent submodule add ../sub dir/sub &&
|
||||
git -C parent commit -m "add submodule" &&
|
||||
test_tick &&
|
||||
@ -271,6 +273,7 @@ test_expect_success 'grep using relative path' '
|
||||
mkdir parent/src &&
|
||||
echo "(1|2)d(3|4)" >parent/src/file2 &&
|
||||
git -C parent add src/file2 &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git -C parent submodule add ../sub &&
|
||||
git -C parent commit -m "add files and submodule" &&
|
||||
test_tick &&
|
||||
@ -313,6 +316,7 @@ test_expect_success 'grep from a subdir' '
|
||||
mkdir parent/src &&
|
||||
echo "(1|2)d(3|4)" >parent/src/file &&
|
||||
git -C parent add src/file &&
|
||||
test_config_global protocol.file.allow always &&
|
||||
git -C parent submodule add ../sub src/sub &&
|
||||
git -C parent submodule add ../sub sub &&
|
||||
git -C parent commit -m "add files and submodules" &&
|
||||
|
@ -25,6 +25,7 @@ test_expect_success 'import with large marks file' '
|
||||
'
|
||||
|
||||
test_expect_success 'setup dump with submodule' '
|
||||
test_config_global protocol.file.allow always &&
|
||||
git submodule add "$PWD" sub &&
|
||||
git commit -m "add submodule" &&
|
||||
git fast-export HEAD >dump
|
||||
|
@ -268,6 +268,7 @@ test_expect_success 'signed-tags=warn-strip' '
|
||||
|
||||
test_expect_success 'setup submodule' '
|
||||
|
||||
test_config_global protocol.file.allow always &&
|
||||
git checkout -f main &&
|
||||
mkdir sub &&
|
||||
(
|
||||
@ -293,6 +294,7 @@ test_expect_success 'setup submodule' '
|
||||
|
||||
test_expect_success 'submodule fast-export | fast-import' '
|
||||
|
||||
test_config_global protocol.file.allow always &&
|
||||
SUBENT1=$(git ls-tree main^ sub) &&
|
||||
SUBENT2=$(git ls-tree main sub) &&
|
||||
rm -rf new &&
|
||||
|
37
t/t9850-shell.sh
Executable file
37
t/t9850-shell.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='git shell tests'
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'shell allows upload-pack' '
|
||||
printf 0000 >input &&
|
||||
git upload-pack . <input >expect &&
|
||||
git shell -c "git-upload-pack $SQ.$SQ" <input >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'shell forbids other commands' '
|
||||
test_must_fail git shell -c "git config foo.bar baz"
|
||||
'
|
||||
|
||||
test_expect_success 'shell forbids interactive use by default' '
|
||||
test_must_fail git shell
|
||||
'
|
||||
|
||||
test_expect_success 'shell allows interactive command' '
|
||||
mkdir git-shell-commands &&
|
||||
write_script git-shell-commands/ping <<-\EOF &&
|
||||
echo pong
|
||||
EOF
|
||||
echo pong >expect &&
|
||||
echo ping | git shell >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'shell complains of overlong commands' '
|
||||
perl -e "print \"a\" x 2**12 for (0..2**19)" |
|
||||
test_must_fail git shell 2>err &&
|
||||
grep "too long" err
|
||||
'
|
||||
|
||||
test_done
|
@ -964,8 +964,7 @@ static enum protocol_allow_config get_protocol_config(const char *type)
|
||||
if (!strcmp(type, "http") ||
|
||||
!strcmp(type, "https") ||
|
||||
!strcmp(type, "git") ||
|
||||
!strcmp(type, "ssh") ||
|
||||
!strcmp(type, "file"))
|
||||
!strcmp(type, "ssh"))
|
||||
return PROTOCOL_ALLOW_ALWAYS;
|
||||
|
||||
/* known scary; err on the side of caution */
|
||||
|
Reference in New Issue
Block a user