@matheusbsbs / matheus-bagliano / commits / 4ad8332ef7
Fork 0

t0001: test git init when run via an alias

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. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Nov 26, 2010 at 22:32 UTC 4ad8332ef79c53fd7c214fcbe24a29ff243a531e
1 file changed +56
t/t0001-init.sh
+56
@@ -33,6 +33,62 @@ test_expect_success 'plain' '
33 check_config plain/.git false unset
34 '
35
36 +test_expect_success 'plain nested in bare' '
37 + (
38 + unset GIT_DIR GIT_WORK_TREE &&
39 + git init --bare bare-ancestor.git &&
40 + cd bare-ancestor.git &&
41 + mkdir plain-nested &&
42 + cd plain-nested &&
43 + git init
44 + ) &&
45 + check_config bare-ancestor.git/plain-nested/.git false unset
46 +'
47 +
48 +test_expect_success 'plain through aliased command, outside any git repo' '
49 + (
50 + unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
51 + HOME=$(pwd)/alias-config &&
52 + export HOME &&
53 + mkdir alias-config &&
54 + echo "[alias] aliasedinit = init" >alias-config/.gitconfig &&
55 +
56 + GIT_CEILING_DIRECTORIES=$(pwd) &&
57 + export GIT_CEILING_DIRECTORIES &&
58 +
59 + mkdir plain-aliased &&
60 + cd plain-aliased &&
61 + git aliasedinit
62 + ) &&
63 + check_config plain-aliased/.git false unset
64 +'
65 +
66 +test_expect_failure 'plain nested through aliased command' '
67 + (
68 + unset GIT_DIR GIT_WORK_TREE &&
69 + git init plain-ancestor-aliased &&
70 + cd plain-ancestor-aliased &&
71 + echo "[alias] aliasedinit = init" >>.git/config &&
72 + mkdir plain-nested &&
73 + cd plain-nested &&
74 + git aliasedinit
75 + ) &&
76 + check_config plain-ancestor-aliased/plain-nested/.git false unset
77 +'
78 +
79 +test_expect_failure 'plain nested in bare through aliased command' '
80 + (
81 + unset GIT_DIR GIT_WORK_TREE &&
82 + git init --bare bare-ancestor-aliased.git &&
83 + cd bare-ancestor-aliased.git &&
84 + echo "[alias] aliasedinit = init" >>config &&
85 + mkdir plain-nested &&
86 + cd plain-nested &&
87 + git aliasedinit
88 + ) &&
89 + check_config bare-ancestor-aliased.git/plain-nested/.git false unset
90 +'
91 +
92 test_expect_success 'plain with GIT_WORK_TREE' '
93 if (
94 unset GIT_DIR