t1020-subdirectory: test alias expansion in a subdirectory
PATCH 1/1 t1020-subdirectory: test alias expansion in a subdirectory
Add a test for alias expansion in a subdirectory of the worktree.
---
65f3a9e (Remove all logic from get_git_work_tree(), 2010-11-01) breaks this test, which is why I am adding it.
In fact, we don't really have tests for alias expansion at all, but that's a different issue.
t/t1020-subdirectory.sh | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
t/t1020-subdirectory.sh +8 -0
@@ -110,6 +110,14 @@ test_expect_success 'read-tree' ' ) ' +test_expect_success 'alias expansion' ' + ( + git config alias.ss status && + cd dir && + git status && + git ss + ) +' test_expect_success 'no file/rev ambiguity check inside .git' ' git commit -a -m 1 && (
Signature · 1 line
1.7.3.2.193.g78bbb
PATCH 1/1 t0001: test git init when run via an alias
From: Jonathan Nieder <[email protected]>
Add some tests to document the correct behavior of (possibly aliased) init when run within and outside a git directory.
If I set up a simple git alias “quietinit = init --quiet”, usually it will work just like ‘git init --quiet’.
There are some differences, unfortunately, since in the process of checking for aliases, git has to look for a .git/config file. If ‘git quietinit’ is run from a subdirectory of an existing git repository, that repository’s configuration will affect the configuration of the new repository. In particular, the new repository can inherit bogus values for core.bare and core.worktree.
---
Quoted 1 line
In fact, we don't really have tests for alias expansion at all, but that's a different issue.
It reminds me of this old patch. Let's push them together.
t/t0001-init.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-)
t/t0001-init.sh +56 -0
@@ -33,6 +33,62 @@ 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_success '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
Signature · 1 line
1.7.3.2.210.g045198
Quoted 7 lines · Michael J Gruber
Add a test for alias expansion in a subdirectory of the worktree.
Signed-off-by Michael J Gruber <[email protected]>---
65f3a9e (Remove all logic fromget_git_work_tree(), 2010-11-01) breaks this test, which is why I am adding it.
How about squashing this in?
--8<--
Subject: Allow set_git_work_tree() to be called more than once
Usually one of the setup functions is called once. However alias handling code needs to look ahead in $GIT_DIR/config for aliases. So set_git_work_tree() may be called twice: once when alias is searched, once when the actual command is run.
Loosen the condition and let it through. We can stricten it back when alias handling is fixed.
---
environment.c +1 -5
@@ -128,8 +128,6 @@ const char *get_git_dir(void)return git_dir; } -static int git_work_tree_initialized; -/* * Note. This works only before you used a work tree. This was added * primarily to support git-clone to work in a new repository it just
@@ -137,9 +135,7 @@ static int git_work_tree_initialized;*/ void set_git_work_tree (const char *new_work_tree) { -if (git_work_tree_initialized) -die ("internal error: work tree has already been set" ); - git_work_tree_initialized =1 ; +free (work_tree); work_tree =xstrdup (make_absolute_path (new_work_tree)); }
--8<--
Signature · 1 line
Duy
Quoted 14 lines · Nguyen Thai Ngoc Duy
Quoted 7 lines · Michael J Gruber
Add a test for alias expansion in a subdirectory of the worktree.
Signed-off-by Michael J Gruber <[email protected]>---
65f3a9e (Remove all logic fromget_git_work_tree(), 2010-11-01) breaks this test, which is why I am adding it.How about squashing this in?
--8<--
Subject: Allowset_git_work_tree()to be called more than once
Quoted 7 lines
Usually one of the setup functions is called once. However alias handling code needs to look ahead in $GIT_DIR/config for aliases. So
set_git_work_tree()may be called twice: once when alias is searched, once when the actual command is run.Loosen the condition and let it through. We can stricten it back when alias handling is fixed.
Sounds like sweeping something under rug.
Without this hack, alias does not work, but if your plan is to rework this part right when alias is fixed, then what's the point of loosening it? Either way your alias is broken, no?
Shouldn't it at least make sure that the function is giving a consistent picture to the outside world between the time it was called for the first time and the second time? E.g. the second time around new-work-tree must be the same as whatever was given the first time, or something.
Quoted 28 lines
---
environment.c +1
-6@@ -128,8 +128,6 @@ const char *get_git_dir(void)return git_dir; } -static int git_work_tree_initialized; -/* * Note. This works only before you used a work tree. This was added * primarily to support git-clone to work in a new repository it just @@ -137,9 +135,7 @@ static int git_work_tree_initialized;*/ void set_git_work_tree (const char *new_work_tree) { -if (git_work_tree_initialized) -die ("internal error: work tree has already been set" ); - git_work_tree_initialized =1 ; +free (work_tree); work_tree =xstrdup (make_absolute_path (new_work_tree)); } --8<--Signature · 1 line
Duy
Quoted 26 lines · Junio C Hamano
Quoted 14 lines · Nguyen Thai Ngoc Duy
Quoted 7 lines · Michael J Gruber
Add a test for alias expansion in a subdirectory of the worktree.
Signed-off-by Michael J Gruber <[email protected]>---
65f3a9e (Remove all logic fromget_git_work_tree(), 2010-11-01) breaks this test, which is why I am adding it.How about squashing this in?
--8<--
Subject: Allowset_git_work_tree()to be called more than onceQuoted 7 lines
Usually one of the setup functions is called once. However alias handling code needs to look ahead in $GIT_DIR/config for aliases. So
set_git_work_tree()may be called twice: once when alias is searched, once when the actual command is run.Loosen the condition and let it through. We can stricten it back when alias handling is fixed.
Sounds like sweeping something under rug.
Quoted 8 lines
Without this hack, alias does not work, but if your plan is to rework this part right when alias is fixed, then what's the point of loosening it? Either way your alias is broken, no?
Shouldn't it at least make sure that the function is giving a consistent picture to the outside world between the time it was called for the first time and the second time? E.g. the second time around new-work-tree must be the same as whatever was given the first time, or something.
Right. Will do that.
Signature · 1 line
Duy