Skip to content

Commit

Permalink
t1200: fix a timing dependent error
Browse files Browse the repository at this point in the history
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 <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nanako Shiraishi authored and Junio C Hamano committed Nov 25, 2009
1 parent ba2c747 commit 5d166cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Documentation/gitcore-tutorial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1186,9 +1186,9 @@ $ git show-branch
* [master] Some fun.
! [mybranch] Some work.
--
+ [mybranch] Some work.
* [master] Some fun.
*+ [mybranch^] Initial commit
+ [mybranch] Some work.
*+ [master^] Initial commit
------------

Now we are ready to experiment with the merge by hand.
Expand Down
10 changes: 7 additions & 3 deletions t/t1200-tutorial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ test_expect_success 'tree' '
'

test_expect_success 'git diff-index -p HEAD' '
tree=$(git write-tree)
test_tick &&
tree=$(git write-tree) &&
commit=$(echo "Initial commit" | git commit-tree $tree) &&
git update-ref HEAD $commit &&
git diff-index -p HEAD > diff.output &&
Expand Down Expand Up @@ -113,12 +114,14 @@ test_expect_success 'git branch' '
test_expect_success 'git resolve now fails' '
git checkout mybranch &&
echo "Work, work, work" >>hello &&
test_tick &&
git commit -m "Some work." -i hello &&
git checkout master &&
echo "Play, play, play" >>hello &&
echo "Lots of fun" >>example &&
test_tick &&
git commit -m "Some fun." -i hello example &&
test_must_fail git merge -m "Merge work in mybranch" mybranch
Expand All @@ -141,6 +144,7 @@ cat > show-branch.expect << EOF
EOF

test_expect_success 'git show-branch' '
test_tick &&
git commit -m "Merge work in mybranch" -i hello &&
git show-branch --topo-order --more=1 master mybranch \
> show-branch.output &&
Expand Down Expand Up @@ -201,9 +205,9 @@ cat > show-branch4.expect << EOF
* [master] Some fun.
! [mybranch] Some work.
--
+ [mybranch] Some work.
* [master] Some fun.
*+ [mybranch^] Initial commit
+ [mybranch] Some work.
*+ [master^] Initial commit
EOF

test_expect_success 'git show-branch (part 4)' '
Expand Down

0 comments on commit 5d166cc

Please sign in to comment.