From: Phillip Wood <phillip.wood@talktalk.net> To: Git Mailing List <git@vger.kernel.org> Cc: Junio C Hamano <gitster@pobox.com>, "Brian M. Carlson" <sandals@crustytoothpaste.net>, Eric Sunshine <sunshine@sunshineco.com>, Phillip Wood <phillip.wood@dunelm.org.uk> Subject: [PATCH v4 4/9] t3701: don't hard code sha1 hash values Date: Thu, 1 Mar 2018 10:50:58 +0000 Message-ID: <20180301105103.24268-5-phillip.wood@talktalk.net> (raw) In-Reply-To: <20180301105103.24268-1-phillip.wood@talktalk.net> From: Phillip Wood <phillip.wood@dunelm.org.uk> Use a filter when comparing diffs to fix the value of non-zero hashes in diff index lines so we're not hard coding sha1 hash values in the expected output. This makes it easier to change the expected output if a test is edited as we don't need to worry about the exact hash value and means the tests will work when the hash algorithm is transitioned away from sha1. Thanks-to: Junio C Hamano <gitster@pobox.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> --- Notes: changes since v3: - fix zero hash values to seven digits changes since v2: - fix hash values in index lines rather than removing the line - reworded commit message t/t3701-add-interactive.sh | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 836ce346ed..f95714230b 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -10,6 +10,19 @@ then test_done fi +diff_cmp () { + for x + do + sed -e '/^index/s/[0-9a-f]*[1-9a-f][0-9a-f]*\.\./1234567../' \ + -e '/^index/s/\.\.[0-9a-f]*[1-9a-f][0-9a-f]*/..9abcdef/' \ + -e '/^index/s/ 00*\.\./ 0000000../' \ + -e '/^index/s/\.\.00*$/..0000000/' \ + -e '/^index/s/\.\.00* /..0000000 /' \ + "$x" >"$x.filtered" + done + test_cmp "$1.filtered" "$2.filtered" +} + test_expect_success 'setup (initial)' ' echo content >file && git add file && @@ -35,7 +48,7 @@ test_expect_success 'setup expected' ' test_expect_success 'diff works (initial)' ' (echo d; echo 1) | git add -i >output && sed -ne "/new file/,/content/p" <output >diff && - test_cmp expected diff + diff_cmp expected diff ' test_expect_success 'revert works (initial)' ' git add file && @@ -72,7 +85,7 @@ test_expect_success 'setup expected' ' test_expect_success 'diff works (commit)' ' (echo d; echo 1) | git add -i >output && sed -ne "/^index/,/content/p" <output >diff && - test_cmp expected diff + diff_cmp expected diff ' test_expect_success 'revert works (commit)' ' git add file && @@ -91,7 +104,7 @@ test_expect_success 'dummy edit works' ' test_set_editor : && (echo e; echo a) | git add -p && git diff > diff && - test_cmp expected diff + diff_cmp expected diff ' test_expect_success 'setup patch' ' @@ -159,7 +172,7 @@ test_expect_success 'setup expected' ' test_expect_success 'real edit works' ' (echo e; echo n; echo d) | git add -p && git diff >output && - test_cmp expected output + diff_cmp expected output ' test_expect_success 'skip files similarly as commit -a' ' @@ -171,7 +184,7 @@ test_expect_success 'skip files similarly as commit -a' ' git reset && git commit -am commit && git diff >expected && - test_cmp expected output && + diff_cmp expected output && git reset --hard HEAD^ ' rm -f .gitignore @@ -248,7 +261,7 @@ test_expect_success 'add first line works' ' git apply patch && (echo s; echo y; echo y) | git add -p file && git diff --cached > diff && - test_cmp expected diff + diff_cmp expected diff ' test_expect_success 'setup expected' ' @@ -271,7 +284,7 @@ test_expect_success 'deleting a non-empty file' ' rm non-empty && echo y | git add -p non-empty && git diff --cached >diff && - test_cmp expected diff + diff_cmp expected diff ' test_expect_success 'setup expected' ' @@ -290,7 +303,7 @@ test_expect_success 'deleting an empty file' ' rm empty && echo y | git add -p empty && git diff --cached >diff && - test_cmp expected diff + diff_cmp expected diff ' test_expect_success 'split hunk setup' ' @@ -355,7 +368,7 @@ test_expect_success 'patch mode ignores unmerged entries' ' +changed EOF git diff --cached >diff && - test_cmp expected diff + diff_cmp expected diff ' test_expect_success TTY 'diffs can be colorized' ' @@ -384,7 +397,7 @@ test_expect_success 'patch-mode via -i prompts for files' ' echo test >expect && git diff --cached --name-only >actual && - test_cmp expect actual + diff_cmp expect actual ' test_expect_success 'add -p handles globs' ' -- 2.16.1
next prev parent reply index Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-02-13 10:44 [PATCH 0/4] Correct offsets of hunks when one is skipped Phillip Wood 2018-02-13 10:44 ` [PATCH 1/4] add -i: add function to format hunk header Phillip Wood 2018-02-13 10:44 ` [PATCH 2/4] t3701: add failing test for pathological context lines Phillip Wood 2018-02-13 20:35 ` Junio C Hamano 2018-02-13 10:44 ` [PATCH 3/4] add -p: Adjust offsets of subsequent hunks when one is skipped Phillip Wood 2018-02-13 10:44 ` [PATCH 4/4] add -p: calculate offset delta for edited patches Phillip Wood 2018-02-13 23:56 ` [PATCH 0/4] Correct offsets of hunks when one is skipped brian m. carlson 2018-02-19 13:01 ` Phillip Wood 2018-02-19 11:29 ` [PATCH v2 0/9] " Phillip Wood 2018-02-19 11:29 ` [PATCH v2 1/9] add -i: add function to format hunk header Phillip Wood 2018-02-20 18:21 ` Junio C Hamano 2018-02-19 11:29 ` [PATCH v2 2/9] t3701: indent here documents Phillip Wood 2018-02-19 18:36 ` Eric Sunshine 2018-02-19 11:29 ` [PATCH v2 3/9] t3701: use test_write_lines and write_script Phillip Wood 2018-02-19 18:47 ` Eric Sunshine 2018-02-20 17:19 ` Junio C Hamano 2018-02-21 11:26 ` Phillip Wood 2018-02-19 11:29 ` [PATCH v2 4/9] t3701: don't hard code sha1 hash values Phillip Wood 2018-02-19 18:52 ` Eric Sunshine 2018-02-20 17:39 ` Junio C Hamano 2018-02-21 11:42 ` Phillip Wood 2018-02-21 16:58 ` Junio C Hamano 2018-02-19 11:29 ` [PATCH v2 5/9] t3701: add failing test for pathological context lines Phillip Wood 2018-02-21 11:28 ` Phillip Wood 2018-02-19 11:29 ` [PATCH v2 6/9] add -p: Adjust offsets of subsequent hunks when one is skipped Phillip Wood 2018-02-19 11:29 ` [PATCH v2 7/9] add -p: calculate offset delta for edited patches Phillip Wood 2018-02-19 11:29 ` [PATCH v2 8/9] add -p: fix counting when splitting and coalescing Phillip Wood 2018-02-19 11:29 ` [PATCH v2 9/9] add -p: don't rely on apply's '--recount' option Phillip Wood 2018-02-20 18:50 ` Junio C Hamano 2018-02-27 11:03 ` [PATCH v3 0/9] Correct offsets of hunks when one is skipped Phillip Wood 2018-02-27 11:03 ` [PATCH v3 1/9] add -i: add function to format hunk header Phillip Wood 2018-02-27 11:03 ` [PATCH v3 2/9] t3701: indent here documents Phillip Wood 2018-02-27 22:35 ` Junio C Hamano 2018-02-28 11:00 ` Phillip Wood 2018-02-28 15:37 ` Junio C Hamano 2018-03-01 10:57 ` Phillip Wood 2018-03-01 15:58 ` Junio C Hamano 2018-02-27 11:03 ` [PATCH v3 3/9] t3701: use test_write_lines and write_script Phillip Wood 2018-02-27 11:03 ` [PATCH v3 4/9] t3701: don't hard code sha1 hash values Phillip Wood 2018-02-27 22:42 ` Junio C Hamano 2018-02-28 11:03 ` Phillip Wood 2018-02-28 11:10 ` Phillip Wood 2018-02-27 11:04 ` [PATCH v3 5/9] t3701: add failing test for pathological context lines Phillip Wood 2018-02-27 11:04 ` [PATCH v3 6/9] add -p: Adjust offsets of subsequent hunks when one is skipped Phillip Wood 2018-02-27 11:04 ` [PATCH v3 7/9] add -p: calculate offset delta for edited patches Phillip Wood 2018-02-27 11:04 ` [PATCH v3 8/9] add -p: fix counting when splitting and coalescing Phillip Wood 2018-02-27 11:04 ` [PATCH v3 9/9] add -p: don't rely on apply's '--recount' option Phillip Wood 2018-03-01 10:50 ` [PATCH v4 0/9] Correct offsets of hunks when one is skipped Phillip Wood 2018-03-01 10:50 ` [PATCH v4 1/9] add -i: add function to format hunk header Phillip Wood 2018-03-01 10:50 ` [PATCH v4 2/9] t3701: indent here documents Phillip Wood 2018-03-01 10:50 ` [PATCH v4 3/9] t3701: use test_write_lines and write_script Phillip Wood 2018-03-01 10:50 ` Phillip Wood [this message] 2018-03-02 15:55 ` [PATCH v4 4/9] t3701: don't hard code sha1 hash values SZEDER Gábor 2018-03-02 16:09 ` Junio C Hamano 2018-03-05 10:59 ` Phillip Wood 2018-03-05 12:32 ` SZEDER Gábor 2018-03-01 10:50 ` [PATCH v4 5/9] t3701: add failing test for pathological context lines Phillip Wood 2018-03-01 10:51 ` [PATCH v4 6/9] add -p: adjust offsets of subsequent hunks when one is skipped Phillip Wood 2018-03-01 10:51 ` [PATCH v4 7/9] add -p: calculate offset delta for edited patches Phillip Wood 2018-03-01 20:14 ` Junio C Hamano 2018-03-02 10:36 ` Phillip Wood 2018-03-01 10:51 ` [PATCH v4 8/9] add -p: fix counting when splitting and coalescing Phillip Wood 2018-03-01 20:29 ` Junio C Hamano 2018-03-02 10:48 ` Phillip Wood 2018-03-01 10:51 ` [PATCH v4 9/9] add -p: don't rely on apply's '--recount' option Phillip Wood 2018-03-01 20:30 ` Junio C Hamano 2018-03-02 10:49 ` Phillip Wood 2018-03-05 10:56 ` [PATCH v5 0/9] Correct offsets of hunks when one is skipped Phillip Wood 2018-03-05 10:56 ` [PATCH v5 1/9] add -i: add function to format hunk header Phillip Wood 2018-03-05 10:56 ` [PATCH v5 2/9] t3701: indent here documents Phillip Wood 2018-03-05 10:56 ` [PATCH v5 3/9] t3701: use test_write_lines and write_script Phillip Wood 2018-03-05 10:56 ` [PATCH v5 4/9] t3701: don't hard code sha1 hash values Phillip Wood 2018-03-05 10:56 ` [PATCH v5 5/9] t3701: add failing test for pathological context lines Phillip Wood 2018-03-05 10:56 ` [PATCH v5 6/9] add -p: adjust offsets of subsequent hunks when one is skipped Phillip Wood 2018-03-05 10:56 ` [PATCH v5 7/9] add -p: calculate offset delta for edited patches Phillip Wood 2018-03-05 10:56 ` [PATCH v5 8/9] add -p: fix counting when splitting and coalescing Phillip Wood 2018-03-05 10:56 ` [PATCH v5 9/9] add -p: don't rely on apply's '--recount' option Phillip Wood 2018-03-05 18:50 ` [PATCH v5 0/9] Correct offsets of hunks when one is skipped Junio C Hamano 2018-03-06 10:25 ` Phillip Wood
Reply instructions: You may reply publically 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=20180301105103.24268-5-phillip.wood@talktalk.net \ --to=phillip.wood@talktalk.net \ --cc=git@vger.kernel.org \ --cc=gitster@pobox.com \ --cc=phillip.wood@dunelm.org.uk \ --cc=sandals@crustytoothpaste.net \ --cc=sunshine@sunshineco.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
git@vger.kernel.org list mirror (unofficial, one of many) Archives are clonable: git clone --mirror https://public-inbox.org/git git clone --mirror http://ou63pmih66umazou.onion/git git clone --mirror http://czquwvybam4bgbro.onion/git git clone --mirror http://hjrcffqmbrq6wope.onion/git Example config snippet for mirrors Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.version-control.git nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git nntp://news.gmane.org/gmane.comp.version-control.git note: .onion URLs require Tor: https://www.torproject.org/ AGPL code for this site: git clone https://public-inbox.org/public-inbox.git