summaryrefslogtreecommitdiff
path: root/t/t2020-checkout-detach.sh
AgeCommit message (Collapse)Author
2021-02-11tests: remove most uses of test_i18ncmpÆvar Arnfjörð Bjarmason
As a follow-up to d162b25f956 (tests: remove support for GIT_TEST_GETTEXT_POISON, 2021-01-20) remove most uses of test_i18ncmp via a simple s/test_i18ncmp/test_cmp/g search-replacement. I'm leaving t6300-for-each-ref.sh out due to a conflict with in-flight changes between "master" and "seen", as well as the prerequisite itself due to other changes between "master" and "next/seen" which add new test_i18ncmp uses. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-19t2*: adjust the references to the default branch name "main"Johannes Schindelin
Carefully excluding t2106, which sees independent development elsewhere at the time of writing, we transition above-mentioned tests to the default branch name `main`. This trick was performed via $ (cd t && sed -i -e 's/master/main/g' -e 's/MASTER/MAIN/g' \ -e 's/Master/Main/g' -- t2*.sh && git checkout HEAD -- t2106\*) This allows us to define `GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main` for those tests. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-19tests: mark tests relying on the current default for `init.defaultBranch`Johannes Schindelin
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>
2019-04-02doc: promote "git switch"Nguyễn Thái Ngọc Duy
The new command "git switch" is added to avoid the confusion of one-command-do-all "git checkout" for new users. They are also helpful to avoid ambiguation context. For these reasons, promote it everywhere possible. This includes documentation, suggestions/advice from other commands... The "Checking out files" progress line in unpack-trees.c is also updated to "Updating files" to be neutral to both git-checkout and git-switch. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-04-02checkout: advice how to get out of detached HEAD modeNguyễn Thái Ngọc Duy
Detached HEAD mode is considered dangerous and confusing for newcomers and we print a big block of warning how to move forward. But we should also suggest the user the way to get out of it if they get into detached HEAD by mistake. While at there, I also suggest how to turn the advice off. This is another thing I find annoying with advices and should be dealt with in a more generic way. But that may require some refactoring in advice.c first. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-03-26t2020: abstract away SHA-1 specific constantsbrian m. carlson
Adjust the test so that it uses variables for the revisions we're checking out instead of hard-coded hashes. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-12-06t2020: test variations that matterJunio C Hamano
Because our test suite is not about validating the working of the shell, it is pointless to test variations of how a literal string 'yes' is quoted when assigned to an environment variable. Instead, test various ways to spell 'yes' (we use strcasecmp() so uppercased and capitalized variant should work just like 'yes' spelled in all lowercase) and make sure we take them as 'yes'. That is more relevant in testing Git. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-12-06checkout: describe_detached_head: remove ellipsis after committishAnn T Ropea
We do not want an ellipsis displayed following an (abbreviated) SHA-1 value. The days when this was necessary to indicate the truncation to lower-level Git commands and/or the user are bygone. However, to ease the transition, the ellipsis will still be printed if the user sets the environment variable GIT_PRINT_SHA1_ELLIPSIS to "yes". Correct documentation with respect to what describe_detached_head prints when GIT_PRINT_SHA1_ELLIPSIS is not set as indicated above. Add tests for the old and new behaviour. Signed-off-by: Ann T Ropea <bedhanger@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-08-15checkout: do not mention detach advice for explicit --detach optionStefan Beller
When a user asked for a detached HEAD specifically with `--detach`, we do not need to give advice on what a detached HEAD state entails as we can assume they know what they're getting into as they asked for it. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-16status: add advice on how to push/pull to tracking branchMatthieu Moy
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-10Merge branch 'js/checkout-detach-count'Junio C Hamano
When checking out another commit from an already detached state, we used to report all commits that are not reachable from any of the refs as lossage, but some of them might be reachable from the new HEAD, and there is no need to warn about them. By Johannes Sixt * js/checkout-detach-count: checkout (detached): truncate list of orphaned commits at the new HEAD t2020-checkout-detach: check for the number of orphaned commits
2012-05-04checkout (detached): truncate list of orphaned commits at the new HEADJohannes Sixt
When git checkout switches from a detached HEAD to any other commit, then all orphaned commits were listed in a warning: Warning: you are leaving 2 commits behind...: a5e5396 another fixup 6aa1af6 fixup foo But if the new commit is actually one from this list (6aa1af6 in this example), then the list in the warning can be truncated at the new HEAD, because history beginning at HEAD is not "left behind". This makes it so. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-04t2020-checkout-detach: check for the number of orphaned commitsJohannes Sixt
Change the test that orphans commits to leave 2 commits behind. Add a test that leaves only one of these behind. The next patch will truncate the list of orphaned commits earlier. With this preliminary update, its effect will become more obvious. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-14test: do not rely on US English tracking-info messagesJonathan Nieder
When v1.7.9.2~28^2 (2012-02-02) marked "Your branch is behind" and friends for translation, it forgot to adjust tests not to check those messages when tests are being run with git configured to write its output in another language. With this patch applied, t2020 and t6040 pass again with GETTEXT_POISON=YesPlease. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Explained-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-03checkout: check for "Previous HEAD" notice in t2020René Scharfe
If we leave a detached head, exactly one of two things happens: either checkout warns about it being an orphan or describes it as a courtesy. Test t2020 already checked that the warning is shown as needed. This patch also checks for the description. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13i18n: use test_i18ngrep in t2020, t2204, t3030, and t3200Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-12i18n: mark checkout plural warning for translationÆvar Arnfjörð Bjarmason
Mark the "Warning: you are leaving %d commit(s) behind" message added in v1.7.5-rc0~74^2 (commit: give final warning when reattaching HEAD to leave commits behind) by Junio C Hamano for translation. This message requires the use of ngettext() features, and is the first message to use the Q_() wrapper around ngettext(). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-20checkout: clear commit marks after detached-orphan checkJeff King
When leaving a detached HEAD, we do a revision walk to make sure the commit we are leaving isn't being orphaned. However, this leaves crufty marks in the commit objects which can confuse later walkers, like the one in stat_tracking_info. Let's clean up after ourselves to prevent this conflict. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-20checkout: add basic tests for detached-orphan warningJeff King
Commit 8e2dc6ac added a warning when we leave a detached HEAD whose commit is not reachable from any ref tip. Let's add a few basic tests to make sure it works. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-08checkout: introduce --detach synonym for "git checkout foo^{commit}"Junio C Hamano
For example, one might use this when making a temporary merge to test that two topics work well together. Patch by Junio, with tests from Jeff King. [jn: with some extra checks for bogus commandline usage] Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>