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 00:44:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2012 SZEDER Gábor
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='test git-specific bash prompt functions'
|
|
|
|
|
2020-11-18 23:44:45 +00:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-18 23:44:19 +00:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
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 00:44:33 +00:00
|
|
|
. ./lib-bash.sh
|
|
|
|
|
2012-05-22 20:46:40 +00: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 00:44:33 +00:00
|
|
|
|
|
|
|
actual="$TRASH_DIRECTORY/actual"
|
2013-06-26 03:05:13 +00: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 00:44:33 +00:00
|
|
|
|
|
|
|
test_expect_success 'setup for prompt tests' '
|
|
|
|
git init otherrepo &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
git tag -a -m msg1 t1 &&
|
|
|
|
git checkout -b b1 &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git commit -m "second b1" file &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git commit -m "third b1" file &&
|
|
|
|
git tag -a -m msg2 t2 &&
|
2020-11-18 23:44:45 +00:00
|
|
|
git checkout -b b2 main &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git commit -m "second b2" file &&
|
2013-06-17 20:34:16 +00:00
|
|
|
echo 00 >file &&
|
2013-04-25 09:28:54 +00:00
|
|
|
git commit -m "another b2" file &&
|
2013-06-17 20:34:16 +00:00
|
|
|
echo 000 >file &&
|
2013-04-25 09:28:54 +00:00
|
|
|
git commit -m "yet another b2" file &&
|
2015-01-07 01:22:27 +00:00
|
|
|
mkdir ignored_dir &&
|
|
|
|
echo "ignored_dir/" >>.gitignore &&
|
2020-11-18 23:44:45 +00:00
|
|
|
git checkout main
|
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 00:44:33 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - branch name' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2012-08-24 17:52:48 +00:00
|
|
|
test_expect_success SYMLINKS 'prompt - branch name - symlink symref' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
|
|
|
test_when_finished "git checkout main" &&
|
2012-08-24 17:52:48 +00:00
|
|
|
test_config core.preferSymlinkRefs true &&
|
2020-11-18 23:44:45 +00:00
|
|
|
git checkout main &&
|
2012-08-24 17:52:48 +00:00
|
|
|
__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 00:16:02 +00:00
|
|
|
test_expect_success 'prompt - unborn branch' '
|
|
|
|
printf " (unborn)" >expected &&
|
|
|
|
git checkout --orphan unborn &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
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 00:16:02 +00:00
|
|
|
__git_ps1 >"$actual" &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
t: factor out FUNNYNAMES as shared lazy prereq
A fair number of tests need to check that the filesystem supports file
names including "funny" characters, like newline, tab, and double-quote.
Jonathan Nieder suggested that this be extracted into a lazy prereq in
the top-level `test-lib.sh`. This patch effects that change.
The FUNNYNAMES prereq now uniformly requires support for newlines, tabs,
and double-quotes in filenames. This very slightly decreases the power
of some tests, which might have run previously on a system that supports
(e.g.) newlines and tabs but not double-quotes, but now will not. This
seems to me like an acceptable tradeoff for consistency.
One test (`t/t9902-completion.sh`) defined FUNNYNAMES to further require
the separators \034 through \037, the test for which was implemented
using the Bash-specific $'\034' syntax. I've elected to leave this one
as is, renaming it to FUNNIERNAMES.
After this patch, `git grep 'test_\(set\|lazy\)_prereq.*FUNNYNAMES'` has
only one result.
Signed-off-by: William Chargin <wchargin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-06 18:35:08 +00:00
|
|
|
if test_have_prereq !FUNNYNAMES; then
|
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 09:01:58 +00:00
|
|
|
say 'Your filesystem does not allow newlines in filenames.'
|
|
|
|
fi
|
|
|
|
|
|
|
|
test_expect_success FUNNYNAMES 'prompt - with newline in path' '
|
t: factor out FUNNYNAMES as shared lazy prereq
A fair number of tests need to check that the filesystem supports file
names including "funny" characters, like newline, tab, and double-quote.
Jonathan Nieder suggested that this be extracted into a lazy prereq in
the top-level `test-lib.sh`. This patch effects that change.
The FUNNYNAMES prereq now uniformly requires support for newlines, tabs,
and double-quotes in filenames. This very slightly decreases the power
of some tests, which might have run previously on a system that supports
(e.g.) newlines and tabs but not double-quotes, but now will not. This
seems to me like an acceptable tradeoff for consistency.
One test (`t/t9902-completion.sh`) defined FUNNYNAMES to further require
the separators \034 through \037, the test for which was implemented
using the Bash-specific $'\034' syntax. I've elected to leave this one
as is, renaming it to FUNNIERNAMES.
After this patch, `git grep 'test_\(set\|lazy\)_prereq.*FUNNYNAMES'` has
only one result.
Signed-off-by: William Chargin <wchargin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-06 18:35:08 +00:00
|
|
|
repo_with_newline="repo
|
|
|
|
with
|
|
|
|
newline" &&
|
|
|
|
mkdir "$repo_with_newline" &&
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
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 09:01:58 +00:00
|
|
|
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 00:44:33 +00:00
|
|
|
test_expect_success 'prompt - detached head' '
|
2013-06-23 23:55:42 +00: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 00:44:33 +00:00
|
|
|
git checkout b1^ &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - describe detached head - contains' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git checkout b1^ &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_DESCRIBE_STYLE=contains &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - describe detached head - branch' '
|
2016-04-22 13:39:01 +00:00
|
|
|
printf " ((tags/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 00:44:33 +00:00
|
|
|
git checkout b1^ &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_DESCRIBE_STYLE=branch &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - describe detached head - describe' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git checkout b1^ &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_DESCRIBE_STYLE=describe &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - describe detached head - default' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git checkout --detach b1 &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - inside .git directory' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
(
|
|
|
|
cd .git &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - deep inside .git directory' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
(
|
2018-05-26 06:47:45 +00:00
|
|
|
cd .git/objects &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - inside bare repository' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (BARE:main)" >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 00:44:33 +00:00
|
|
|
git init --bare bare.git &&
|
|
|
|
test_when_finished "rm -rf bare.git" &&
|
|
|
|
(
|
|
|
|
cd bare.git &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - interactive rebase' '
|
git-prompt: change the prompt for interactive-based rebases
In the past, we had different prompts for different types of rebases:
REBASE: for am-based rebases
REBASE-m: for merge-based rebases
REBASE-i: for interactive-based rebases
It's not clear why this distinction was necessary or helpful; when the
prompt was added in commit e75201963f67 ("Improve bash prompt to detect
various states like an unfinished merge", 2007-09-30), it simply added
these three different types. Perhaps there was a useful purpose back
then, but there have been some changes:
* The merge backend was deleted after being implemented on top of the
interactive backend, causing the prompt for merge-based rebases to
change from REBASE-m to REBASE-i.
* The interactive backend is used for multiple different types of
non-interactive rebases, so the "-i" part of the prompt doesn't
really mean what it used to.
* Rebase backends have gained more abilities and have a great deal of
overlap, sometimes making it hard to distinguish them.
* Behavioral differences between the backends have also been ironed
out.
* We want to change the default backend from am to interactive, which
means people would get "REBASE-i" by default if we didn't change
the prompt, and only if they specified --am or --whitespace or -C
would they get the "REBASE" prompt.
* In the future, we plan to have "--whitespace", "-C", and even "--am"
run the interactive backend once it can handle everything the
am-backend can.
For all these reasons, make the prompt for any type of rebase just be
"REBASE".
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-02-15 21:36:35 +00:00
|
|
|
printf " (b1|REBASE 2/3)" >expected &&
|
2012-08-24 18:03:58 +00: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 00:44:33 +00:00
|
|
|
test_when_finished "rm -f fake_editor.sh" &&
|
|
|
|
test_set_editor "$TRASH_DIRECTORY/fake_editor.sh" &&
|
|
|
|
git checkout b1 &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
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 00:44:33 +00:00
|
|
|
git rebase -i HEAD^ &&
|
2016-09-05 19:00:47 +00:00
|
|
|
test_when_finished "git rebase --abort" &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - rebase merge' '
|
git-prompt: change the prompt for interactive-based rebases
In the past, we had different prompts for different types of rebases:
REBASE: for am-based rebases
REBASE-m: for merge-based rebases
REBASE-i: for interactive-based rebases
It's not clear why this distinction was necessary or helpful; when the
prompt was added in commit e75201963f67 ("Improve bash prompt to detect
various states like an unfinished merge", 2007-09-30), it simply added
these three different types. Perhaps there was a useful purpose back
then, but there have been some changes:
* The merge backend was deleted after being implemented on top of the
interactive backend, causing the prompt for merge-based rebases to
change from REBASE-m to REBASE-i.
* The interactive backend is used for multiple different types of
non-interactive rebases, so the "-i" part of the prompt doesn't
really mean what it used to.
* Rebase backends have gained more abilities and have a great deal of
overlap, sometimes making it hard to distinguish them.
* Behavioral differences between the backends have also been ironed
out.
* We want to change the default backend from am to interactive, which
means people would get "REBASE-i" by default if we didn't change
the prompt, and only if they specified --am or --whitespace or -C
would they get the "REBASE" prompt.
* In the future, we plan to have "--whitespace", "-C", and even "--am"
run the interactive backend once it can handle everything the
am-backend can.
For all these reasons, make the prompt for any type of rebase just be
"REBASE".
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-02-15 21:36:35 +00: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 00:44:33 +00:00
|
|
|
git checkout b2 &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
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 00:44:33 +00:00
|
|
|
test_must_fail git rebase --merge b1 b2 &&
|
|
|
|
test_when_finished "git rebase --abort" &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
git-prompt: change the prompt for interactive-based rebases
In the past, we had different prompts for different types of rebases:
REBASE: for am-based rebases
REBASE-m: for merge-based rebases
REBASE-i: for interactive-based rebases
It's not clear why this distinction was necessary or helpful; when the
prompt was added in commit e75201963f67 ("Improve bash prompt to detect
various states like an unfinished merge", 2007-09-30), it simply added
these three different types. Perhaps there was a useful purpose back
then, but there have been some changes:
* The merge backend was deleted after being implemented on top of the
interactive backend, causing the prompt for merge-based rebases to
change from REBASE-m to REBASE-i.
* The interactive backend is used for multiple different types of
non-interactive rebases, so the "-i" part of the prompt doesn't
really mean what it used to.
* Rebase backends have gained more abilities and have a great deal of
overlap, sometimes making it hard to distinguish them.
* Behavioral differences between the backends have also been ironed
out.
* We want to change the default backend from am to interactive, which
means people would get "REBASE-i" by default if we didn't change
the prompt, and only if they specified --am or --whitespace or -C
would they get the "REBASE" prompt.
* In the future, we plan to have "--whitespace", "-C", and even "--am"
run the interactive backend once it can handle everything the
am-backend can.
For all these reasons, make the prompt for any type of rebase just be
"REBASE".
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-02-15 21:36:35 +00:00
|
|
|
test_expect_success 'prompt - rebase am' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git checkout b2 &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
2020-02-15 21:36:41 +00:00
|
|
|
test_must_fail git rebase --apply b1 b2 &&
|
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 00:44:33 +00:00
|
|
|
test_when_finished "git rebase --abort" &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - merge' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
git checkout b1 &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
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 00:44:33 +00:00
|
|
|
test_must_fail git merge b2 &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - cherry-pick' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main|CHERRY-PICKING)" >expected &&
|
2019-07-01 14:21:06 +00:00
|
|
|
test_must_fail git cherry-pick b1 b1^ &&
|
|
|
|
test_when_finished "git cherry-pick --abort" &&
|
|
|
|
__git_ps1 >"$actual" &&
|
|
|
|
test_cmp expected "$actual" &&
|
|
|
|
git reset --merge &&
|
|
|
|
test_must_fail git rev-parse CHERRY_PICK_HEAD &&
|
|
|
|
__git_ps1 >"$actual" &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - revert' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main|REVERTING)" >expected &&
|
2019-07-01 14:21:06 +00:00
|
|
|
test_must_fail git revert b1^ b1 &&
|
|
|
|
test_when_finished "git revert --abort" &&
|
|
|
|
__git_ps1 >"$actual" &&
|
|
|
|
test_cmp expected "$actual" &&
|
|
|
|
git reset --merge &&
|
|
|
|
test_must_fail git rev-parse REVERT_HEAD &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bisect' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main|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 00:44:33 +00:00
|
|
|
git bisect start &&
|
|
|
|
test_when_finished "git bisect reset" &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - clean' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - dirty worktree' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main *)" >expected &&
|
2013-06-17 20:34:16 +00:00
|
|
|
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 00:44:33 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - dirty index' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main +)" >expected &&
|
2013-06-17 20:34:16 +00:00
|
|
|
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 00:44:33 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git add -u &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - dirty index and worktree' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main *+)" >expected &&
|
2013-06-17 20:34:16 +00:00
|
|
|
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 00:44:33 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
git add -u &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2015-11-21 11:30:07 +00:00
|
|
|
test_expect_success 'prompt - dirty status indicator - orphan branch - clean' '
|
|
|
|
printf " (orphan #)" >expected &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
2015-11-21 11:30:07 +00:00
|
|
|
git checkout --orphan orphan &&
|
|
|
|
git reset --hard &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2015-11-21 11:30:09 +00:00
|
|
|
test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index' '
|
2015-11-21 11:30:07 +00:00
|
|
|
printf " (orphan +)" >expected &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
2015-11-21 11:30:07 +00:00
|
|
|
git checkout --orphan orphan &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2015-11-21 11:30:09 +00:00
|
|
|
test_expect_success 'prompt - dirty status indicator - orphan branch - dirty index and worktree' '
|
2015-11-21 11:30:07 +00:00
|
|
|
printf " (orphan *+)" >expected &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
2015-11-21 11:30:07 +00:00
|
|
|
git checkout --orphan orphan &&
|
|
|
|
>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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2013-02-13 20:58:19 +00:00
|
|
|
test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2013-06-17 20:34:16 +00:00
|
|
|
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 00:44:33 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
test_config bash.showDirtyState false &&
|
2013-02-13 20:58:19 +00:00
|
|
|
(
|
|
|
|
sane_unset GIT_PS1_SHOWDIRTYSTATE &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 20:58:19 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2013-06-17 20:34:16 +00:00
|
|
|
echo "dirty" >file &&
|
2013-02-13 20:58:19 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
test_config bash.showDirtyState true &&
|
|
|
|
(
|
|
|
|
sane_unset GIT_PS1_SHOWDIRTYSTATE &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 20:58:19 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2013-06-17 20:34:16 +00:00
|
|
|
echo "dirty" >file &&
|
2013-02-13 20:58:19 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
test_config bash.showDirtyState false &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 20:58:19 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main *)" >expected &&
|
2013-06-17 20:34:16 +00:00
|
|
|
echo "dirty" >file &&
|
2013-02-13 20:58:19 +00: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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - dirty status indicator - not shown inside .git directory' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
cd .git &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - stash status indicator - no stash' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWSTASHSTATE=y &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - stash status indicator - stash' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main $)" >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 00:44:33 +00:00
|
|
|
echo 2 >file &&
|
|
|
|
git stash &&
|
|
|
|
test_when_finished "git stash drop" &&
|
2011-04-01 15:47:37 +00: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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWSTASHSTATE=y &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - stash status indicator - not shown inside .git directory' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
echo 2 >file &&
|
|
|
|
git stash &&
|
|
|
|
test_when_finished "git stash drop" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWSTASHSTATE=y &&
|
|
|
|
cd .git &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - no untracked files' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
cd otherrepo &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - untracked files' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main %%)" >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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__git_ps1 >"$actual"
|
2015-07-19 11:28:05 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - empty untracked dir' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2015-07-19 11:28:05 +00:00
|
|
|
mkdir otherrepo/untracked-dir &&
|
|
|
|
test_when_finished "rm -rf otherrepo/untracked-dir" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
cd otherrepo &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - non-empty untracked dir' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main %%)" >expected &&
|
2015-07-19 11:28:05 +00:00
|
|
|
mkdir otherrepo/untracked-dir &&
|
|
|
|
test_when_finished "rm -rf otherrepo/untracked-dir" &&
|
|
|
|
>otherrepo/untracked-dir/untracked-file &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
cd otherrepo &&
|
|
|
|
__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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2015-03-13 02:24:50 +00:00
|
|
|
test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main %%)" >expected &&
|
2015-03-13 02:24:50 +00:00
|
|
|
(
|
|
|
|
mkdir -p ignored_dir &&
|
|
|
|
cd ignored_dir &&
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2013-02-13 20:58:18 +00:00
|
|
|
test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2013-02-13 20:58:18 +00:00
|
|
|
test_config bash.showUntrackedFiles false &&
|
|
|
|
(
|
|
|
|
sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 20:58:18 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2013-02-13 20:58:18 +00:00
|
|
|
test_config bash.showUntrackedFiles true &&
|
|
|
|
(
|
|
|
|
sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 20:58:18 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2013-02-13 20:58:18 +00:00
|
|
|
test_config bash.showUntrackedFiles false &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 20:58:18 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main %%)" >expected &&
|
2013-02-13 20:58:18 +00:00
|
|
|
test_config bash.showUntrackedFiles true &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__git_ps1 >"$actual"
|
2013-02-13 20:58:18 +00: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 00:44:33 +00:00
|
|
|
test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
cd .git &&
|
2013-06-17 20:34:16 +00: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 00:44:33 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - format string starting with dash' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf -- "-main" >expected &&
|
2013-06-17 20:34:16 +00:00
|
|
|
__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 00:44:33 +00:00
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2013-06-26 03:05:13 +00:00
|
|
|
test_expect_success 'prompt - pc mode' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmain" >expected &&
|
2013-06-26 03:05:13 +00:00
|
|
|
(
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty "$actual" &&
|
2014-04-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - branch name' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmain" >expected &&
|
2013-06-26 03:05:13 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
2018-07-02 00:24:04 +00:00
|
|
|
__git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
|
2014-04-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - detached head' '
|
2014-04-21 23:53:09 +00:00
|
|
|
printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected &&
|
2013-06-26 03:05:13 +00:00
|
|
|
git checkout b1^ &&
|
2020-11-18 23:44:45 +00:00
|
|
|
test_when_finished "git checkout main" &&
|
2013-06-26 03:05:13 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmain" >expected &&
|
2013-06-26 03:05:13 +00:00
|
|
|
echo "dirty" >file &&
|
|
|
|
test_when_finished "git reset --hard" &&
|
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmain" >expected &&
|
2013-06-26 03:05:13 +00: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-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmain" >expected &&
|
2013-06-26 03:05:13 +00: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-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmain" >expected &&
|
2013-06-26 03:05:13 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWDIRTYSTATE=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
cd otherrepo &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - inside .git directory' '
|
2014-04-21 23:53:09 +00:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nGIT_DIR!" >expected &&
|
2013-06-26 03:05:13 +00: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-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - stash status indicator' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmain" >expected &&
|
2013-06-26 03:05:13 +00: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-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prompt - bash color pc mode - untracked files status indicator' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmain" >expected &&
|
2013-06-26 03:05:13 +00:00
|
|
|
(
|
|
|
|
GIT_PS1_SHOWUNTRACKEDFILES=y &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
2014-04-21 23:53:09 +00:00
|
|
|
printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2013-06-26 03:05:15 +00:00
|
|
|
test_expect_success 'prompt - zsh color pc mode' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf "BEFORE: (%%F{green}main%%f):AFTER" >expected &&
|
2013-06-26 03:05:13 +00:00
|
|
|
(
|
|
|
|
ZSH_VERSION=5.0.0 &&
|
|
|
|
GIT_PS1_SHOWCOLORHINTS=y &&
|
2014-05-19 22:55:37 +00:00
|
|
|
__git_ps1 "BEFORE:" ":AFTER" &&
|
|
|
|
printf "%s" "$PS1" >"$actual"
|
2013-06-26 03:05:13 +00:00
|
|
|
) &&
|
|
|
|
test_cmp expected "$actual"
|
|
|
|
'
|
|
|
|
|
2015-01-07 01:22:27 +00:00
|
|
|
test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2015-01-07 01:22:27 +00:00
|
|
|
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' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2015-01-07 01:22:27 +00:00
|
|
|
(
|
|
|
|
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' '
|
2020-11-18 23:44:45 +00:00
|
|
|
printf " (main)" >expected &&
|
2015-01-07 01:22:27 +00:00
|
|
|
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' '
|
|
|
|
(
|
|
|
|
cd ignored_dir &&
|
|
|
|
GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
|
|
|
|
__git_ps1 >"$actual"
|
|
|
|
) &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty "$actual"
|
2015-01-07 01:22:27 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
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"
|
|
|
|
'
|
|
|
|
|
2018-02-23 23:39:48 +00:00
|
|
|
test_expect_success 'prompt - hide if pwd ignored - inside gitdir' '
|
2015-01-07 01:22:27 +00:00
|
|
|
printf " (GIT_DIR!)" >expected &&
|
|
|
|
(
|
|
|
|
GIT_PS1_HIDE_IF_PWD_IGNORED=y &&
|
|
|
|
cd .git &&
|
2018-02-23 23:39:48 +00:00
|
|
|
__git_ps1 >"$actual"
|
2015-01-07 01:22:27 +00: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 00:44:33 +00:00
|
|
|
test_done
|