Skip to content

Commit 40b1e1e

Browse files
LukeShugitster
authored andcommitted
subtree: t7900: comment subtree_test_create_repo
It's unclear what the purpose of t7900-subtree.sh's `subtree_test_create_repo` helper function is. It wraps test-lib.sh's, `test_create_repo` but follows that up by setting log.date=relative. Why does it set log.date=relative? My first guess was that at one point the tests required that, but no longer do, and that the function is now vestigial. I even wrote a patch to get rid of it and was moments away from `git send-email`ing it. However, by chance when looking for something else in the history, I discovered the true reason, from e7aac44 (contrib/subtree: ignore log.date configuration, 2015-07-21). It's testing that setting log.date=relative doesn't break `git subtree`, as at one point in the past that did break `git subtree`. So, add a comment about this, to avoid future such confusion. And while at it, go ahead and (1) touch up the function to avoid a pointless subshell and (2) update the one test that didn't use it. Signed-off-by: Luke Shumaker <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f700406 commit 40b1e1e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

contrib/subtree/t/t7900-subtree.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ TEST_DIRECTORY=$(pwd)/../../../t
1313
export TEST_DIRECTORY
1414
. "$TEST_DIRECTORY"/test-lib.sh
1515

16+
# Use our own wrapper around test-lib.sh's test_create_repo, in order
17+
# to set log.date=relative. `git subtree` parses the output of `git
18+
# log`, and so it must be careful to not be affected by settings that
19+
# change the `git log` output. We test this by setting
20+
# log.date=relative for every repo in the tests.
1621
subtree_test_create_repo () {
1722
test_create_repo "$1" &&
18-
(
19-
cd "$1" &&
20-
git config log.date relative
21-
)
23+
git -C "$1" config log.date relative
2224
}
2325

2426
create () {
@@ -242,8 +244,8 @@ test_expect_success 'merge the added subproj again, should do nothing' '
242244
'
243245

244246
test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '
245-
test_create_repo "$test_count" &&
246-
test_create_repo "$test_count/subproj" &&
247+
subtree_test_create_repo "$test_count" &&
248+
subtree_test_create_repo "$test_count/subproj" &&
247249
test_create_commit "$test_count" main1 &&
248250
test_create_commit "$test_count/subproj" sub1 &&
249251
(

0 commit comments

Comments
 (0)