Skip to content

Commit 5d166cc

Browse files
Nanako Shiraishigitster
authored andcommitted
t1200: fix a timing dependent error
The fourth test of show-branch in t1200 test was failing but only sometimes. It only failed when two commits created in an earlier test had different timestamps. When they were created within the same second, the actual output matched the expected output. Fix this by using test_tick to force reliable timestamps and update the expected output so it does not to depend on the commits made in the same sacond. Signed-off-by: Nanako Shiraishi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba2c747 commit 5d166cc

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Documentation/gitcore-tutorial.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,9 +1186,9 @@ $ git show-branch
11861186
* [master] Some fun.
11871187
! [mybranch] Some work.
11881188
--
1189-
+ [mybranch] Some work.
11901189
* [master] Some fun.
1191-
*+ [mybranch^] Initial commit
1190+
+ [mybranch] Some work.
1191+
*+ [master^] Initial commit
11921192
------------
11931193

11941194
Now we are ready to experiment with the merge by hand.

t/t1200-tutorial.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ test_expect_success 'tree' '
4747
'
4848

4949
test_expect_success 'git diff-index -p HEAD' '
50-
tree=$(git write-tree)
50+
test_tick &&
51+
tree=$(git write-tree) &&
5152
commit=$(echo "Initial commit" | git commit-tree $tree) &&
5253
git update-ref HEAD $commit &&
5354
git diff-index -p HEAD > diff.output &&
@@ -113,12 +114,14 @@ test_expect_success 'git branch' '
113114
test_expect_success 'git resolve now fails' '
114115
git checkout mybranch &&
115116
echo "Work, work, work" >>hello &&
117+
test_tick &&
116118
git commit -m "Some work." -i hello &&
117119
118120
git checkout master &&
119121
120122
echo "Play, play, play" >>hello &&
121123
echo "Lots of fun" >>example &&
124+
test_tick &&
122125
git commit -m "Some fun." -i hello example &&
123126
124127
test_must_fail git merge -m "Merge work in mybranch" mybranch
@@ -141,6 +144,7 @@ cat > show-branch.expect << EOF
141144
EOF
142145

143146
test_expect_success 'git show-branch' '
147+
test_tick &&
144148
git commit -m "Merge work in mybranch" -i hello &&
145149
git show-branch --topo-order --more=1 master mybranch \
146150
> show-branch.output &&
@@ -201,9 +205,9 @@ cat > show-branch4.expect << EOF
201205
* [master] Some fun.
202206
! [mybranch] Some work.
203207
--
204-
+ [mybranch] Some work.
205208
* [master] Some fun.
206-
*+ [mybranch^] Initial commit
209+
+ [mybranch] Some work.
210+
*+ [master^] Initial commit
207211
EOF
208212

209213
test_expect_success 'git show-branch (part 4)' '

0 commit comments

Comments
 (0)