blob: bbd513bab0fb03d5d84b72a76fdbe6cf8a3285eb [file] [log] [blame]
SZEDER Gábor963c0402012-05-09 02:44:33 +02001#!/bin/sh
2#
3# Copyright (c) 2012 SZEDER Gábor
4#
5
6test_description='test git-specific bash prompt functions'
7
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +00008GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
Johannes Schindelin334afbc2020-11-18 23:44:19 +00009export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
SZEDER Gábor963c0402012-05-09 02:44:33 +020011. ./lib-bash.sh
12
Felipe Contrerasaf31a452012-05-22 22:46:40 +020013. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
SZEDER Gábor963c0402012-05-09 02:44:33 +020014
15actual="$TRASH_DIRECTORY/actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -030016c_red='\\[\\e[31m\\]'
17c_green='\\[\\e[32m\\]'
18c_lblue='\\[\\e[1;34m\\]'
19c_clear='\\[\\e[0m\\]'
SZEDER Gábor963c0402012-05-09 02:44:33 +020020
21test_expect_success 'setup for prompt tests' '
SZEDER Gábor963c0402012-05-09 02:44:33 +020022 git init otherrepo &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020023 echo 1 >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +020024 git add file &&
25 test_tick &&
26 git commit -m initial &&
27 git tag -a -m msg1 t1 &&
28 git checkout -b b1 &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020029 echo 2 >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +020030 git commit -m "second b1" file &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020031 echo 3 >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +020032 git commit -m "third b1" file &&
33 git tag -a -m msg2 t2 &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +000034 git checkout -b b2 main &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020035 echo 0 >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +020036 git commit -m "second b2" file &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020037 echo 00 >file &&
Zoltan Klingerb71dc3e2013-04-25 19:28:54 +100038 git commit -m "another b2" file &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020039 echo 000 >file &&
Zoltan Klingerb71dc3e2013-04-25 19:28:54 +100040 git commit -m "yet another b2" file &&
Jess Austin0120b8c2015-01-06 20:22:27 -050041 mkdir ignored_dir &&
42 echo "ignored_dir/" >>.gitignore &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +000043 git checkout main
SZEDER Gábor963c0402012-05-09 02:44:33 +020044'
45
SZEDER Gábor963c0402012-05-09 02:44:33 +020046test_expect_success 'prompt - branch name' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +000047 printf " (main)" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020048 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +020049 test_cmp expected "$actual"
50'
51
SZEDER Gábor868dc1a2012-08-24 19:52:48 +020052test_expect_success SYMLINKS 'prompt - branch name - symlink symref' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +000053 printf " (main)" >expected &&
54 test_when_finished "git checkout main" &&
SZEDER Gábor868dc1a2012-08-24 19:52:48 +020055 test_config core.preferSymlinkRefs true &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +000056 git checkout main &&
SZEDER Gábor868dc1a2012-08-24 19:52:48 +020057 __git_ps1 >"$actual" &&
58 test_cmp expected "$actual"
59'
60
SZEDER Gábore3e0b932013-06-24 02:16:02 +020061test_expect_success 'prompt - unborn branch' '
62 printf " (unborn)" >expected &&
63 git checkout --orphan unborn &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +000064 test_when_finished "git checkout main" &&
SZEDER Gábore3e0b932013-06-24 02:16:02 +020065 __git_ps1 >"$actual" &&
66 test_cmp expected "$actual"
67'
68
William Chargin6ec63302018-08-06 11:35:08 -070069if test_have_prereq !FUNNYNAMES; then
SZEDER Gábora4889e62013-08-17 11:01:58 +020070 say 'Your filesystem does not allow newlines in filenames.'
71fi
72
73test_expect_success FUNNYNAMES 'prompt - with newline in path' '
William Chargin6ec63302018-08-06 11:35:08 -070074 repo_with_newline="repo
75with
76newline" &&
77 mkdir "$repo_with_newline" &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +000078 printf " (main)" >expected &&
SZEDER Gábora4889e62013-08-17 11:01:58 +020079 git init "$repo_with_newline" &&
80 test_when_finished "rm -rf \"$repo_with_newline\"" &&
81 mkdir "$repo_with_newline"/subdir &&
82 (
83 cd "$repo_with_newline/subdir" &&
84 __git_ps1 >"$actual"
85 ) &&
86 test_cmp expected "$actual"
87'
88
SZEDER Gábor963c0402012-05-09 02:44:33 +020089test_expect_success 'prompt - detached head' '
SZEDER Gábore8f21ca2013-06-24 01:55:42 +020090 printf " ((%s...))" $(git log -1 --format="%h" --abbrev=13 b1^) >expected &&
91 test_config core.abbrev 13 &&
SZEDER Gábor963c0402012-05-09 02:44:33 +020092 git checkout b1^ &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +000093 test_when_finished "git checkout main" &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020094 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +020095 test_cmp expected "$actual"
96'
97
98test_expect_success 'prompt - describe detached head - contains' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +020099 printf " ((t2~1))" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200100 git checkout b1^ &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000101 test_when_finished "git checkout main" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200102 (
103 GIT_PS1_DESCRIBE_STYLE=contains &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200104 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200105 ) &&
106 test_cmp expected "$actual"
107'
108
109test_expect_success 'prompt - describe detached head - branch' '
Johannes Schindelin75504242016-04-22 15:39:01 +0200110 printf " ((tags/t2~1))" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200111 git checkout b1^ &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000112 test_when_finished "git checkout main" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200113 (
114 GIT_PS1_DESCRIBE_STYLE=branch &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200115 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200116 ) &&
117 test_cmp expected "$actual"
118'
119
120test_expect_success 'prompt - describe detached head - describe' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200121 printf " ((t1-1-g%s))" $(git log -1 --format="%h" b1^) >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200122 git checkout b1^ &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000123 test_when_finished "git checkout main" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200124 (
125 GIT_PS1_DESCRIBE_STYLE=describe &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200126 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200127 ) &&
128 test_cmp expected "$actual"
129'
130
131test_expect_success 'prompt - describe detached head - default' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200132 printf " ((t2))" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200133 git checkout --detach b1 &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000134 test_when_finished "git checkout main" &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200135 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200136 test_cmp expected "$actual"
137'
138
139test_expect_success 'prompt - inside .git directory' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200140 printf " (GIT_DIR!)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200141 (
142 cd .git &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200143 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200144 ) &&
145 test_cmp expected "$actual"
146'
147
148test_expect_success 'prompt - deep inside .git directory' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200149 printf " (GIT_DIR!)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200150 (
Christian Couder5340d472018-05-26 08:47:45 +0200151 cd .git/objects &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200152 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200153 ) &&
154 test_cmp expected "$actual"
155'
156
157test_expect_success 'prompt - inside bare repository' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000158 printf " (BARE:main)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200159 git init --bare bare.git &&
160 test_when_finished "rm -rf bare.git" &&
161 (
162 cd bare.git &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200163 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200164 ) &&
165 test_cmp expected "$actual"
166'
167
168test_expect_success 'prompt - interactive rebase' '
Elijah Newren6d04ce72020-02-15 21:36:35 +0000169 printf " (b1|REBASE 2/3)" >expected &&
SZEDER Gábor74122902012-08-24 20:03:58 +0200170 write_script fake_editor.sh <<-\EOF &&
171 echo "exec echo" >"$1"
172 echo "edit $(git log -1 --format="%h")" >>"$1"
173 echo "exec echo" >>"$1"
174 EOF
SZEDER Gábor963c0402012-05-09 02:44:33 +0200175 test_when_finished "rm -f fake_editor.sh" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200176 test_set_editor "$TRASH_DIRECTORY/fake_editor.sh" &&
177 git checkout b1 &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000178 test_when_finished "git checkout main" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200179 git rebase -i HEAD^ &&
Johannes Sixtc00bfc92016-09-05 21:00:47 +0200180 test_when_finished "git rebase --abort" &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200181 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200182 test_cmp expected "$actual"
183'
184
185test_expect_success 'prompt - rebase merge' '
Elijah Newren6d04ce72020-02-15 21:36:35 +0000186 printf " (b2|REBASE 1/3)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200187 git checkout b2 &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000188 test_when_finished "git checkout main" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200189 test_must_fail git rebase --merge b1 b2 &&
190 test_when_finished "git rebase --abort" &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200191 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200192 test_cmp expected "$actual"
193'
194
Elijah Newren6d04ce72020-02-15 21:36:35 +0000195test_expect_success 'prompt - rebase am' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200196 printf " (b2|REBASE 1/3)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200197 git checkout b2 &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000198 test_when_finished "git checkout main" &&
Elijah Newren10cdb9f2020-02-15 21:36:41 +0000199 test_must_fail git rebase --apply b1 b2 &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200200 test_when_finished "git rebase --abort" &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200201 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200202 test_cmp expected "$actual"
203'
204
205test_expect_success 'prompt - merge' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200206 printf " (b1|MERGING)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200207 git checkout b1 &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000208 test_when_finished "git checkout main" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200209 test_must_fail git merge b2 &&
210 test_when_finished "git reset --hard" &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200211 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200212 test_cmp expected "$actual"
213'
214
215test_expect_success 'prompt - cherry-pick' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000216 printf " (main|CHERRY-PICKING)" >expected &&
Phillip Woode981bf72019-07-01 07:21:06 -0700217 test_must_fail git cherry-pick b1 b1^ &&
218 test_when_finished "git cherry-pick --abort" &&
219 __git_ps1 >"$actual" &&
220 test_cmp expected "$actual" &&
221 git reset --merge &&
222 test_must_fail git rev-parse CHERRY_PICK_HEAD &&
223 __git_ps1 >"$actual" &&
224 test_cmp expected "$actual"
225'
226
227test_expect_success 'prompt - revert' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000228 printf " (main|REVERTING)" >expected &&
Phillip Woode981bf72019-07-01 07:21:06 -0700229 test_must_fail git revert b1^ b1 &&
230 test_when_finished "git revert --abort" &&
231 __git_ps1 >"$actual" &&
232 test_cmp expected "$actual" &&
233 git reset --merge &&
234 test_must_fail git rev-parse REVERT_HEAD &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200235 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200236 test_cmp expected "$actual"
237'
238
239test_expect_success 'prompt - bisect' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000240 printf " (main|BISECTING)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200241 git bisect start &&
242 test_when_finished "git bisect reset" &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200243 __git_ps1 >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200244 test_cmp expected "$actual"
245'
246
247test_expect_success 'prompt - dirty status indicator - clean' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000248 printf " (main)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200249 (
250 GIT_PS1_SHOWDIRTYSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200251 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200252 ) &&
253 test_cmp expected "$actual"
254'
255
256test_expect_success 'prompt - dirty status indicator - dirty worktree' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000257 printf " (main *)" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200258 echo "dirty" >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200259 test_when_finished "git reset --hard" &&
260 (
261 GIT_PS1_SHOWDIRTYSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200262 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200263 ) &&
264 test_cmp expected "$actual"
265'
266
267test_expect_success 'prompt - dirty status indicator - dirty index' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000268 printf " (main +)" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200269 echo "dirty" >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200270 test_when_finished "git reset --hard" &&
271 git add -u &&
272 (
273 GIT_PS1_SHOWDIRTYSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200274 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200275 ) &&
276 test_cmp expected "$actual"
277'
278
279test_expect_success 'prompt - dirty status indicator - dirty index and worktree' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000280 printf " (main *+)" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200281 echo "dirty index" >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200282 test_when_finished "git reset --hard" &&
283 git add -u &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200284 echo "dirty worktree" >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200285 (
286 GIT_PS1_SHOWDIRTYSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200287 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200288 ) &&
289 test_cmp expected "$actual"
290'
291
SZEDER Gábora30d11e2015-11-21 12:30:07 +0100292test_expect_success 'prompt - dirty status indicator - orphan branch - clean' '
293 printf " (orphan #)" >expected &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000294 test_when_finished "git checkout main" &&
SZEDER Gábora30d11e2015-11-21 12:30:07 +0100295 git checkout --orphan orphan &&
296 git reset --hard &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200297 (
298 GIT_PS1_SHOWDIRTYSTATE=y &&
SZEDER Gábora30d11e2015-11-21 12:30:07 +0100299 __git_ps1 >"$actual"
300 ) &&
301 test_cmp expected "$actual"
302'
303
SZEDER Gáborc26f70c2015-11-21 12:30:09 +0100304test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index' '
SZEDER Gábora30d11e2015-11-21 12:30:07 +0100305 printf " (orphan +)" >expected &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000306 test_when_finished "git checkout main" &&
SZEDER Gábora30d11e2015-11-21 12:30:07 +0100307 git checkout --orphan orphan &&
308 (
309 GIT_PS1_SHOWDIRTYSTATE=y &&
310 __git_ps1 >"$actual"
311 ) &&
312 test_cmp expected "$actual"
313'
314
SZEDER Gáborc26f70c2015-11-21 12:30:09 +0100315test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index and worktree' '
SZEDER Gábora30d11e2015-11-21 12:30:07 +0100316 printf " (orphan *+)" >expected &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000317 test_when_finished "git checkout main" &&
SZEDER Gábora30d11e2015-11-21 12:30:07 +0100318 git checkout --orphan orphan &&
319 >file &&
320 (
321 GIT_PS1_SHOWDIRTYSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200322 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200323 ) &&
324 test_cmp expected "$actual"
325'
326
Martin Erik Wernerdc7e7bc2013-02-13 21:58:19 +0100327test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000328 printf " (main)" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200329 echo "dirty" >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200330 test_when_finished "git reset --hard" &&
331 test_config bash.showDirtyState false &&
332 (
Martin Erik Wernerdc7e7bc2013-02-13 21:58:19 +0100333 sane_unset GIT_PS1_SHOWDIRTYSTATE &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200334 __git_ps1 >"$actual"
Martin Erik Wernerdc7e7bc2013-02-13 21:58:19 +0100335 ) &&
336 test_cmp expected "$actual"
337'
338
339test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000340 printf " (main)" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200341 echo "dirty" >file &&
Martin Erik Wernerdc7e7bc2013-02-13 21:58:19 +0100342 test_when_finished "git reset --hard" &&
343 test_config bash.showDirtyState true &&
344 (
345 sane_unset GIT_PS1_SHOWDIRTYSTATE &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200346 __git_ps1 >"$actual"
Martin Erik Wernerdc7e7bc2013-02-13 21:58:19 +0100347 ) &&
348 test_cmp expected "$actual"
349'
350
351test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000352 printf " (main)" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200353 echo "dirty" >file &&
Martin Erik Wernerdc7e7bc2013-02-13 21:58:19 +0100354 test_when_finished "git reset --hard" &&
355 test_config bash.showDirtyState false &&
356 (
357 GIT_PS1_SHOWDIRTYSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200358 __git_ps1 >"$actual"
Martin Erik Wernerdc7e7bc2013-02-13 21:58:19 +0100359 ) &&
360 test_cmp expected "$actual"
361'
362
363test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000364 printf " (main *)" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200365 echo "dirty" >file &&
Martin Erik Wernerdc7e7bc2013-02-13 21:58:19 +0100366 test_when_finished "git reset --hard" &&
367 test_config bash.showDirtyState true &&
368 (
SZEDER Gábor963c0402012-05-09 02:44:33 +0200369 GIT_PS1_SHOWDIRTYSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200370 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200371 ) &&
372 test_cmp expected "$actual"
373'
374
375test_expect_success 'prompt - dirty status indicator - not shown inside .git directory' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200376 printf " (GIT_DIR!)" >expected &&
377 echo "dirty" >file &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200378 test_when_finished "git reset --hard" &&
379 (
380 GIT_PS1_SHOWDIRTYSTATE=y &&
381 cd .git &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200382 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200383 ) &&
384 test_cmp expected "$actual"
385'
386
387test_expect_success 'prompt - stash status indicator - no stash' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000388 printf " (main)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200389 (
390 GIT_PS1_SHOWSTASHSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200391 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200392 ) &&
393 test_cmp expected "$actual"
394'
395
396test_expect_success 'prompt - stash status indicator - stash' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000397 printf " (main $)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200398 echo 2 >file &&
399 git stash &&
400 test_when_finished "git stash drop" &&
SZEDER Gábordd0b72c2011-04-01 17:47:37 +0200401 git pack-refs --all &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200402 (
403 GIT_PS1_SHOWSTASHSTATE=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200404 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200405 ) &&
406 test_cmp expected "$actual"
407'
408
409test_expect_success 'prompt - stash status indicator - not shown inside .git directory' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200410 printf " (GIT_DIR!)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200411 echo 2 >file &&
412 git stash &&
413 test_when_finished "git stash drop" &&
414 (
415 GIT_PS1_SHOWSTASHSTATE=y &&
416 cd .git &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200417 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200418 ) &&
419 test_cmp expected "$actual"
420'
421
422test_expect_success 'prompt - untracked files status indicator - no untracked files' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000423 printf " (main)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200424 (
425 GIT_PS1_SHOWUNTRACKEDFILES=y &&
426 cd otherrepo &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200427 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200428 ) &&
429 test_cmp expected "$actual"
430'
431
432test_expect_success 'prompt - untracked files status indicator - untracked files' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000433 printf " (main %%)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200434 (
435 GIT_PS1_SHOWUNTRACKEDFILES=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200436 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200437 ) &&
438 test_cmp expected "$actual"
439'
440
SZEDER Gábor6bfab992015-07-19 13:28:05 +0200441test_expect_success 'prompt - untracked files status indicator - empty untracked dir' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000442 printf " (main)" >expected &&
SZEDER Gábor6bfab992015-07-19 13:28:05 +0200443 mkdir otherrepo/untracked-dir &&
444 test_when_finished "rm -rf otherrepo/untracked-dir" &&
445 (
446 GIT_PS1_SHOWUNTRACKEDFILES=y &&
447 cd otherrepo &&
448 __git_ps1 >"$actual"
449 ) &&
450 test_cmp expected "$actual"
451'
452
453test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000454 printf " (main %%)" >expected &&
SZEDER Gábor6bfab992015-07-19 13:28:05 +0200455 mkdir otherrepo/untracked-dir &&
456 test_when_finished "rm -rf otherrepo/untracked-dir" &&
457 >otherrepo/untracked-dir/untracked-file &&
458 (
459 GIT_PS1_SHOWUNTRACKEDFILES=y &&
460 cd otherrepo &&
461 __git_ps1 >"$actual"
462 ) &&
463 test_cmp expected "$actual"
464'
465
Cody A Taylor9bdc5172015-03-12 19:24:50 -0700466test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000467 printf " (main %%)" >expected &&
Cody A Taylor9bdc5172015-03-12 19:24:50 -0700468 (
469 mkdir -p ignored_dir &&
470 cd ignored_dir &&
471 GIT_PS1_SHOWUNTRACKEDFILES=y &&
472 __git_ps1 >"$actual"
473 ) &&
474 test_cmp expected "$actual"
475'
476
Martin Erik Werner58978e82013-02-13 21:58:18 +0100477test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000478 printf " (main)" >expected &&
Martin Erik Werner58978e82013-02-13 21:58:18 +0100479 test_config bash.showUntrackedFiles false &&
480 (
481 sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200482 __git_ps1 >"$actual"
Martin Erik Werner58978e82013-02-13 21:58:18 +0100483 ) &&
484 test_cmp expected "$actual"
485'
486
487test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000488 printf " (main)" >expected &&
Martin Erik Werner58978e82013-02-13 21:58:18 +0100489 test_config bash.showUntrackedFiles true &&
490 (
491 sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200492 __git_ps1 >"$actual"
Martin Erik Werner58978e82013-02-13 21:58:18 +0100493 ) &&
494 test_cmp expected "$actual"
495'
496
497test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000498 printf " (main)" >expected &&
Martin Erik Werner58978e82013-02-13 21:58:18 +0100499 test_config bash.showUntrackedFiles false &&
500 (
501 GIT_PS1_SHOWUNTRACKEDFILES=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200502 __git_ps1 >"$actual"
Martin Erik Werner58978e82013-02-13 21:58:18 +0100503 ) &&
504 test_cmp expected "$actual"
505'
506
507test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000508 printf " (main %%)" >expected &&
Martin Erik Werner58978e82013-02-13 21:58:18 +0100509 test_config bash.showUntrackedFiles true &&
510 (
511 GIT_PS1_SHOWUNTRACKEDFILES=y &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200512 __git_ps1 >"$actual"
Martin Erik Werner58978e82013-02-13 21:58:18 +0100513 ) &&
514 test_cmp expected "$actual"
515'
516
SZEDER Gábor963c0402012-05-09 02:44:33 +0200517test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200518 printf " (GIT_DIR!)" >expected &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200519 (
520 GIT_PS1_SHOWUNTRACKEDFILES=y &&
521 cd .git &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200522 __git_ps1 >"$actual"
SZEDER Gábor963c0402012-05-09 02:44:33 +0200523 ) &&
524 test_cmp expected "$actual"
525'
526
527test_expect_success 'prompt - format string starting with dash' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000528 printf -- "-main" >expected &&
SZEDER Gábor4fe00b42013-06-17 22:34:16 +0200529 __git_ps1 "-%s" >"$actual" &&
SZEDER Gábor963c0402012-05-09 02:44:33 +0200530 test_cmp expected "$actual"
531'
532
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300533test_expect_success 'prompt - pc mode' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000534 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmain" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300535 (
536 __git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
SZEDER Gábor1c5e94f2018-08-19 23:57:25 +0200537 test_must_be_empty "$actual" &&
Richard Hansen89765002014-04-21 19:53:09 -0400538 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300539 ) &&
540 test_cmp expected "$actual"
541'
542
543test_expect_success 'prompt - bash color pc mode - branch name' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000544 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmain" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300545 (
546 GIT_PS1_SHOWCOLORHINTS=y &&
Eric Sunshinecff42432018-07-01 20:24:04 -0400547 __git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
Richard Hansen89765002014-04-21 19:53:09 -0400548 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300549 ) &&
550 test_cmp expected "$actual"
551'
552
553test_expect_success 'prompt - bash color pc mode - detached head' '
Richard Hansen89765002014-04-21 19:53:09 -0400554 printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300555 git checkout b1^ &&
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000556 test_when_finished "git checkout main" &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300557 (
558 GIT_PS1_SHOWCOLORHINTS=y &&
559 __git_ps1 "BEFORE:" ":AFTER" &&
Richard Hansen89765002014-04-21 19:53:09 -0400560 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300561 ) &&
562 test_cmp expected "$actual"
563'
564
565test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000566 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmain" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300567 echo "dirty" >file &&
568 test_when_finished "git reset --hard" &&
569 (
570 GIT_PS1_SHOWDIRTYSTATE=y &&
571 GIT_PS1_SHOWCOLORHINTS=y &&
572 __git_ps1 "BEFORE:" ":AFTER" &&
Richard Hansen89765002014-04-21 19:53:09 -0400573 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300574 ) &&
575 test_cmp expected "$actual"
576'
577
578test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000579 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmain" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300580 echo "dirty" >file &&
581 test_when_finished "git reset --hard" &&
582 git add -u &&
583 (
584 GIT_PS1_SHOWDIRTYSTATE=y &&
585 GIT_PS1_SHOWCOLORHINTS=y &&
586 __git_ps1 "BEFORE:" ":AFTER" &&
Richard Hansen89765002014-04-21 19:53:09 -0400587 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300588 ) &&
589 test_cmp expected "$actual"
590'
591
592test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000593 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmain" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300594 echo "dirty index" >file &&
595 test_when_finished "git reset --hard" &&
596 git add -u &&
597 echo "dirty worktree" >file &&
598 (
599 GIT_PS1_SHOWCOLORHINTS=y &&
600 GIT_PS1_SHOWDIRTYSTATE=y &&
601 __git_ps1 "BEFORE:" ":AFTER" &&
Richard Hansen89765002014-04-21 19:53:09 -0400602 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300603 ) &&
604 test_cmp expected "$actual"
605'
606
607test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000608 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmain" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300609 (
610 GIT_PS1_SHOWDIRTYSTATE=y &&
611 GIT_PS1_SHOWCOLORHINTS=y &&
612 cd otherrepo &&
613 __git_ps1 "BEFORE:" ":AFTER" &&
Richard Hansen89765002014-04-21 19:53:09 -0400614 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300615 ) &&
616 test_cmp expected "$actual"
617'
618
619test_expect_success 'prompt - bash color pc mode - inside .git directory' '
Richard Hansen89765002014-04-21 19:53:09 -0400620 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nGIT_DIR!" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300621 echo "dirty" >file &&
622 test_when_finished "git reset --hard" &&
623 (
624 GIT_PS1_SHOWDIRTYSTATE=y &&
625 GIT_PS1_SHOWCOLORHINTS=y &&
626 cd .git &&
627 __git_ps1 "BEFORE:" ":AFTER" &&
Richard Hansen89765002014-04-21 19:53:09 -0400628 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300629 ) &&
630 test_cmp expected "$actual"
631'
632
633test_expect_success 'prompt - bash color pc mode - stash status indicator' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000634 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmain" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300635 echo 2 >file &&
636 git stash &&
637 test_when_finished "git stash drop" &&
638 (
639 GIT_PS1_SHOWSTASHSTATE=y &&
640 GIT_PS1_SHOWCOLORHINTS=y &&
641 __git_ps1 "BEFORE:" ":AFTER" &&
Richard Hansen89765002014-04-21 19:53:09 -0400642 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300643 ) &&
644 test_cmp expected "$actual"
645'
646
647test_expect_success 'prompt - bash color pc mode - untracked files status indicator' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000648 printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmain" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300649 (
650 GIT_PS1_SHOWUNTRACKEDFILES=y &&
651 GIT_PS1_SHOWCOLORHINTS=y &&
652 __git_ps1 "BEFORE:" ":AFTER" &&
Richard Hansen89765002014-04-21 19:53:09 -0400653 printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300654 ) &&
655 test_cmp expected "$actual"
656'
657
Eduardo R. D'Avilaf3bd62d2013-06-26 00:05:15 -0300658test_expect_success 'prompt - zsh color pc mode' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000659 printf "BEFORE: (%%F{green}main%%f):AFTER" >expected &&
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300660 (
661 ZSH_VERSION=5.0.0 &&
662 GIT_PS1_SHOWCOLORHINTS=y &&
Richard Hansen1e4119c2014-05-19 18:55:37 -0400663 __git_ps1 "BEFORE:" ":AFTER" &&
664 printf "%s" "$PS1" >"$actual"
Eduardo R. D'Avila1572e182013-06-26 00:05:13 -0300665 ) &&
666 test_cmp expected "$actual"
667'
668
Jess Austin0120b8c2015-01-06 20:22:27 -0500669test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000670 printf " (main)" >expected &&
Jess Austin0120b8c2015-01-06 20:22:27 -0500671 test_config bash.hideIfPwdIgnored false &&
672 (
673 cd ignored_dir &&
674 __git_ps1 >"$actual"
675 ) &&
676 test_cmp expected "$actual"
677'
678
679test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled, pc mode' '
680 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
681 test_config bash.hideIfPwdIgnored false &&
682 (
683 cd ignored_dir &&
684 __git_ps1 "BEFORE:" ":AFTER" &&
685 printf "%s" "$PS1" >"$actual"
686 ) &&
687 test_cmp expected "$actual"
688'
689
690test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000691 printf " (main)" >expected &&
Jess Austin0120b8c2015-01-06 20:22:27 -0500692 (
693 cd ignored_dir &&
694 __git_ps1 >"$actual"
695 ) &&
696 test_cmp expected "$actual"
697'
698
699test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, pc mode' '
700 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
701 (
702 cd ignored_dir &&
703 __git_ps1 "BEFORE:" ":AFTER" &&
704 printf "%s" "$PS1" >"$actual"
705 ) &&
706 test_cmp expected "$actual"
707'
708
709test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' '
Johannes Schindelin8dcf73c2020-11-18 23:44:45 +0000710 printf " (main)" >expected &&
Jess Austin0120b8c2015-01-06 20:22:27 -0500711 test_config bash.hideIfPwdIgnored false &&
712 (
713 cd ignored_dir &&
714 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
715 __git_ps1 >"$actual"
716 ) &&
717 test_cmp expected "$actual"
718'
719
720test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled, pc mode' '
721 printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
722 test_config bash.hideIfPwdIgnored false &&
723 (
724 cd ignored_dir &&
725 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
726 __git_ps1 "BEFORE:" ":AFTER" &&
727 printf "%s" "$PS1" >"$actual"
728 ) &&
729 test_cmp expected "$actual"
730'
731
732test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' '
Jess Austin0120b8c2015-01-06 20:22:27 -0500733 (
734 cd ignored_dir &&
735 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
736 __git_ps1 >"$actual"
737 ) &&
SZEDER Gábor1c5e94f2018-08-19 23:57:25 +0200738 test_must_be_empty "$actual"
Jess Austin0120b8c2015-01-06 20:22:27 -0500739'
740
741test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' '
742 printf "BEFORE::AFTER" >expected &&
743 (
744 cd ignored_dir &&
745 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
746 __git_ps1 "BEFORE:" ":AFTER" &&
747 printf "%s" "$PS1" >"$actual"
748 ) &&
749 test_cmp expected "$actual"
750'
751
SZEDER Gábord31f2982018-02-24 00:39:48 +0100752test_expect_success 'prompt - hide if pwd ignored - inside gitdir' '
Jess Austin0120b8c2015-01-06 20:22:27 -0500753 printf " (GIT_DIR!)" >expected &&
754 (
755 GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
756 cd .git &&
SZEDER Gábord31f2982018-02-24 00:39:48 +0100757 __git_ps1 >"$actual"
Jess Austin0120b8c2015-01-06 20:22:27 -0500758 ) &&
759 test_cmp expected "$actual"
760'
761
SZEDER Gábor963c0402012-05-09 02:44:33 +0200762test_done