git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Re: [PATCH] Add tests for documented features of "git reset".
       [not found] ` <7vr6l5oi4r.fsf@gitster.siamese.dyndns.org>
@ 2007-09-14 22:01   ` Carlos Rica
  2007-09-14 22:10     ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Carlos Rica @ 2007-09-14 22:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Schindelin

[-- Attachment #1: Type: text/plain, Size: 359 bytes --]

2007/9/11, Junio C Hamano <gitster@pobox.com>:
> I also suspect this would not pass on CRLF boxes.

I finally removed the hardcoded object IDs (patch attached,
to be applied on top of the previous patch).

But I don't know what to fix for making the test to pass
in CRLF boxes. Could it due to the comparison of
expected diffs with files created using <<EOF?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-t7102-reset-Use-tags-to-avoid-hardcoded-revision-ID.patch --]
[-- Type: text/x-patch; name="0001-t7102-reset-Use-tags-to-avoid-hardcoded-revision-ID.patch", Size: 7070 bytes --]

From b4c696b3e5b79d02c228bbc79d0d0e8f6a144453 Mon Sep 17 00:00:00 2001
From: Carlos Rica <jasampler@gmail.com>
Date: Thu, 13 Sep 2007 12:37:45 +0200
Subject: [PATCH] t7102-reset: Use tags to avoid hardcoded revision IDs.

Signed-off-by: Carlos Rica <jasampler@gmail.com>
---
 t/t7102-reset.sh |   83 ++++++++++++++++++++++++++---------------------------
 1 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 2cad4db..7e3da71 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -21,19 +21,28 @@ test_expect_success 'creating initial files and commits' '
 
 	echo "2nd line 1st file" >>first &&
 	git commit -a -m "modify 1st file" &&
+	git tag modify1 &&
 
 	git rm first &&
 	git mv second secondfile &&
 	git commit -a -m "remove 1st and rename 2nd" &&
+	git tag moves &&
 
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
-	git commit -a -m "modify 2nd file"
+	git commit -a -m "modify 2nd file" &&
+	git tag modify2
 '
 # git log --pretty=oneline # to see those SHA1 involved
 
