tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2012 SZEDER Gábor
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='test git-specific bash prompt functions'
|
|
|
|
|
|
|
|
. ./lib-bash.sh
|
|
|
|
|
2012-05-22 22:46:40 +02:00
|
|
|
. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
|
|
|
|
actual="$TRASH_DIRECTORY/actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
c_red='\\[\\e[31m\\]'
|
|
|
|
c_green='\\[\\e[32m\\]'
|
|
|
|
c_lblue='\\[\\e[1;34m\\]'
|
|
|
|
c_clear='\\[\\e[0m\\]'
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
|
|
|
|
test_expect_success 'setup for prompt tests' '
|
|
|
|
git init otherrepo &&
|
2013-06-17 22:34:16 +02:00
|
|
|
echo 1 >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
git tag -a -m msg1 t1 &&
|
|
|
|
git checkout -b b1 &&
|
2013-06-17 22:34:16 +02:00
|
|
|
echo 2 >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git commit -m "second b1" file &&
|
2013-06-17 22:34:16 +02:00
|
|
|
echo 3 >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git commit -m "third b1" file &&
|
|
|
|
git tag -a -m msg2 t2 &&
|
|
|
|
git checkout -b b2 master &&
|
2013-06-17 22:34:16 +02:00
|
|
|
echo 0 >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git commit -m "second b2" file &&
|
2013-06-17 22:34:16 +02:00
|
|
|
echo 00 >file &&
|
2013-04-25 11:28:54 +02:00
|
|
|
git commit -m "another b2" file &&
|
2013-06-17 22:34:16 +02:00
|
|
|
echo 000 >file &&
|
2013-04-25 11:28:54 +02:00
|
|
|
git commit -m "yet another b2" file &&
|
2015-01-07 02:22:27 +01:00
|
|
|
mkdir ignored_dir &&
|
|
|
|
echo "ignored_dir/" >>.gitignore &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout master
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - branch name' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2012-08-24 19:52:48 +02:00
|
|
|
test_expect_success SYMLINKS 'prompt - branch name - symlink symref' '
|
|
|
|
printf " (master)" >expected &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
test_config core.preferSymlinkRefs true &&
|
|
|
|
git checkout master &&
|
|
|
|
__git_ps1 >"$actual" &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
bash prompt: combine 'git rev-parse' for detached head
When describing a detached HEAD according to the $GIT_PS1_DESCRIBE
environment variable fails, __git_ps1() now runs the '$(git rev-parse
--short HEAD)' command substitution to get the abbreviated detached
HEAD commit object name. This imposes the overhead of fork()ing a
subshell and fork()+exec()ing a git process.
Avoid this overhead by combining this command substitution with the
"main" 'git rev-parse' execution for getting the path to the .git
directory & co. This means that we'll look for the abbreviated commit
object name even when it's not necessary, because we're on a branch or
the detached HEAD can be described. It doesn't matter, however,
because once 'git rev-parse' is up and running to fulfill all those
other queries, the additional overhead of looking for the abbreviated
commit object name is not measurable because it's lost in the noise.
There is a caveat, however, when we are on an unborn branch, because
in that case HEAD doesn't point to a valid commit, hence the query for
the abbreviated commit object name fails. Therefore, '--short HEAD'
must be the last options to 'git rev-parse' in order to get all the
other necessary information for the prompt even on an unborn branch.
Furthermore, in that case, and in that case only, 'git rev-parse'
doesn't output the last line containing the abbreviated commit object
name, obviously, so we have to take care to only parse it if 'git
rev-parse' exited without any error.
Although there are tests already excercising __git_ps1() on unborn
branches, they all do so implicitly. Add a test that checks this
explicitly.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
2013-06-24 02:16:02 +02:00
|
|
|
test_expect_success 'prompt - unborn branch' '
|
|
|
|
printf " (unborn)" >expected &&
|
|
|
|
git checkout --orphan unborn &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
__git_ps1 >"$actual" &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
bash prompt: test the prompt with newline in repository path
Newlines in the path to a git repository were not an issue for the
git-specific bash prompt before commit efaa0c1532 (bash prompt:
combine 'git rev-parse' executions in the main code path, 2013-06-17),
because the path returned by 'git rev-parse --git-dir' was directly
stored in a variable, and this variable was later always accessed
inside double quotes.
Newlines are not an issue after commit efaa0c1532 either, but it's
more subtle. Since efaa0c1532 we use the following single 'git
rev-parse' execution to query various info about the repository:
git rev-parse --git-dir --is-inside-git-dir \
--is-bare-repository --is-inside-work-tree
The results to these queries are separated by a newline character in
the output, e.g.:
/home/szeder/src/git/.git
false
false
true
A newline in the path to the git repository could potentially break
the parsing of these results and ultimately the bash prompt, unless
the parsing is done right. Commit efaa0c1532 got it right, as I
consciously started parsing 'git rev-parse's output from the end,
where each record is a single line containing either 'true' or 'false'
or, after e3e0b9378b (bash prompt: combine 'git rev-parse' for
detached head, 2013-06-24), the abbreviated commit object name, and
all what remains at the beginning is the path to the git repository,
no matter how many lines it is.
This subtlety really warrants its own test, especially since I didn't
explain it in the log message or in an in-code comment back then, so
add a test to excercise the prompt with newline characters in the path
to the repository. Guard this test with the FUNNYNAMES prerequisite,
because not all filesystems support newlines in filenames. Note that
'git rev-parse --git-dir' prints '.git' or '.' when at the top of the
worktree or the repository, respectively, and only prints the full
path to the repository when in a subdirectory, hence the need for
changing into a subdir in the test.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-17 11:01:58 +02:00
|
|
|
repo_with_newline='repo
|
|
|
|
with
|
|
|
|
newline'
|
|
|
|
|
|
|
|
if mkdir "$repo_with_newline" 2>/dev/null
|
|
|
|
then
|
|
|
|
test_set_prereq FUNNYNAMES
|
|
|
|
else
|
|
|
|
say 'Your filesystem does not allow newlines in filenames.'
|
|
|
|
fi
|
|
|
|
|
|
|
|
test_expect_success FUNNYNAMES 'prompt - with newline in path' '
|
|
|
|
printf " (master)" >expected &&
|
|
|
|
git init "$repo_with_newline" &&
|
|
|
|
test_when_finished "rm -rf \"$repo_with_newline\"" &&
|
|
|
|
mkdir "$repo_with_newline"/subdir &&
|
|
|
|
(
|
|
|
|
cd "$repo_with_newline/subdir" &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_expect_success 'prompt - detached head' '
|
2013-06-24 01:55:42 +02:00
|
|
|
printf " ((%s...))" $(git log -1 --format="%h" --abbrev=13 b1^) >expected &&
|
|
|
|
test_config core.abbrev 13 &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout b1^ &&
|
|
|
|
test_when_finished "git checkout master" &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - describe detached head - contains' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " ((t2~1))" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout b1^ &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_DESCRIBE_STYLE=contains &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - describe detached head - branch' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " ((b1~1))" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout b1^ &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_DESCRIBE_STYLE=branch &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - describe detached head - describe' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " ((t1-1-g%s))" $(git log -1 --format="%h" b1^) >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout b1^ &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_DESCRIBE_STYLE=describe &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - describe detached head - default' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " ((t2))" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout --detach b1 &&
|
|
|
|
test_when_finished "git checkout master" &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - inside .git directory' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (GIT_DIR!)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
cd .git &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - deep inside .git directory' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (GIT_DIR!)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
cd .git/refs/heads &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - inside bare repository' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (BARE:master)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git init --bare bare.git &&
|
|
|
|
test_when_finished "rm -rf bare.git" &&
|
|
|
|
(
|
|
|
|
cd bare.git &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - interactive rebase' '
|
2015-03-20 11:07:15 +01:00
|
|
|
printf " (b1|REBASE-i 2/3)" >expected &&
|
2012-08-24 20:03:58 +02:00
|
|
|
write_script fake_editor.sh <<-\EOF &&
|
|
|
|
echo "exec echo" >"$1"
|
|
|
|
echo "edit $(git log -1 --format="%h")" >>"$1"
|
|
|
|
echo "exec echo" >>"$1"
|
|
|
|
EOF
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_when_finished "rm -f fake_editor.sh" &&
|
|
|
|
test_set_editor "$TRASH_DIRECTORY/fake_editor.sh" &&
|
|
|
|
git checkout b1 &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
git rebase -i HEAD^ &&
|
|
|
|
test_when_finished "git rebase --abort"
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - rebase merge' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (b2|REBASE-m 1/3)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout b2 &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
test_must_fail git rebase --merge b1 b2 &&
|
|
|
|
test_when_finished "git rebase --abort" &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - rebase' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (b2|REBASE 1/3)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout b2 &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
test_must_fail git rebase b1 b2 &&
|
|
|
|
test_when_finished "git rebase --abort" &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - merge' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (b1|MERGING)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git checkout b1 &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
test_must_fail git merge b2 &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - cherry-pick' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master|CHERRY-PICKING)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_must_fail git cherry-pick b1 &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bisect' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master|BISECTING)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
git bisect start &&
|
|
|
|
test_when_finished "git bisect reset" &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - clean' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - dirty worktree' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master *)" >expected &&
|
|
|
|
echo "dirty" >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - dirty index' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master +)" >expected &&
|
|
|
|
echo "dirty" >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git add -u &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - dirty index and worktree' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master *+)" >expected &&
|
|
|
|
echo "dirty index" >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git add -u &&
|
2013-06-17 22:34:16 +02:00
|
|
|
echo "dirty worktree" >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - before root commit' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master #)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
cd otherrepo &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2013-02-13 21:58:19 +01:00
|
|
|
test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
|
|
|
echo "dirty" >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
test_config bash.showDirtyState false &&
|
2013-02-13 21:58:19 +01:00
|
|
|
(
|
|
|
|
sane_unset GIT_PS1_SHOWDIRTYSTATE &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 21:58:19 +01:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
|
|
|
echo "dirty" >file &&
|
2013-02-13 21:58:19 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
test_config bash.showDirtyState true &&
|
|
|
|
(
|
|
|
|
sane_unset GIT_PS1_SHOWDIRTYSTATE &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 21:58:19 +01:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
|
|
|
echo "dirty" >file &&
|
2013-02-13 21:58:19 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
test_config bash.showDirtyState false &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 21:58:19 +01:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master *)" >expected &&
|
|
|
|
echo "dirty" >file &&
|
2013-02-13 21:58:19 +01:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
test_config bash.showDirtyState true &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - not shown inside .git directory' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (GIT_DIR!)" >expected &&
|
|
|
|
echo "dirty" >file &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
cd .git &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - stash status indicator - no stash' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWSTASHSTATE=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - stash status indicator - stash' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master $)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
echo 2 >file &&
|
|
|
|
git stash &&
|
|
|
|
test_when_finished "git stash drop" &&
|
2011-04-01 17:47:37 +02:00
|
|
|
git pack-refs --all &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWSTASHSTATE=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - stash status indicator - not shown inside .git directory' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (GIT_DIR!)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
echo 2 >file &&
|
|
|
|
git stash &&
|
|
|
|
test_when_finished "git stash drop" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWSTASHSTATE=y &&
|
|
|
|
cd .git &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - no untracked files' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
cd otherrepo &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - untracked files' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master %%)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2013-02-13 21:58:18 +01:00
|
|
|
test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
2013-02-13 21:58:18 +01:00
|
|
|
test_config bash.showUntrackedFiles false &&
|
|
|
|
(
|
|
|
|
sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 21:58:18 +01:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
2013-02-13 21:58:18 +01:00
|
|
|
test_config bash.showUntrackedFiles true &&
|
|
|
|
(
|
|
|
|
sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 21:58:18 +01:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master)" >expected &&
|
2013-02-13 21:58:18 +01:00
|
|
|
test_config bash.showUntrackedFiles false &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 21:58:18 +01:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (master %%)" >expected &&
|
2013-02-13 21:58:18 +01:00
|
|
|
test_config bash.showUntrackedFiles true &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 21:58:18 +01:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf " (GIT_DIR!)" >expected &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
cd .git &&
|
2013-06-17 22:34:16 +02:00
|
|
|
__git_ps1 >"$actual"
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - format string starting with dash' '
|
2013-06-17 22:34:16 +02:00
|
|
|
printf -- "-master" >expected &&
|
|
|
|
__git_ps1 "-%s" >"$actual" &&
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2013-06-26 05:05:13 +02:00
|
|
|
test_expect_success 'prompt - pc mode' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
printf "" >expected_output &&
|
|
|
|
(
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
|
|
|
|
test_cmp expected_output "$actual" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - branch name' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmaster" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" >"$actual"
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - detached head' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
git checkout b1^ &&
|
|
|
|
test_when_finished "git checkout master" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmaster" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
echo "dirty" >file &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
echo "dirty" >file &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git add -u &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
echo "dirty index" >file &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git add -u &&
|
|
|
|
echo "dirty worktree" >file &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmaster" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
cd otherrepo &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - inside .git directory' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nGIT_DIR!" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
echo "dirty" >file &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
cd .git &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - stash status indicator' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmaster" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
echo 2 >file &&
|
|
|
|
git stash &&
|
|
|
|
test_when_finished "git stash drop" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWSTASHSTATE=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - untracked files status indicator' '
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmaster" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-22 01:53:09 +02:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2013-06-26 05:05:15 +02:00
|
|
|
test_expect_success 'prompt - zsh color pc mode' '
|
2014-05-20 00:55:37 +02:00
|
|
|
printf "BEFORE: (%%F{green}master%%f):AFTER" >expected &&
|
2013-06-26 05:05:13 +02:00
|
|
|
(
|
|
|
|
ZSH_VERSION=5.0.0 &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
2014-05-20 00:55:37 +02:00
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
|
|
|
printf "%s" "$PS1" >"$actual"
|
2013-06-26 05:05:13 +02:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2015-01-07 02:22:27 +01:00
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' '
|
|
|
|
printf " (master)" >expected &&
|
|
|
|
test_config bash.hideIfPwdIgnored false &&
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled, pc mode' '
|
|
|
|
printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
|
|
|
|
test_config bash.hideIfPwdIgnored false &&
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
|
|
|
printf "%s" "$PS1" >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' '
|
|
|
|
printf " (master)" >expected &&
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, pc mode' '
|
|
|
|
printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
|
|
|
printf "%s" "$PS1" >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' '
|
|
|
|
printf " (master)" >expected &&
|
|
|
|
test_config bash.hideIfPwdIgnored false &&
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled, pc mode' '
|
|
|
|
printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected &&
|
|
|
|
test_config bash.hideIfPwdIgnored false &&
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
|
|
|
printf "%s" "$PS1" >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' '
|
|
|
|
printf "" >expected &&
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' '
|
|
|
|
printf "BEFORE::AFTER" >expected &&
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
|
|
|
printf "%s" "$PS1" >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stdout)' '
|
|
|
|
printf " (GIT_DIR!)" >expected &&
|
|
|
|
(
|
|
|
|
GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
|
|
|
|
cd .git &&
|
|
|
|
__git_ps1 >"$actual" 2>/dev/null
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stderr)' '
|
|
|
|
printf "" >expected &&
|
|
|
|
(
|
|
|
|
GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
|
|
|
|
cd .git &&
|
|
|
|
__git_ps1 >/dev/null 2>"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
tests: add tests for the bash prompt functions in the completion script
The tests cover the discovery of the '.git' directory in the
__gitdir() function in different scenarios, and the prompt itself,
i.e. branch name, detached heads, operations (rebase, merge,
cherry-pick, bisect), and status indicators (dirty, stash, untracked
files; but not the upstream status).
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-09 02:44:33 +02:00
|
|
|
test_done
|