git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Alexey Shumkin <alex.crezoff@gmail.com>
To: git@vger.kernel.org
Cc: Alexey Shumkin <Alex.Crezoff@gmail.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs
Date: Thu, 24 Jan 2013 13:10:25 +0400	[thread overview]
Message-ID: <cee3610fde1626c2854eb5b821529ab22a06e4bf.1359018188.git.Alex.Crezoff@gmail.com> (raw)
In-Reply-To: <cover.1359018188.git.Alex.Crezoff@gmail.com>
In-Reply-To: <cover.1359018188.git.Alex.Crezoff@gmail.com>

The expected SHA-1 digests are always available in variables.  Use
them instead of hardcoding.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
---
 t/t6006-rev-list-format.sh | 130 +++++++++++++++++++++++++--------------------
 1 file changed, 72 insertions(+), 58 deletions(-)

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index f94f0c4..c248509 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -6,8 +6,19 @@ test_description='git rev-list --pretty=format test'
 
 test_tick
 test_expect_success 'setup' '
-touch foo && git add foo && git commit -m "added foo" &&
-  echo changed >foo && git commit -a -m "changed foo"
+	touch foo &&
+	git add foo &&
+	git commit -m "added foo" &&
+	head1=$(git rev-parse --verify HEAD) &&
+	head1_7=$(echo $head1 | cut -c1-7) &&
+	echo changed >foo &&
+	git commit -a -m "changed foo" &&
+	head2=$(git rev-parse --verify HEAD) &&
+	head2_7=$(echo $head2 | cut -c1-7) &&
+	head2_parent=$(git cat-file -p HEAD | grep parent | cut -f 2 -d" ") &&
+	head2_parent_7=$(echo $head2_parent | cut -c1-7) &&
+	tree2=$(git cat-file -p HEAD | grep tree | cut -f 2 -d" ") &&
+	tree2_7=$(echo $tree2 | cut -c1-7)
 '
 
 # usage: test_format name format_string <expected_output
@@ -19,49 +30,49 @@ test_cmp expect.$1 output.$1
 "
 }
 
-test_format percent %%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format percent %%h <<EOF
+commit $head2
 %h
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 %h
 EOF
 
-test_format hash %H%n%h <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-131a310eb913d107dd3c09a65d1651175898735d
-131a310
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
+test_format hash %H%n%h <<EOF
+commit $head2
+$head2
+$head2_7
+commit $head1
+$head1
+$head1_7
 EOF
 
-test_format tree %T%n%t <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-fe722612f26da5064c32ca3843aa154bdb0b08a0
-fe72261
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format tree %T%n%t <<EOF
+commit $head2
+$tree2
+$tree2_7
+commit $head1
 4d5fcadc293a348e88f777dc0920f11e7d71441c
 4d5fcad
 EOF
 
-test_format parents %P%n%p <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format parents %P%n%p <<EOF
+commit $head2
+$head1
+$head2_parent_7
+commit $head1
 
 
 EOF
 
 # we don't test relative here
-test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format author %an%n%ae%n%ad%n%aD%n%at <<EOF
+commit $head2
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 A U Thor
 author@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -69,14 +80,14 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<EOF
+commit $head2
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
 Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 C O Mitter
 committer@example.com
 Thu Apr 7 15:13:13 2005 -0700
@@ -84,21 +95,21 @@ Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format encoding %e <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format encoding %e <<EOF
+commit $head2
+commit $head1
 EOF
 
-test_format subject %s <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format subject %s <<EOF
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format body %b <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+test_format body %b <<EOF
+commit $head2
+commit $head1
 EOF
 
 test_format raw-body %B <<'EOF'
@@ -110,17 +121,17 @@ added foo
 
 EOF
 
