diff --git a/builtin-init-db.c b/builtin-init-db.c index 1d7d15e8d5..01f366ad0b 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -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] != '/') { diff --git a/builtin-repo-config.c b/builtin-repo-config.c index a38099a63d..4885930ca4 100644 --- a/builtin-repo-config.c +++ b/builtin-repo-config.c @@ -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) diff --git a/cache.h b/cache.h index 8ad5920d2b..4943056c19 100644 --- a/cache.h +++ b/cache.h @@ -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); diff --git a/config.c b/config.c index 663993fefa..6a4224e98c 100644 --- a/config.c +++ b/config.c @@ -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"); } diff --git a/exec_cmd.c b/exec_cmd.c index 5d6a1247b4..3996bce33f 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -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) { diff --git a/git-parse-remote.sh b/git-parse-remote.sh index 11c4aba244..ea7511e8a0 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -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) diff --git a/git-pull.sh b/git-pull.sh index e23beb685d..1703091bbb 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -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 ;; diff --git a/merge-recursive.c b/merge-recursive.c index 6dd6e2e5af..ae4dcfbe5b 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -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")); diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh index a79c77af39..74f5c2a575 100755 --- a/t/t4116-apply-reverse.sh +++ b/t/t4116-apply-reverse.sh @@ -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 . ) ' diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index 8a8152b257..de45ac4e0f 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -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 > log2.txt + git-init-db 2>> log2.txt ) add A1 diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index e2e8c894f9..90eeeba2a3 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -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 && diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 66ef92f41f..f841574573 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -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 .. ' diff --git a/t/t5600-clone-fail-cleanup.sh b/t/t5600-clone-fail-cleanup.sh index 1913a12d71..041be04f5c 100755 --- a/t/t5600-clone-fail-cleanup.sh +++ b/t/t5600-clone-fail-cleanup.sh @@ -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' \ diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh index 52dab2d484..dd9caad1c2 100755 --- a/t/t5700-clone-reference.sh +++ b/t/t5700-clone-reference.sh @@ -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" diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh index 3c43554c69..b9f6d96363 100755 --- a/t/t5710-info-alternate.sh +++ b/t/t5710-info-alternate.sh @@ -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' diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index ae597e80dd..2f4ff82e14 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -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 && diff --git a/t/test-lib.sh b/t/test-lib.sh index 7e9149751e..f0f9cd6be0 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -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 diff --git a/templates/remotes-- b/templates/remotes-- deleted file mode 100644 index fae88709a6..0000000000 --- a/templates/remotes-- +++ /dev/null @@ -1 +0,0 @@ -: this is just to ensure the directory exists.