Merge branch 'jc/clone' into next

* jc/clone:
  Move "no merge candidate" warning into git-pull
  Use preprocessor constants for environment variable names.
  Do not create $GIT_DIR/remotes/ directory anymore.
  Introduce GIT_TEMPLATE_DIR
  Revert "fix testsuite: make sure they use templates freshly built from the source"
This commit is contained in:
Junio C Hamano
2006-12-19 01:57:02 -08:00
20 changed files with 55 additions and 65 deletions

View File

@@ -124,8 +124,11 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
int template_len;
DIR *dir;
if (!template_dir)
template_dir = DEFAULT_GIT_TEMPLATE_DIR;
if (!template_dir) {
template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
if (!template_dir)
template_dir = DEFAULT_GIT_TEMPLATE_DIR;
}
strcpy(template_path, template_dir);
template_len = strlen(template_path);
if (template_path[template_len-1] != '/') {

View File

@@ -67,10 +67,10 @@ static int get_value(const char* key_, const char* regex_)
char *global = NULL, *repo_config = NULL;
const char *local;
local = getenv("GIT_CONFIG");
local = getenv(CONFIG_ENVIRONMENT);
if (!local) {
const char *home = getenv("HOME");
local = getenv("GIT_CONFIG_LOCAL");
local = getenv(CONFIG_LOCAL_ENVIRONMENT);
if (!local)
local = repo_config = xstrdup(git_path("config"));
if (home)

View File

@@ -122,6 +122,10 @@ extern int cache_errno;
#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
#define CONFIG_ENVIRONMENT "GIT_CONFIG"
#define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
extern int is_bare_git_dir(const char *dir);
extern const char *get_git_dir(void);

View File

@@ -350,10 +350,10 @@ int git_config(config_fn_t fn)
* $GIT_CONFIG_LOCAL will make it process it in addition to the
* global config file, the same way it would the per-repository
* config file otherwise. */
filename = getenv("GIT_CONFIG");
filename = getenv(CONFIG_ENVIRONMENT);
if (!filename) {
home = getenv("HOME");
filename = getenv("GIT_CONFIG_LOCAL");
filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
if (!filename)
filename = repo_config = xstrdup(git_path("config"));
}
@@ -544,9 +544,9 @@ int git_config_set_multivar(const char* key, const char* value,
char* lock_file;
const char* last_dot = strrchr(key, '.');
config_filename = getenv("GIT_CONFIG");
config_filename = getenv(CONFIG_ENVIRONMENT);
if (!config_filename) {
config_filename = getenv("GIT_CONFIG_LOCAL");
config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
if (!config_filename)
config_filename = git_path("config");
}
@@ -754,9 +754,9 @@ int git_config_rename_section(const char *old_name, const char *new_name)
int out_fd;
char buf[1024];
config_filename = getenv("GIT_CONFIG");
config_filename = getenv(CONFIG_ENVIRONMENT);
if (!config_filename) {
config_filename = getenv("GIT_CONFIG_LOCAL");
config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
if (!config_filename)
config_filename = git_path("config");
}

View File

@@ -21,7 +21,7 @@ const char *git_exec_path(void)
if (current_exec_path)
return current_exec_path;
env = getenv("GIT_EXEC_PATH");
env = getenv(EXEC_PATH_ENVIRONMENT);
if (env && *env) {
return env;
}
@@ -35,7 +35,7 @@ int execv_git_cmd(const char **argv)
char git_command[PATH_MAX + 1];
int i;
const char *paths[] = { current_exec_path,
getenv("GIT_EXEC_PATH"),
getenv(EXEC_PATH_ENVIRONMENT),
builtin_exec_path };
for (i = 0; i < ARRAY_SIZE(paths); ++i) {

View File

@@ -132,7 +132,6 @@ canon_refs_list_for_fetch () {
# or the first one otherwise; add prefix . to the rest
# to prevent the secondary branches to be merged by default.
merge_branches=
found_mergeref=
curr_branch=
if test "$1" = "-d"
then
@@ -172,10 +171,6 @@ canon_refs_list_for_fetch () {
dot_prefix= && break
done
fi
if test -z $dot_prefix
then
found_mergeref=true
fi
case "$remote" in
'') remote=HEAD ;;
refs/heads/* | refs/tags/* | refs/remotes/*) ;;
@@ -196,11 +191,6 @@ canon_refs_list_for_fetch () {
fi
echo "${dot_prefix}${force}${remote}:${local}"
done
if test -z "$found_mergeref" -a "$curr_branch"
then
echo >&2 "Warning: No merge candidate found because value of config option
\"branch.${curr_branch}.merge\" does not match any remote branch fetched."
fi
}
# Returns list of src: (no store), or src:dst (store)

View File

@@ -76,6 +76,10 @@ merge_head=$(sed -e '/ not-for-merge /d' \
case "$merge_head" in
'')
curr_branch=$(git-symbolic-ref HEAD | \
sed -e 's|^refs/heads/||')
echo >&2 "Warning: No merge candidate found because value of config option
\"branch.${curr_branch}.merge\" does not match any remote branch fetched."
echo >&2 "No changes."
exit 0
;;

View File

@@ -1279,7 +1279,7 @@ int main(int argc, char *argv[])
struct commit *result, *h1, *h2;
git_config(git_default_config); /* core.filemode */
original_index_file = getenv("GIT_INDEX_FILE");
original_index_file = getenv(INDEX_ENVIRONMENT);
if (!original_index_file)
original_index_file = xstrdup(git_path("index"));

View File

@@ -50,12 +50,12 @@ test_expect_success 'setup separate repository lacking postimage' '
git tar-tree initial initial | tar xf - &&
(
cd initial && git_init_db && git add .
cd initial && git init-db && git add .
) &&
git tar-tree second second | tar xf - &&
(
cd second && git_init_db && git add .
cd second && git init-db && git add .
)
'

View File

@@ -44,7 +44,7 @@ test_expect_success \
'unpack without delta' \
"GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
git_init_db &&
git-init-db &&
git-unpack-objects -n <test-1-${packname_1}.pack &&
git-unpack-objects <test-1-${packname_1}.pack"
@@ -75,7 +75,7 @@ test_expect_success \
'unpack with delta' \
'GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
git_init_db &&
git-init-db &&
git-unpack-objects -n <test-2-${packname_2}.pack &&
git-unpack-objects <test-2-${packname_2}.pack'
@@ -100,7 +100,7 @@ test_expect_success \
'use packed objects' \
'GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
git_init_db &&
git-init-db &&
cp test-1-${packname_1}.pack test-1-${packname_1}.idx .git2/objects/pack && {
git-diff-tree --root -p $commit &&
while read object

View File

@@ -24,7 +24,7 @@ test_expect_success setup '
parent=$commit || return 1
done &&
git-update-ref HEAD "$commit" &&
git_clone -l ./. victim &&
git-clone -l ./. victim &&
cd victim &&
git-log &&
cd .. &&

View File

@@ -97,7 +97,7 @@ pull_to_client () {
(
mkdir client &&
cd client &&
git_init_db 2>> log2.txt
git-init-db 2>> log2.txt
)
add A1

View File

@@ -15,23 +15,22 @@ test_expect_success setup '
git commit -a -m original'
test_expect_success "clone and setup child repos" '
git_clone . one &&
git clone . one &&
cd one &&
echo >file updated by one &&
git commit -a -m "updated by one" &&
cd .. &&
git_clone . two &&
git clone . two &&
cd two &&
git repo-config branch.master.remote one &&
{
echo "URL: ../one/.git/"
echo "Pull: refs/heads/master:refs/heads/one"
} >.git/remotes/one
git repo-config remote.one.url ../one/.git/ &&
git repo-config remote.one.fetch refs/heads/master:refs/heads/one &&
cd .. &&
git_clone . three &&
git clone . three &&
cd three &&
git repo-config branch.master.remote two &&
git repo-config branch.master.merge refs/heads/one &&
mkdir -p .git/remotes &&
{
echo "URL: ../two/.git/"
echo "Pull: refs/heads/master:refs/heads/two"
@@ -74,7 +73,7 @@ test_expect_success 'fetch following tags' '
mkdir four &&
cd four &&
git_init_db &&
git init-db &&
git fetch .. :track &&
git show-ref --verify refs/tags/anno &&

View File

@@ -17,7 +17,7 @@ test_expect_success setup '
test_expect_success 'pulling into void' '
mkdir cloned &&
cd cloned &&
git_init_db &&
git init-db &&
git pull ..
'

View File

@@ -13,7 +13,7 @@ remove the directory before attempting a clone again.'
test_expect_failure \
'clone of non-existent source should fail' \
'git_clone foo bar'
'git-clone foo bar'
test_expect_failure \
'failed clone should not leave a directory' \
@@ -29,11 +29,11 @@ test_create_repo foo
# current path not to the target dir
test_expect_failure \
'clone of non-existent (relative to $PWD) source should fail' \
'git_clone ../foo baz'
'git-clone ../foo baz'
test_expect_success \
'clone should work now that source exists' \
'git_clone foo bar'
'git-clone foo bar'
test_expect_success \
'successfull clone must leave the directory' \

View File

@@ -17,7 +17,7 @@ git commit -m initial'
cd "$base_dir"
test_expect_success 'preparing second repository' \
'git_clone A B && cd B &&
'git clone A B && cd B &&
echo second > file2 &&
git add file2 &&
git commit -m addition &&
@@ -27,7 +27,7 @@ git prune'
cd "$base_dir"
test_expect_success 'cloning with reference' \
'git_clone -l -s --reference B A C'
'git clone -l -s --reference B A C'
cd "$base_dir"

View File

@@ -34,7 +34,7 @@ git prune'
cd "$base_dir"
test_expect_success 'preparing second repository' \
'git_clone -l -s A B && cd B &&
'git clone -l -s A B && cd B &&
echo "foo bar" > file2 &&
git add file2 &&
git commit -m "next commit" file2 &&
@@ -44,7 +44,7 @@ git prune'
cd "$base_dir"
test_expect_success 'preparing third repository' \
'git_clone -l -s B C && cd C &&
'git clone -l -s B C && cd C &&
echo "Goodbye, cruel world" > file3 &&
git add file3 &&
git commit -m "one more" file3 &&
@@ -54,11 +54,11 @@ git prune'
cd "$base_dir"
test_expect_failure 'creating too deep nesting' \
'git_clone -l -s C D &&
git_clone -l -s D E &&
git_clone -l -s E F &&
git_clone -l -s F G &&
git_clone -l -s G H &&
'git clone -l -s C D &&
git clone -l -s D E &&
git clone -l -s E F &&
git clone -l -s F G &&
git clone -l -s G H &&
cd H &&
test_valid_repo'

View File

@@ -88,7 +88,7 @@ test_expect_success \
test_expect_success "Michael Cassar's test case" '
rm -fr .git papers partA &&
git_init_db &&
git init-db &&
mkdir -p papers/unsorted papers/all-papers partA &&
echo a > papers/unsorted/Thesis.pdf &&
echo b > partA/outline.txt &&
@@ -109,7 +109,7 @@ rm -fr papers partA path?
test_expect_success "Sergey Vlasov's test case" '
rm -fr .git &&
git_init_db &&
git init-db &&
mkdir ab &&
date >ab.c &&
date >ab/d &&

View File

@@ -182,16 +182,6 @@ test_create_repo () {
cd "$owd"
}
# Many tests do init-db and clone but they must be told about the freshly
# built templates.
git_init_db () {
git init-db --template="$GIT_EXEC_PATH/templates/blt/" "$@"
}
git_clone () {
git clone --template="$GIT_EXEC_PATH/templates/blt/" "$@"
}
test_done () {
trap - exit
case "$test_failure" in
@@ -218,8 +208,9 @@ test_done () {
# t/ subdirectory and are run in trash subdirectory.
PATH=$(pwd)/..:$PATH
GIT_EXEC_PATH=$(pwd)/..
GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
HOME=$(pwd)/trash
export PATH GIT_EXEC_PATH HOME
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR HOME
GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
export GITPERLLIB

View File

@@ -1 +0,0 @@
: this is just to ensure the directory exists.