+refs_are_equal() {
+	r1=$(git rev-parse $1) &&
+	r2=$(git rev-parse $2) &&
+	test $r1 = $r2
+}
+
 check_changes () {
-	test "$(git rev-parse HEAD)" = "$1" &&
+	refs_are_equal HEAD $1 &&
 	git diff | git diff .diff_expect - &&
 	git diff --cached | git diff .cached_expect - &&
 	for FILE in *
@@ -56,7 +65,7 @@ test_expect_success 'giving a non existing revision should fail' '
 	! git reset --mixed aaaaaa &&
 	! git reset --soft aaaaaa &&
 	! git reset --hard aaaaaa &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes modify2
 '
 
 test_expect_success \
@@ -65,7 +74,7 @@ test_expect_success \
 	! git reset --hard -- first &&
 	! git reset --soft HEAD^ -- first &&
 	! git reset --hard HEAD^ -- first &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes modify2
 '
 
 test_expect_success 'giving unrecognized options should fail' '
@@ -77,7 +86,7 @@ test_expect_success 'giving unrecognized options should fail' '
 	! git reset --soft -o &&
 	! git reset --hard --other &&
 	! git reset --hard -o &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes modify2
 '
 
 test_expect_success \
@@ -101,7 +110,7 @@ test_expect_success \
 
 	git checkout master &&
 	git branch -D branch1 branch2 &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes modify2
 '
 
 test_expect_success \
@@ -124,27 +133,19 @@ test_expect_success \
 
 	git checkout master &&
 	git branch -D branch3 branch4 &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes modify2
 '
 
 test_expect_success \
 	'resetting to HEAD with no changes should succeed and do nothing' '
-	git reset --hard &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
-	git reset --hard HEAD &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
-	git reset --soft &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
-	git reset --soft HEAD &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
-	git reset --mixed &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
-	git reset --mixed HEAD &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
-	git reset &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
-	git reset HEAD &&
-		check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	git reset --hard && check_changes modify2
+	git reset --hard HEAD && check_changes modify2
+	git reset --soft && check_changes modify2
+	git reset --soft HEAD && check_changes modify2
+	git reset --mixed && check_changes modify2
+	git reset --mixed HEAD && check_changes modify2
+	git reset && check_changes modify2
+	git reset HEAD && check_changes modify2
 '
 
 >.diff_expect
@@ -165,9 +166,8 @@ secondfile:
 EOF
 test_expect_success '--soft reset only should show changes in diff --cached' '
 	git reset --soft HEAD^ &&
-	check_changes d1a4bc3abce4829628ae2dcb0d60ef3d1a78b1c4 &&
-	test "$(git rev-parse ORIG_HEAD)" = \
-			3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes moves &&
+	refs_are_equal ORIG_HEAD modify2
 '
 
 >.diff_expect
@@ -182,9 +182,9 @@ test_expect_success \
 	'changing files and redo the last commit should succeed' '
 	echo "3rd line 2nd file" >>secondfile &&
 	git commit -a -C ORIG_HEAD &&
-	check_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&
-	test "$(git rev-parse ORIG_HEAD)" = \
-			3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	git tag addline1
+	check_changes addline1 &&
+	refs_are_equal ORIG_HEAD modify2
 '
 
 >.diff_expect
@@ -199,9 +199,8 @@ EOF
 test_expect_success \
 	'--hard reset should change the files and undo commits permanently' '
 	git reset --hard HEAD~2 &&
-	check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
-	test "$(git rev-parse ORIG_HEAD)" = \
-			3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d
+	check_changes modify1 &&
+	refs_are_equal ORIG_HEAD addline1
 '
 
 >.diff_expect
@@ -243,7 +242,7 @@ test_expect_success \
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
 	git add secondfile &&
-	check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e
+	check_changes modify1
 '
 
 cat >.diff_expect <<EOF
@@ -271,9 +270,8 @@ secondfile:
 EOF
 test_expect_success '--mixed reset to HEAD should unadd the files' '
 	git reset &&
-	check_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
-	test "$(git rev-parse ORIG_HEAD)" = \
-			ddaefe00f1da16864591c61fdc7adb5d7cd6b74e
+	check_changes modify1 &&
+	refs_are_equal ORIG_HEAD modify1
 '
 
 >.diff_expect
@@ -285,7 +283,7 @@ secondfile:
 EOF
 test_expect_success 'redoing the last two commits should succeed' '
 	git add secondfile &&
-	git reset --hard ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&
+	git reset --hard modify1 &&
 
 	git rm first &&
 	git mv second secondfile &&
@@ -294,7 +292,7 @@ test_expect_success 'redoing the last two commits should succeed' '
 	echo "1st line 2nd file" >secondfile &&
 	echo "2nd line 2nd file" >>secondfile &&
 	git commit -a -m "modify 2nd file" &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes modify2
 '
 
 >.diff_expect
@@ -316,10 +314,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
 	git checkout branch2 &&
 	echo "3rd line in branch2" >>secondfile &&
 	git commit -a -m "change in branch2" &&
+	git tag addline2 &&
 
 	! git pull . branch1 &&
 	git reset --hard &&
-	check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
+	check_changes addline2
 '
 
 >.diff_expect
@@ -332,15 +331,15 @@ EOF
 test_expect_success \
 	'--hard reset to ORIG_HEAD should clear a fast-forward merge' '
 	git reset --hard HEAD^ &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+	check_changes modify2 &&
 
 	git pull . branch1 &&
 	git reset --hard ORIG_HEAD &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&
+	check_changes modify2 &&
 
 	git checkout master &&
 	git branch -D branch1 branch2 &&
-	check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
+	check_changes modify2
 '
 
 cat > expect << EOF
-- 
1.5.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add tests for documented features of "git reset".
  2007-09-14 22:01   ` [PATCH] Add tests for documented features of "git reset" Carlos Rica
@ 2007-09-14 22:10     ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2007-09-14 22:10 UTC (permalink / raw)
  To: Carlos Rica; +Cc: git, Johannes Schindelin

"Carlos Rica" <jasampler@gmail.com> writes:

> 2007/9/11, Junio C Hamano <gitster@pobox.com>:
>> I also suspect this would not pass on CRLF boxes.
>
> I finally removed the hardcoded object IDs (patch attached,
> to be applied on top of the previous patch).
>
> But I don't know what to fix for making the test to pass
> in CRLF boxes.

The blobs created by the test script would be different on CRLF
boxes, and exact object IDs hardcoded in your test would not
match.  That was the only thing I meant.

But now you bring it up, I guess the expected output may not
match as well.  Hmmm..

Anyway, thanks for the update.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-09-14 22:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <46E5EAE0.70603@gmail.com>
     [not found] ` <7vr6l5oi4r.fsf@gitster.siamese.dyndns.org>
2007-09-14 22:01   ` [PATCH] Add tests for documented features of "git reset" Carlos Rica
2007-09-14 22:10     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).