From: Michael Rappazzo <rappazzo@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, pclouds@gmail.com, szeder@ira.uka.de,
Michael Rappazzo <rappazzo@gmail.com>
Subject: [PATCH v3 1/2] rev-parse tests: add tests executed from a subdirectory
Date: Fri, 6 May 2016 09:35:19 -0400 [thread overview]
Message-ID: <1462541720-79553-2-git-send-email-rappazzo@gmail.com> (raw)
In-Reply-To: <1462541720-79553-1-git-send-email-rappazzo@gmail.com>
t1500-rev-parse contains envrionment leaks (changing dir without
changing back, setting config variables, etc). Add a test to clean this
up up so that future tests can be added without worry of any setting
from a previous test.
t2027-worktree-list has an incorrect expectation for --git-common-dir
which has been adjusted and marked to expect failure.
Some of the tests added have been marked to expect failure. These
demonstrate a problem with the way that some options to git rev-parse
behave when executed from a subdirectory of the main worktree.
Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
---
t/t1500-rev-parse.sh | 38 ++++++++++++++++++++++++++++++++++++++
t/t1700-split-index.sh | 17 +++++++++++++++++
t/t2027-worktree-list.sh | 12 ++++++++++--
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 48ee077..442ca46 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -36,6 +36,7 @@ test_rev_parse() {
# label is-bare is-inside-git is-inside-work prefix git-dir
ROOT=$(pwd)
+original_core_bare=$(git config core.bare)
test_rev_parse toplevel false false true '' .git
@@ -84,4 +85,41 @@ test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false ''
git config --unset core.bare
test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
+test_expect_success 'cleanup from the previous tests' '
+ cd .. &&
+ rm -r work &&
+ mv repo.git .git &&
+ unset GIT_DIR &&
+ unset GIT_CONFIG &&
+ git config core.bare $original_core_bare
+'
+
+test_expect_success 'git-common-dir from worktree root' '
+ echo .git >expect &&
+ git rev-parse --git-common-dir >actual &&
+ test_cmp expect actual
+'
+
+test_expect_failure 'git-common-dir inside sub-dir' '
+ mkdir -p path/to/child &&
+ test_when_finished "rm -rf path" &&
+ echo "$(git -C path/to/child rev-parse --show-cdup).git" >expect &&
+ git -C path/to/child rev-parse --git-common-dir >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git-path from worktree root' '
+ echo .git/objects >expect &&
+ git rev-parse --git-path objects >actual &&
+ test_cmp expect actual
+'
+
+test_expect_failure 'git-path inside sub-dir' '
+ mkdir -p path/to/child &&
+ test_when_finished "rm -rf path" &&
+ echo "$(git -C path/to/child rev-parse --show-cdup).git/objects" >expect &&
+ git -C path/to/child rev-parse --git-path objects >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh
index 8aef49f..8ca21bd 100755
--- a/t/t1700-split-index.sh
+++ b/t/t1700-split-index.sh
@@ -200,4 +200,21 @@ EOF
test_cmp expect actual
'
+test_expect_failure 'rev-parse --shared-index-path' '
+ rm -rf .git &&
+ test_create_repo . &&
+ git update-index --split-index &&
+ ls -t .git/sharedindex* | tail -n 1 >expect &&
+ git rev-parse --shared-index-path >actual &&
+ test_cmp expect actual &&
+ mkdir work &&
+ test_when_finished "rm -rf work" &&
+ (
+ cd work &&
+ ls -t ../.git/sharedindex* | tail -n 1 >expect &&
+ git rev-parse --shared-index-path >actual &&
+ test_cmp expect actual
+ )
+'
+
test_done
diff --git a/t/t2027-worktree-list.sh b/t/t2027-worktree-list.sh
index 1b1b65a..53cc5d3 100755
--- a/t/t2027-worktree-list.sh
+++ b/t/t2027-worktree-list.sh
@@ -8,16 +8,24 @@ test_expect_success 'setup' '
test_commit init
'
-test_expect_success 'rev-parse --git-common-dir on main worktree' '
+test_expect_failure 'rev-parse --git-common-dir on main worktree' '
git rev-parse --git-common-dir >actual &&
echo .git >expected &&
test_cmp expected actual &&
mkdir sub &&
git -C sub rev-parse --git-common-dir >actual2 &&
- echo sub/.git >expected2 &&
+ echo ../.git >expected2 &&
test_cmp expected2 actual2
'
+test_expect_failure 'rev-parse --git-path objects linked worktree' '
+ echo "$(git rev-parse --show-toplevel)/.git/worktrees/linked-tree/objects" >expect &&
+ test_when_finished "rm -rf linked-tree && git worktree prune" &&
+ git worktree add --detach linked-tree master &&
+ git -C linked-tree rev-parse --git-path objects >actual &&
+ test_cmp expect actual
+'
+
test_expect_success '"list" all worktrees from main' '
echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect &&
test_when_finished "rm -rf here && git worktree prune" &&
--
2.8.0
next prev parent reply other threads:[~2016-05-06 13:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 13:35 [PATCH v3 0/2] [PATCH v3 0/2] rev-parse: fix some options when executed from subpath of main tree Michael Rappazzo
2016-05-06 13:35 ` Michael Rappazzo [this message]
2016-05-06 22:10 ` [PATCH v3 1/2] rev-parse tests: add tests executed from a subdirectory Junio C Hamano
2016-05-07 13:35 ` Mike Rappazzo
2016-05-08 18:05 ` Junio C Hamano
2016-05-08 18:46 ` Junio C Hamano
2016-05-06 13:35 ` [PATCH v3 2/2] rev-parse: fix some options when executed from subpath of main tree Michael Rappazzo
2016-05-10 7:38 ` Eric Sunshine
-- strict thread matches above, loose matches on Subject: below --
2017-02-10 15:33 [PATCH v2 0/2] Fix bugs in rev-parse's output when run in a subdirectory Johannes Schindelin
2017-02-17 16:58 ` [PATCH v3 " Johannes Schindelin
2017-02-17 16:59 ` [PATCH v3 1/2] rev-parse tests: add tests executed from " Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462541720-79553-2-git-send-email-rappazzo@gmail.com \
--to=rappazzo@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=szeder@ira.uka.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.