{"thread":{"id":"9848","subject":"Re: [PATCH] Add tests for documented features of \"git reset\".","startedAt":"2007-09-14T22:01:21Z","lastAt":"2007-09-14T22:10:00Z","messageCount":2,"participants":["Carlos Rica","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"53060","messageId":"1b46aba20709141501l6f0f7440hd22b2bd6c4838a0b@mail.gmail.com","threadId":"9848","inReplyTo":"7vr6l5oi4r.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add tests for documented features of \"git reset\".","fromName":"Carlos Rica","fromEmail":"jasampler@gmail.com","sentAt":"2007-09-14T22:01:21Z","receivedAt":"2007-09-14T22:01:21Z","isPatch":true,"sender":{"key":"jasampler@gmail.com","avatar":null},"body":"2007/9/11, Junio C Hamano <gitster@pobox.com>:\n> I also suspect this would not pass on CRLF boxes.\n\nI finally removed the hardcoded object IDs (patch attached,\nto be applied on top of the previous patch).\n\nBut I don't know what to fix for making the test to pass\nin CRLF boxes. Could it due to the comparison of\nexpected diffs with files created using <<EOF?\n\n\nFrom b4c696b3e5b79d02c228bbc79d0d0e8f6a144453 Mon Sep 17 00:00:00 2001\nFrom: Carlos Rica <jasampler@gmail.com>\nDate: Thu, 13 Sep 2007 12:37:45 +0200\nSubject: [PATCH] t7102-reset: Use tags to avoid hardcoded revision IDs.\n\nSigned-off-by: Carlos Rica <jasampler@gmail.com>\n---\n t/t7102-reset.sh |   83 ++++++++++++++++++++++++++---------------------------\n 1 files changed, 41 insertions(+), 42 deletions(-)\n\ndiff --git a/t/t7102-reset.sh b/t/t7102-reset.sh\nindex 2cad4db..7e3da71 100755\n--- a/t/t7102-reset.sh\n+++ b/t/t7102-reset.sh\n@@ -21,19 +21,28 @@ test_expect_success 'creating initial files and commits' '\n \n \techo \"2nd line 1st file\" >>first &&\n \tgit commit -a -m \"modify 1st file\" &&\n+\tgit tag modify1 &&\n \n \tgit rm first &&\n \tgit mv second secondfile &&\n \tgit commit -a -m \"remove 1st and rename 2nd\" &&\n+\tgit tag moves &&\n \n \techo \"1st line 2nd file\" >secondfile &&\n \techo \"2nd line 2nd file\" >>secondfile &&\n-\tgit commit -a -m \"modify 2nd file\"\n+\tgit commit -a -m \"modify 2nd file\" &&\n+\tgit tag modify2\n '\n # git log --pretty=oneline # to see those SHA1 involved\n \n+refs_are_equal() {\n+\tr1=$(git rev-parse $1) &&\n+\tr2=$(git rev-parse $2) &&\n+\ttest $r1 = $r2\n+}\n+\n check_changes () {\n-\ttest \"$(git rev-parse HEAD)\" = \"$1\" &&\n+\trefs_are_equal HEAD $1 &&\n \tgit diff | git diff .diff_expect - &&\n \tgit diff --cached | git diff .cached_expect - &&\n \tfor FILE in *\n@@ -56,7 +65,7 @@ test_expect_success 'giving a non existing revision should fail' '\n \t! git reset --mixed aaaaaa &&\n \t! git reset --soft aaaaaa &&\n \t! git reset --hard aaaaaa &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tcheck_changes modify2\n '\n \n test_expect_success \\\n@@ -65,7 +74,7 @@ test_expect_success \\\n \t! git reset --hard -- first &&\n \t! git reset --soft HEAD^ -- first &&\n \t! git reset --hard HEAD^ -- first &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tcheck_changes modify2\n '\n \n test_expect_success 'giving unrecognized options should fail' '\n@@ -77,7 +86,7 @@ test_expect_success 'giving unrecognized options should fail' '\n \t! git reset --soft -o &&\n \t! git reset --hard --other &&\n \t! git reset --hard -o &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tcheck_changes modify2\n '\n \n test_expect_success \\\n@@ -101,7 +110,7 @@ test_expect_success \\\n \n \tgit checkout master &&\n \tgit branch -D branch1 branch2 &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tcheck_changes modify2\n '\n \n test_expect_success \\\n@@ -124,27 +133,19 @@ test_expect_success \\\n \n \tgit checkout master &&\n \tgit branch -D branch3 branch4 &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tcheck_changes modify2\n '\n \n test_expect_success \\\n \t'resetting to HEAD with no changes should succeed and do nothing' '\n-\tgit reset --hard &&\n-\t\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n-\tgit reset --hard HEAD &&\n-\t\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n-\tgit reset --soft &&\n-\t\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n-\tgit reset --soft HEAD &&\n-\t\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n-\tgit reset --mixed &&\n-\t\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n-\tgit reset --mixed HEAD &&\n-\t\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n-\tgit reset &&\n-\t\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n-\tgit reset HEAD &&\n-\t\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tgit reset --hard && check_changes modify2\n+\tgit reset --hard HEAD && check_changes modify2\n+\tgit reset --soft && check_changes modify2\n+\tgit reset --soft HEAD && check_changes modify2\n+\tgit reset --mixed && check_changes modify2\n+\tgit reset --mixed HEAD && check_changes modify2\n+\tgit reset && check_changes modify2\n+\tgit reset HEAD && check_changes modify2\n '\n \n >.diff_expect\n@@ -165,9 +166,8 @@ secondfile:\n EOF\n test_expect_success '--soft reset only should show changes in diff --cached' '\n \tgit reset --soft HEAD^ &&\n-\tcheck_changes d1a4bc3abce4829628ae2dcb0d60ef3d1a78b1c4 &&\n-\ttest \"$(git rev-parse ORIG_HEAD)\" = \\\n-\t\t\t3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tcheck_changes moves &&\n+\trefs_are_equal ORIG_HEAD modify2\n '\n \n >.diff_expect\n@@ -182,9 +182,9 @@ test_expect_success \\\n \t'changing files and redo the last commit should succeed' '\n \techo \"3rd line 2nd file\" >>secondfile &&\n \tgit commit -a -C ORIG_HEAD &&\n-\tcheck_changes 3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d &&\n-\ttest \"$(git rev-parse ORIG_HEAD)\" = \\\n-\t\t\t3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tgit tag addline1\n+\tcheck_changes addline1 &&\n+\trefs_are_equal ORIG_HEAD modify2\n '\n \n >.diff_expect\n@@ -199,9 +199,8 @@ EOF\n test_expect_success \\\n \t'--hard reset should change the files and undo commits permanently' '\n \tgit reset --hard HEAD~2 &&\n-\tcheck_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&\n-\ttest \"$(git rev-parse ORIG_HEAD)\" = \\\n-\t\t\t3d3b7be011a58ca0c179ae45d94e6c83c0b0cd0d\n+\tcheck_changes modify1 &&\n+\trefs_are_equal ORIG_HEAD addline1\n '\n \n >.diff_expect\n@@ -243,7 +242,7 @@ test_expect_success \\\n \techo \"1st line 2nd file\" >secondfile &&\n \techo \"2nd line 2nd file\" >>secondfile &&\n \tgit add secondfile &&\n-\tcheck_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e\n+\tcheck_changes modify1\n '\n \n cat >.diff_expect <<EOF\n@@ -271,9 +270,8 @@ secondfile:\n EOF\n test_expect_success '--mixed reset to HEAD should unadd the files' '\n \tgit reset &&\n-\tcheck_changes ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&\n-\ttest \"$(git rev-parse ORIG_HEAD)\" = \\\n-\t\t\tddaefe00f1da16864591c61fdc7adb5d7cd6b74e\n+\tcheck_changes modify1 &&\n+\trefs_are_equal ORIG_HEAD modify1\n '\n \n >.diff_expect\n@@ -285,7 +283,7 @@ secondfile:\n EOF\n test_expect_success 'redoing the last two commits should succeed' '\n \tgit add secondfile &&\n-\tgit reset --hard ddaefe00f1da16864591c61fdc7adb5d7cd6b74e &&\n+\tgit reset --hard modify1 &&\n \n \tgit rm first &&\n \tgit mv second secondfile &&\n@@ -294,7 +292,7 @@ test_expect_success 'redoing the last two commits should succeed' '\n \techo \"1st line 2nd file\" >secondfile &&\n \techo \"2nd line 2nd file\" >>secondfile &&\n \tgit commit -a -m \"modify 2nd file\" &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tcheck_changes modify2\n '\n \n >.diff_expect\n@@ -316,10 +314,11 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '\n \tgit checkout branch2 &&\n \techo \"3rd line in branch2\" >>secondfile &&\n \tgit commit -a -m \"change in branch2\" &&\n+\tgit tag addline2 &&\n \n \t! git pull . branch1 &&\n \tgit reset --hard &&\n-\tcheck_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb\n+\tcheck_changes addline2\n '\n \n >.diff_expect\n@@ -332,15 +331,15 @@ EOF\n test_expect_success \\\n \t'--hard reset to ORIG_HEAD should clear a fast-forward merge' '\n \tgit reset --hard HEAD^ &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&\n+\tcheck_changes modify2 &&\n \n \tgit pull . branch1 &&\n \tgit reset --hard ORIG_HEAD &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc &&\n+\tcheck_changes modify2 &&\n \n \tgit checkout master &&\n \tgit branch -D branch1 branch2 &&\n-\tcheck_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc\n+\tcheck_changes modify2\n '\n \n cat > expect << EOF\n-- \n1.5.3.1\n\n"},{"id":"53062","messageId":"7v7imsaog7.fsf@gitster.siamese.dyndns.org","threadId":"9848","inReplyTo":"1b46aba20709141501l6f0f7440hd22b2bd6c4838a0b@mail.gmail.com","subject":"Re: [PATCH] Add tests for documented features of \"git reset\".","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-14T22:10:00Z","receivedAt":"2007-09-14T22:10:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Carlos Rica\" <jasampler@gmail.com> writes:\n\n> 2007/9/11, Junio C Hamano <gitster@pobox.com>:\n>> I also suspect this would not pass on CRLF boxes.\n>\n> I finally removed the hardcoded object IDs (patch attached,\n> to be applied on top of the previous patch).\n>\n> But I don't know what to fix for making the test to pass\n> in CRLF boxes.\n\nThe blobs created by the test script would be different on CRLF\nboxes, and exact object IDs hardcoded in your test would not\nmatch.  That was the only thing I meant.\n\nBut now you bring it up, I guess the expected output may not\nmatch as well.  Hmmm..\n\nAnyway, thanks for the update.\n"}]}