{"thread":{"id":"39949","subject":"[PATCH v2 1/2] t/t7509: remove unnecessary manipulation of reflog","startedAt":"2015-07-27T22:57:07Z","lastAt":"2015-07-27T22:57:08Z","messageCount":2,"participants":["David Turner"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"266872","messageId":"1438037829-2642-1-git-send-email-dturner@twopensource.com","threadId":"39949","inReplyTo":null,"subject":"[PATCH v2 1/2] t/t7509: remove unnecessary manipulation of reflog","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2015-07-27T22:57:07Z","receivedAt":"2015-07-27T22:57:07Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"Remove unnecessary reflog manipulation.  The test does not rely in any\nway on this reflog manipulation, and the case that the test\nexercises is unrelated to reflogs.\n\nSigned-off-by: David Turner <dturner@twopensource.com>\n---\nThis version of the patch series addresses Junio's comments on v1.\n\n---\n t/t7509-commit.sh | 13 -------------\n 1 file changed, 13 deletions(-)\n\ndiff --git a/t/t7509-commit.sh b/t/t7509-commit.sh\nindex 9ac7940..db9774e 100755\n--- a/t/t7509-commit.sh\n+++ b/t/t7509-commit.sh\n@@ -90,22 +90,10 @@ sha1_file() {\n remove_object() {\n \trm -f $(sha1_file \"$*\")\n }\n-no_reflog() {\n-\tcp .git/config .git/config.saved &&\n-\techo \"[core] logallrefupdates = false\" >>.git/config &&\n-\ttest_when_finished \"mv -f .git/config.saved .git/config\" &&\n-\n-\tif test -e .git/logs\n-\tthen\n-\t\tmv .git/logs . &&\n-\t\ttest_when_finished \"mv logs .git/\"\n-\tfi\n-}\n \n test_expect_success '--amend option with empty author' '\n \tgit cat-file commit Initial >tmp &&\n \tsed \"s/author [^<]* </author  </\" tmp >empty-author &&\n-\tno_reflog &&\n \tsha=$(git hash-object -t commit -w empty-author) &&\n \ttest_when_finished \"remove_object $sha\" &&\n \tgit checkout $sha &&\n@@ -119,7 +107,6 @@ test_expect_success '--amend option with empty author' '\n test_expect_success '--amend option with missing author' '\n \tgit cat-file commit Initial >tmp &&\n \tsed \"s/author [^<]* </author </\" tmp >malformed &&\n-\tno_reflog &&\n \tsha=$(git hash-object -t commit -w malformed) &&\n \ttest_when_finished \"remove_object $sha\" &&\n \tgit checkout $sha &&\n-- \n2.0.4.315.gad8727a-twtrsrc\n"},{"id":"266873","messageId":"1438037829-2642-2-git-send-email-dturner@twopensource.com","threadId":"39949","inReplyTo":"1438037829-2642-1-git-send-email-dturner@twopensource.com","subject":"[PATCH v2 2/2] tests: Remove some direct access to .git/logs","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2015-07-27T22:57:08Z","receivedAt":"2015-07-27T22:57:08Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"Alternate refs backends might store reflogs somewhere other than\n.git/logs.  Change most test code that directly accesses .git/logs to\ninstead use git reflog commands.\n\nThere are still a few tests which need direct access to reflogs: to\ncheck reflog permissions, to manually create reflogs from scratch, to\nsave/restore reflogs, to check the format of raw reflog data, and to\nremove not just reflog contents, but the reflogs themselves. All cases\nwhich don't need direct access have been modified.\n\nSigned-off-by: David Turner <dturner@twopensource.com>\n---\n t/t1400-update-ref.sh         |  5 ++---\n t/t1410-reflog.sh             | 24 ++++++++++++++++--------\n t/t1411-reflog-show.sh        |  2 +-\n t/t1503-rev-parse-verify.sh   |  9 +++------\n t/t3200-branch.sh             | 12 ++++++------\n t/t3210-pack-refs.sh          |  2 +-\n t/t3404-rebase-interactive.sh | 10 +++++-----\n t/t3903-stash.sh              |  2 +-\n t/t5312-prune-corruption.sh   |  2 +-\n t/t6501-freshen-objects.sh    |  2 +-\n 10 files changed, 37 insertions(+), 33 deletions(-)\n\ndiff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\nindex d787bf5..8bf1559 100755\n--- a/t/t1400-update-ref.sh\n+++ b/t/t1400-update-ref.sh\n@@ -155,12 +155,11 @@ test_expect_success \"(not) changed .git/$m\" \"\n '\n rm -f .git/$m\n \n-: a repository with working tree always has reflog these days...\n-: >.git/logs/refs/heads/master\n+rm -f .git/logs/refs/heads/master\n test_expect_success \\\n \t\"create $m (logged by touch)\" \\\n \t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n-\t git update-ref HEAD '\"$A\"' -m \"Initial Creation\" &&\n+\t git update-ref --create-reflog HEAD '\"$A\"' -m \"Initial Creation\" &&\n \t test '\"$A\"' = $(cat .git/'\"$m\"')'\n test_expect_success \\\n \t\"update $m (logged by touch)\" \\\ndiff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh\nindex 779d4e3..b79049f 100755\n--- a/t/t1410-reflog.sh\n+++ b/t/t1410-reflog.sh\n@@ -100,7 +100,8 @@ test_expect_success setup '\n \n \tcheck_fsck &&\n \n-\ttest_line_count = 4 .git/logs/refs/heads/master\n+\tgit reflog refs/heads/master >output &&\n+\ttest_line_count = 4 output\n '\n \n test_expect_success rewind '\n@@ -116,7 +117,8 @@ test_expect_success rewind '\n \n \tcheck_have A B C D E F G H I J K L &&\n \n-\ttest_line_count = 5 .git/logs/refs/heads/master\n+\tgit reflog refs/heads/master >output &&\n+\ttest_line_count = 5 output\n '\n \n test_expect_success 'corrupt and check' '\n@@ -134,7 +136,8 @@ test_expect_success 'reflog expire --dry-run should not touch reflog' '\n \t\t--stale-fix \\\n \t\t--all &&\n \n-\ttest_line_count = 5 .git/logs/refs/heads/master &&\n+\tgit reflog refs/heads/master >output &&\n+\ttest_line_count = 5 output &&\n \n \tcheck_fsck \"missing blob $F\"\n '\n@@ -147,7 +150,8 @@ test_expect_success 'reflog expire' '\n \t\t--stale-fix \\\n \t\t--all &&\n \n-\ttest_line_count = 2 .git/logs/refs/heads/master &&\n+\tgit reflog refs/heads/master >output &&\n+\ttest_line_count = 2 output &&\n \n \tcheck_fsck \"dangling commit $K\"\n '\n@@ -213,7 +217,8 @@ test_expect_success 'delete' '\n test_expect_success 'rewind2' '\n \n \ttest_tick && git reset --hard HEAD~2 &&\n-\ttest_line_count = 4 .git/logs/refs/heads/master\n+\tgit reflog refs/heads/master >output &&\n+\ttest_line_count = 4 output\n '\n \n test_expect_success '--expire=never' '\n@@ -222,7 +227,8 @@ test_expect_success '--expire=never' '\n \t\t--expire=never \\\n \t\t--expire-unreachable=never \\\n \t\t--all &&\n-\ttest_line_count = 4 .git/logs/refs/heads/master\n+\tgit reflog refs/heads/master >output &&\n+\ttest_line_count = 4 output\n '\n \n test_expect_success 'gc.reflogexpire=never' '\n@@ -230,7 +236,8 @@ test_expect_success 'gc.reflogexpire=never' '\n \tgit config gc.reflogexpire never &&\n \tgit config gc.reflogexpireunreachable never &&\n \tgit reflog expire --verbose --all &&\n-\ttest_line_count = 4 .git/logs/refs/heads/master\n+\tgit reflog refs/heads/master >output &&\n+\ttest_line_count = 4 output\n '\n \n test_expect_success 'gc.reflogexpire=false' '\n@@ -238,7 +245,8 @@ test_expect_success 'gc.reflogexpire=false' '\n \tgit config gc.reflogexpire false &&\n \tgit config gc.reflogexpireunreachable false &&\n \tgit reflog expire --verbose --all &&\n-\ttest_line_count = 4 .git/logs/refs/heads/master &&\n+\tgit reflog refs/heads/master >output &&\n+\ttest_line_count = 4 output &&\n \n \tgit config --unset gc.reflogexpire &&\n \tgit config --unset gc.reflogexpireunreachable\ndiff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh\nindex 6f47c0d..d568b35 100755\n--- a/t/t1411-reflog-show.sh\n+++ b/t/t1411-reflog-show.sh\n@@ -138,7 +138,7 @@ test_expect_success '--date magic does not override explicit @{0} syntax' '\n : >expect\n test_expect_success 'empty reflog file' '\n \tgit branch empty &&\n-\t: >.git/logs/refs/heads/empty &&\n+\tgit reflog expire --expire=all refs/heads/empty &&\n \n \tgit log -g empty >actual &&\n \ttest_cmp expect actual\ndiff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh\nindex 823fe1d..ab27d0d 100755\n--- a/t/t1503-rev-parse-verify.sh\n+++ b/t/t1503-rev-parse-verify.sh\n@@ -85,8 +85,7 @@ test_expect_success 'fails silently when using -q' '\n \n test_expect_success 'fails silently when using -q with deleted reflogs' '\n \tref=$(git rev-parse HEAD) &&\n-\t: >.git/logs/refs/test &&\n-\tgit update-ref -m \"message for refs/test\" refs/test \"$ref\" &&\n+\tgit update-ref --create-reflog -m \"message for refs/test\" refs/test \"$ref\" &&\n \tgit reflog delete --updateref --rewrite refs/test@{0} &&\n \ttest_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 &&\n \ttest_must_be_empty error\n@@ -94,16 +93,14 @@ test_expect_success 'fails silently when using -q with deleted reflogs' '\n \n test_expect_success 'fails silently when using -q with not enough reflogs' '\n \tref=$(git rev-parse HEAD) &&\n-\t: >.git/logs/refs/test2 &&\n-\tgit update-ref -m \"message for refs/test2\" refs/test2 \"$ref\" &&\n+\tgit update-ref --create-reflog -m \"message for refs/test2\" refs/test2 \"$ref\" &&\n \ttest_must_fail git rev-parse -q --verify refs/test2@{999} >error 2>&1 &&\n \ttest_must_be_empty error\n '\n \n test_expect_success 'succeeds silently with -q and reflogs that do not go far back enough in time' '\n \tref=$(git rev-parse HEAD) &&\n-\t: >.git/logs/refs/test3 &&\n-\tgit update-ref -m \"message for refs/test3\" refs/test3 \"$ref\" &&\n+\tgit update-ref --create-reflog -m \"message for refs/test3\" refs/test3 \"$ref\" &&\n \tgit rev-parse -q --verify refs/test3@{1.year.ago} >actual 2>error &&\n \ttest_must_be_empty error &&\n \techo \"$ref\" >expect &&\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex ddea498..cdaf6f6 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -59,7 +59,7 @@ test_expect_success 'git branch -l d/e/f should create a branch and a log' '\n test_expect_success 'git branch -d d/e/f should delete a branch and a log' '\n \tgit branch -d d/e/f &&\n \ttest_path_is_missing .git/refs/heads/d/e/f &&\n-\ttest_path_is_missing .git/logs/refs/heads/d/e/f\n+\ttest_must_fail git reflog exists refs/heads/d/e/f\n '\n \n test_expect_success 'git branch j/k should work after branch j has been deleted' '\n@@ -82,13 +82,13 @@ test_expect_success 'git branch -m dumps usage' '\n test_expect_success 'git branch -m m m/m should work' '\n \tgit branch -l m &&\n \tgit branch -m m m/m &&\n-\ttest_path_is_file .git/logs/refs/heads/m/m\n+\tgit reflog exists refs/heads/m/m\n '\n \n test_expect_success 'git branch -m n/n n should work' '\n \tgit branch -l n/n &&\n \tgit branch -m n/n n &&\n-\ttest_path_is_file .git/logs/refs/heads/n\n+\tgit reflog exists refs/heads/n\n '\n \n test_expect_success 'git branch -m o/o o should fail when o/p exists' '\n@@ -267,12 +267,12 @@ git config branch.s/s.dummy Hello\n \n test_expect_success 'git branch -m s/s s should work when s/t is deleted' '\n \tgit branch -l s/s &&\n-\ttest_path_is_file .git/logs/refs/heads/s/s &&\n+\tgit reflog exists refs/heads/s/s &&\n \tgit branch -l s/t &&\n-\ttest_path_is_file .git/logs/refs/heads/s/t &&\n+\tgit reflog exists refs/heads/s/t &&\n \tgit branch -d s/t &&\n \tgit branch -m s/s s &&\n-\ttest_path_is_file .git/logs/refs/heads/s\n+\tgit reflog exists refs/heads/s\n '\n \n test_expect_success 'config information was renamed, too' '\ndiff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh\nindex 8aae98d..7b5b6d4 100755\n--- a/t/t3210-pack-refs.sh\n+++ b/t/t3210-pack-refs.sh\n@@ -169,7 +169,7 @@ test_expect_success 'create packed foo/bar/baz branch' '\n \tgit branch foo/bar/baz &&\n \tgit pack-refs --all --prune &&\n \ttest_path_is_missing .git/refs/heads/foo/bar/baz &&\n-\ttest_path_is_missing .git/logs/refs/heads/foo/bar/baz\n+\ttest_must_fail git reflog exists refs/heads/foo/bar/baz\n '\n \n test_expect_success 'notice d/f conflict with existing directory' '\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 467e6c1..4c0675a 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -961,13 +961,13 @@ test_expect_success 'rebase -i produces readable reflog' '\n \tset_fake_editor &&\n \tgit rebase -i --onto I F branch-reflog-test &&\n \tcat >expect <<-\\EOF &&\n-\trebase -i (start): checkout I\n-\trebase -i (pick): G\n-\trebase -i (pick): H\n \trebase -i (finish): returning to refs/heads/branch-reflog-test\n+\trebase -i (pick): H\n+\trebase -i (pick): G\n+\trebase -i (start): checkout I\n \tEOF\n-\ttail -n 4 .git/logs/HEAD |\n-\tsed -e \"s/.*\t//\" >actual &&\n+\tgit reflog -n4 HEAD |\n+\tsed \"s/[^:]*: //\" >actual &&\n \ttest_cmp expect actual\n '\n \ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex f5f18b7..2142c1f 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -672,7 +672,7 @@ test_expect_success 'store updates stash ref and reflog' '\n \t! grep quux bazzy &&\n \tgit stash store -m quuxery $STASH_ID &&\n \ttest $(cat .git/refs/stash) = $STASH_ID &&\n-\tgrep $STASH_ID .git/logs/refs/stash &&\n+\tgit reflog --format=%H stash| grep $STASH_ID &&\n \tgit stash pop &&\n \tgrep quux bazzy\n '\ndiff --git a/t/t5312-prune-corruption.sh b/t/t5312-prune-corruption.sh\nindex 8e98b44..da9d599 100755\n--- a/t/t5312-prune-corruption.sh\n+++ b/t/t5312-prune-corruption.sh\n@@ -12,7 +12,7 @@ delete objects that cannot be recovered.\n \n test_expect_success 'disable reflogs' '\n \tgit config core.logallrefupdates false &&\n-\trm -rf .git/logs\n+\tgit reflog expire --expire=all --all\n '\n \n test_expect_success 'create history reachable only from a bogus-named ref' '\ndiff --git a/t/t6501-freshen-objects.sh b/t/t6501-freshen-objects.sh\nindex 2adf825..cf076dc 100755\n--- a/t/t6501-freshen-objects.sh\n+++ b/t/t6501-freshen-objects.sh\n@@ -56,7 +56,7 @@ for repack in '' true; do\n \n \ttest_expect_success \"disable reflogs ($title)\" '\n \t\tgit config core.logallrefupdates false &&\n-\t\trm -rf .git/logs\n+\t\tgit reflog expire --expire=all --all\n \t'\n \n \ttest_expect_success \"setup basic history ($title)\" '\n-- \n2.0.4.315.gad8727a-twtrsrc\n"}]}