From: Junio C Hamano Date: Thu, 23 Dec 2010 23:46:52 +0000 (-0800) Subject: Merge branch 'nd/setup' into next X-Git-Tag: ko-next~39 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a2bc4196629a6283bfed75aa60ad6aece230cd61;p=git.git Merge branch 'nd/setup' into next * nd/setup: (46 commits) git.txt: correct where --work-tree path is relative to Revert "Documentation: always respect core.worktree if set" t0001: test git init when run via an alias Remove all logic from get_git_work_tree() setup: rework setup_explicit_git_dir() setup: clean up setup_discovered_git_dir() t1020-subdirectory: test alias expansion in a subdirectory setup: clean up setup_bare_git_dir() setup: limit get_git_work_tree()'s to explicit setup case only Use git_config_early() instead of git_config() during repo setup Add git_config_early() git-rev-parse.txt: clarify --git-dir t1510: setup case #31 t1510: setup case #30 t1510: setup case #29 t1510: setup case #28 t1510: setup case #27 t1510: setup case #26 t1510: setup case #25 t1510: setup case #24 ... --- a2bc4196629a6283bfed75aa60ad6aece230cd61 diff --cc config.c index d73b090b6,c431f41c5..625e05187 --- a/config.c +++ b/config.c @@@ -888,9 -868,23 +885,21 @@@ int git_config_early(config_fn_t fn, vo if (config_parameters) found += 1; - if (found == 0) - return -1; - return ret; + return ret == 0 ? found : ret; } + int git_config(config_fn_t fn, void *data) + { + char *repo_config = NULL; + int ret; + + repo_config = git_pathdup("config"); + ret = git_config_early(fn, data, repo_config); + if (repo_config) + free(repo_config); + return ret; + } + /* * Find all the stuff for git_config_set() below. */ diff --cc t/t0001-init.sh index d44194c35,28c1858c2..af8b9c52a --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@@ -33,9 -33,65 +33,65 @@@ test_expect_success 'plain' check_config plain/.git false unset ' + test_expect_success 'plain nested in bare' ' + ( + unset GIT_DIR GIT_WORK_TREE && + git init --bare bare-ancestor.git && + cd bare-ancestor.git && + mkdir plain-nested && + cd plain-nested && + git init + ) && + check_config bare-ancestor.git/plain-nested/.git false unset + ' + + test_expect_success 'plain through aliased command, outside any git repo' ' + ( + unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL && + HOME=$(pwd)/alias-config && + export HOME && + mkdir alias-config && + echo "[alias] aliasedinit = init" >alias-config/.gitconfig && + + GIT_CEILING_DIRECTORIES=$(pwd) && + export GIT_CEILING_DIRECTORIES && + + mkdir plain-aliased && + cd plain-aliased && + git aliasedinit + ) && + check_config plain-aliased/.git false unset + ' + + test_expect_failure 'plain nested through aliased command' ' + ( + unset GIT_DIR GIT_WORK_TREE && + git init plain-ancestor-aliased && + cd plain-ancestor-aliased && + echo "[alias] aliasedinit = init" >>.git/config && + mkdir plain-nested && + cd plain-nested && + git aliasedinit + ) && + check_config plain-ancestor-aliased/plain-nested/.git false unset + ' + + test_expect_failure 'plain nested in bare through aliased command' ' + ( + unset GIT_DIR GIT_WORK_TREE && + git init --bare bare-ancestor-aliased.git && + cd bare-ancestor-aliased.git && + echo "[alias] aliasedinit = init" >>config && + mkdir plain-nested && + cd plain-nested && + git aliasedinit + ) && + check_config bare-ancestor-aliased.git/plain-nested/.git false unset + ' + test_expect_success 'plain with GIT_WORK_TREE' ' if ( - unset GIT_DIR + sane_unset GIT_DIR && mkdir plain-wt && cd plain-wt && GIT_WORK_TREE=$(pwd) git init