-test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<EOF
+commit $head2
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[31mfoo^[[32mbar^[[34mbaz^[[mxyzzy
 EOF
 
-test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<'EOF'
-commit 131a310eb913d107dd3c09a65d1651175898735d
+test_format advanced-colors '%C(red yellow bold)foo%C(reset)' <<EOF
+commit $head2
 ^[[1;31;43mfoo^[[m
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 ^[[1;31;43mfoo^[[m
 EOF
 
@@ -131,39 +142,42 @@ This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 EOF
+
 test_expect_success 'setup complex body' '
-git config i18n.commitencoding iso8859-1 &&
-  echo change2 >foo && git commit -a -F commit-msg
+	git config i18n.commitencoding iso8859-1 &&
+	echo change2 >foo && git commit -a -F commit-msg &&
+	head3=$(git rev-parse --verify HEAD) &&
+	head3_7=$(echo $head3 | cut -c1-7)
 '
 
-test_format complex-encoding %e <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-encoding %e <<EOF
+commit $head3
 iso8859-1
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
-test_format complex-subject %s <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-subject %s <<EOF
+commit $head3
 Test printing of complex bodies
-commit 131a310eb913d107dd3c09a65d1651175898735d
+commit $head2
 changed foo
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head1
 added foo
 EOF
 
-test_format complex-body %b <<'EOF'
-commit f58db70b055c5718631e5c61528b28b12090cdea
+test_format complex-body %b <<EOF
+commit $head3
 This commit message is much longer than the others,
 and it will be encoded in iso8859-1. We should therefore
 include an iso8859 character: ¡bueno!
 
-commit 131a310eb913d107dd3c09a65d1651175898735d
-commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+commit $head2
+commit $head1
 EOF
 
 test_expect_success '%x00 shows NUL' '
-	echo  >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+	echo  >expect commit $head3 &&
 	echo >>expect fooQbar &&
 	git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
 	nul_to_q <actual.nul >actual &&
-- 
1.8.1.1.10.g9255f3f

  parent reply	other threads:[~2013-01-24  9:11 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-22  7:06 git log --oneline and git log --pretty=format... give differrent outputs Shumkin Alexey
2011-07-22  7:53 ` Alexey Shumkin
2011-07-25 10:31   ` [PATCH] pretty: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2011-07-25 10:31     ` Alexey Shumkin
2011-07-25 19:45       ` Junio C Hamano
2011-07-26 13:18         ` Alexey Shumkin
2011-09-09  8:43         ` [PATCH v2] " Alexey Shumkin
2011-09-09  8:43           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-09  8:43           ` [PATCH 2/2] pretty: " Alexey Shumkin
2011-09-09  8:53         ` [PATCH v2] " Alexey Shumkin
2011-09-09  8:53           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-09 22:54             ` Junio C Hamano
2011-09-20  8:20               ` [PATCH v3 0/2] pretty: " Alexey Shumkin
2011-09-20  8:21               ` [PATCH v3 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-20 19:12                 ` Junio C Hamano
2011-09-20 20:46                   ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
2013-06-20 20:10                         ` Junio C Hamano
2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
2013-06-25 19:28                           ` Junio C Hamano
2013-06-26  7:37                             ` Alexey Shumkin
2013-06-26 14:24                               ` Junio C Hamano
2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
2013-06-26 16:19                             ` Junio C Hamano
2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
2013-07-02 19:41                               ` Junio C Hamano
2013-07-03 20:03                                 ` Alexey Shumkin
2013-07-03 20:06                                   ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 " Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
2013-07-05 18:38                                   ` Junio C Hamano
2013-07-05 18:45                                     ` Junio C Hamano
2013-07-05 12:01                                 ` [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed` Alexey Shumkin
2013-07-04 12:45                               ` [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
2013-07-05  6:47                                 ` Junio C Hamano
2013-07-05  8:00                                   ` Alexey Shumkin
2013-07-05  8:11                                     ` Junio C Hamano
2013-07-05  8:42                                       ` Alexey Shumkin
2013-07-05  8:56                                         ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
2013-07-05  7:07                                 ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable Alexey Shumkin
2013-07-05  6:45                                 ` Junio C Hamano
2013-07-05  8:13                                   ` Alexey Shumkin
2013-07-05  8:44                                     ` Junio C Hamano
2013-07-05  8:51                                       ` Alexey Shumkin
2013-07-05  8:58                                         ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set Alexey Shumkin
2013-07-05  6:52                                 ` Junio C Hamano
2013-07-05  7:04                                 ` Junio C Hamano
2013-07-05  7:46                                   ` Alexey Shumkin
2013-07-05  8:09                                     ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 5/5] t4205: avoid using `sed` Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 2/5] t7102 (reset): " Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-07-02  6:46                               ` Johannes Sixt
2013-07-01 23:19                             ` [PATCH v8 5/5] pretty: " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 2/5] t7102 (reset): " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-07-01  7:00                             ` Johannes Sixt
2013-07-01 22:50                               ` Alexey Shumkin
2013-07-02  7:22                                 ` Johannes Sixt
2013-07-03 20:20                                   ` Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 5/5] pretty: " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 2/5] t7102 (reset): " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 5/5] pretty: " Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-20 20:38                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 2/5] t7102 (reset): " Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-20 20:38                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2013-06-20 20:23                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 5/5] pretty: " Alexey Shumkin
2013-06-20 20:37                         ` Junio C Hamano
2013-01-24  9:10                     ` Alexey Shumkin [this message]
2013-01-24 20:29                       ` [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Junio C Hamano
2013-01-25  9:20                         ` Alexey Shumkin
2013-01-25 11:06                         ` Alexey Shumkin
2013-01-25 15:16                           ` Junio C Hamano
2013-01-25 15:27                             ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 2/4] t7102 (reset): refactoring: " Alexey Shumkin
2013-01-24 20:30                       ` Junio C Hamano
2013-01-25  9:08                         ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2013-01-24 20:44                       ` Junio C Hamano
2013-01-25  9:07                         ` Alexey Shumkin
2013-01-24 21:02                       ` Junio C Hamano
2013-01-25  9:01                         ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 4/4] pretty: " Alexey Shumkin
2011-09-20  8:21               ` [PATCH v3 2/2] " Alexey Shumkin
2011-09-09  8:53           ` [PATCH " Alexey Shumkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cee3610fde1626c2854eb5b821529ab22a06e4bf.1359018188.git.Alex.Crezoff@gmail.com \
    --to=alex.crezoff@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).