-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this patch the setup code is very big, but this will be used in test cases that will be added later. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Christian Couder
authored and
Junio C Hamano
committed
Jun 1, 2009
1 parent
0e87c36
commit a3e8267
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2008 Christian Couder | ||
# | ||
test_description='Tests replace refs functionality' | ||
|
||
exec </dev/null | ||
|
||
. ./test-lib.sh | ||
|
||
add_and_commit_file() | ||
{ | ||
_file="$1" | ||
_msg="$2" | ||
|
||
git add $_file || return $? | ||
test_tick || return $? | ||
git commit --quiet -m "$_file: $_msg" | ||
} | ||
|
||
HASH1= | ||
HASH2= | ||
HASH3= | ||
HASH4= | ||
HASH5= | ||
HASH6= | ||
HASH7= | ||
|
||
test_expect_success 'set up buggy branch' ' | ||
echo "line 1" >> hello && | ||
echo "line 2" >> hello && | ||
echo "line 3" >> hello && | ||
echo "line 4" >> hello && | ||
add_and_commit_file hello "4 lines" && | ||
HASH1=$(git rev-parse --verify HEAD) && | ||
echo "line BUG" >> hello && | ||
echo "line 6" >> hello && | ||
echo "line 7" >> hello && | ||
echo "line 8" >> hello && | ||
add_and_commit_file hello "4 more lines with a BUG" && | ||
HASH2=$(git rev-parse --verify HEAD) && | ||
echo "line 9" >> hello && | ||
echo "line 10" >> hello && | ||
add_and_commit_file hello "2 more lines" && | ||
HASH3=$(git rev-parse --verify HEAD) && | ||
echo "line 11" >> hello && | ||
add_and_commit_file hello "1 more line" && | ||
HASH4=$(git rev-parse --verify HEAD) && | ||
sed -e "s/BUG/5/" hello > hello.new && | ||
mv hello.new hello && | ||
add_and_commit_file hello "BUG fixed" && | ||
HASH5=$(git rev-parse --verify HEAD) && | ||
echo "line 12" >> hello && | ||
echo "line 13" >> hello && | ||
add_and_commit_file hello "2 more lines" && | ||
HASH6=$(git rev-parse --verify HEAD) | ||
echo "line 14" >> hello && | ||
echo "line 15" >> hello && | ||
echo "line 16" >> hello && | ||
add_and_commit_file hello "again 3 more lines" && | ||
HASH7=$(git rev-parse --verify HEAD) | ||
' | ||
|
||
test_expect_success 'replace the author' ' | ||
git cat-file commit $HASH2 | grep "author A U Thor" && | ||
R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) && | ||
git cat-file commit $R | grep "author O Thor" && | ||
git update-ref refs/replace/$HASH2 $R && | ||
git show HEAD~5 | grep "O Thor" && | ||
git show $HASH2 | grep "O Thor" | ||
' | ||
|
||
# | ||
# | ||
test_done |