#!/bin/sh global test_description := ''reflog walk shows repeated commits again'' source ./test-lib.sh test_expect_success 'setup commits' ' test_tick && echo content >file && git add file && git commit -m one && git tag one && echo content >>file && git add file && git commit -m two && git tag two ' test_expect_success 'setup reflog with alternating commits' ' git checkout -b topic && git reset one && git reset two && git reset one && git reset two ' test_expect_success 'reflog shows all entries' ' cat >expect <<-\EOF && topic@{0} reset: moving to two topic@{1} reset: moving to one topic@{2} reset: moving to two topic@{3} reset: moving to one topic@{4} branch: Created from HEAD EOF git log -g --format="%gd %gs" topic >actual && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"reflog walk shows repeated commits again">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"setup commits">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\techo content >file && git add file && git commit -m one &&\n"> <"\tgit tag one &&\n"> <"\techo content >>file && git add file && git commit -m two &&\n"> <"\tgit tag two\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup reflog with alternating commits">)} { (SQ <"\n"> <"\tgit checkout -b topic &&\n"> <"\tgit reset one &&\n"> <"\tgit reset two &&\n"> <"\tgit reset one &&\n"> <"\tgit reset two\n"> ) } ) (C {(test_expect_success)} {(SQ <"reflog shows all entries">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\t\ttopic@{0} reset: moving to two\n"> <"\t\ttopic@{1} reset: moving to one\n"> <"\t\ttopic@{2} reset: moving to two\n"> <"\t\ttopic@{3} reset: moving to one\n"> <"\t\ttopic@{4} branch: Created from HEAD\n"> <"\tEOF\n"> <"\tgit log -g --format=\"%gd %gs\" topic >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )