From: Michael Rappazzo <hidden> Date: 2016-06-16 02:18:55
Differences from v1[1]:
- Simplify implementation based on review comments
- Included similar changes in rev-parse for --git-path and --shared-index-path
- Added tests and separated them into individual commits
[1] http://thread.gmane.org/gmane.comp.version-control.git/290669
Michael Rappazzo (4):
rev-parse: fix some options when executed from subpath of main tree
t1500-rev-parse: add tests executed from sub path of the main worktree
t2027-worktree-list: add and adjust tests related to git-rev-parse
t1700-split-index: add test for rev-parse --shared-index-path
builtin/rev-parse.c | 19 ++++++++++++++-----
t/t1500-rev-parse.sh | 37 +++++++++++++++++++++++++++++++++++++
t/t1700-split-index.sh | 17 +++++++++++++++++
t/t2027-worktree-list.sh | 10 +++++++++-
4 files changed, 77 insertions(+), 6 deletions(-)
--
2.8.0
From: Michael Rappazzo <hidden> Date: 2016-06-16 02:18:55
Executing `git-rev-parse` with `--git-common-dir`, `--git-path <path>`,
or `--shared-index-path` from the root of the main worktree results in
a relative path to the git dir.
When executed from a subdirectory of the main tree, however, it incorrectly
returns a path which starts 'sub/path/.git'. Change this to return the
proper relative path to the git directory.
Signed-off-by: Michael Rappazzo <redacted>
---
builtin/rev-parse.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
From: Michael Rappazzo <hidden> Date: 2016-06-16 02:18:55
Adjust the incorrect expectation for `rev-parse --git-common-dir`.
Add a test for `git rev-parse --git-path` executed from a linked
worktree.
Signed-off-by: Michael Rappazzo <redacted>
---
t/t2027-worktree-list.sh | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
From: SZEDER Gábor <hidden> Date: 2016-06-16 02:19:04
[Resend to list, sorry for the duplicates.]
Executing `git-rev-parse` with `--git-common-dir`, `--git-path <path>`,
or `--shared-index-path` from the root of the main worktree results in
a relative path to the git dir.
When executed from a subdirectory of the main tree, however, it incorrectly
returns a path which starts 'sub/path/.git'.
This is not completely true, because '--git-path ...' returns a
relative path starting with '.git':
$ git -C t/ rev-parse --git-dir --git-path objects --git-common-dir
/home/szeder/src/git/.git
.git/objects
t/.git
It's still wrong, of course.
Change this to return the
proper relative path to the git directory.
I think returning absolute paths would be better. It is consistent
with the already properly working '--git-dir' option, which returns an
absolute path in this case. Furthermore, both '--git-path ...' and
'--git-common-dir' already return absolute paths when run from a
subdirectory of the .git directory:
$ git -C .git/refs rev-parse --git-dir --git-path objects --git-common-dir
/home/szeder/src/git/.git
/home/szeder/src/git/.git/objects
/home/szeder/src/git/.git
This patch doesn't add any new tests, while subsequent patches of the
series do nothing but add more tests. Splitting up your changes this
way doesn't add any value, it only increases the number of commits. I
think either:
- all those new tests could be added with this patch, or
- if you want to add the test separately, then add them before
this patch and mark them with 'test_expect_failure' to clearly
demonstrate what the series is about to fix, and flip them to
'test_expect_success' in this patch.
- An alternative way to split this series, following the "Make
separate commits for logically separate changes" guideline, would
be to fix and test these options in separate patches, i.e. fix and
test '--git-path ...' in one patch, then fix and test
'--git-common-dir' in the next, ...
@@ -84,4 +85,40 @@ test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false '' gitconfig--unsetcore.bare test_rev_parse'GIT_DIR=../repo.git, core.bare undefined'falsefalsetrue''+#cleanup from the above+cd..+rm-rwork+mvrepo.git.git||exit1
You can't just 'exit 1' mid-script, because terminating the test script
abruptly makes the test harness unhappy.
+unset GIT_DIR
+unset GIT_CONFIG
Both variables are set at this point, so calling plain 'unset' is OK.
Still, I would suggest using 'sane_unset' instead, so the next person
looking at this test doesn't have to spend brain cycles on figuring
out whether plain 'unset' is indeed safe or not.
+git config core.bare $original_core_bare
This whole '#cleanup from the above' block is just ugly. Not your
fault, of course, but the consequence of how the preceeding tests were
written in the past. I think it would be best if this series were
scheduled on top of the 't1500 cleanup & modernization' patch I saw a
few days ago, then this block wouldn't be necessary at all.
From: SZEDER Gábor <hidden> Date: 2016-06-16 02:19:04
[Resend to list, sorry for the duplicates...]
quoted hunk
Adjust the incorrect expectation for `rev-parse --git-common-dir`.
Add a test for `git rev-parse --git-path` executed from a linked
worktree.
Signed-off-by: Michael Rappazzo <redacted>
---
t/t2027-worktree-list.sh | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
@@ -14,10 +14,18 @@ test_expect_success 'rev-parse --git-common-dir on main worktree' 'test_cmpexpectedactual&&mkdirsub&&git-Csubrev-parse--git-common-dir>actual2&&-echosub/.git>expected2&&+echo../.git>expected2&&test_cmpexpected2actual2'
This hunk must go into patch 1/4.
The full test suite should pass after every single commit. As patch
1/4 fixes things, the changing behavior makes this test case fail,
resulting in two commits in which 'make test' would fail.