Jeff King | cd43712 | 2009-03-20 02:00:43 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Test reflog display routines' |
| 4 | . ./test-lib.sh |
| 5 | |
| 6 | test_expect_success 'setup' ' |
| 7 | echo content >file && |
| 8 | git add file && |
| 9 | test_tick && |
| 10 | git commit -m one |
| 11 | ' |
| 12 | |
| 13 | cat >expect <<'EOF' |
| 14 | Reflog: HEAD@{0} (C O Mitter <committer@example.com>) |
| 15 | Reflog message: commit (initial): one |
| 16 | EOF |
| 17 | test_expect_success 'log -g shows reflog headers' ' |
| 18 | git log -g -1 >tmp && |
| 19 | grep ^Reflog <tmp >actual && |
| 20 | test_cmp expect actual |
| 21 | ' |
| 22 | |
| 23 | cat >expect <<'EOF' |
| 24 | e46513e HEAD@{0}: commit (initial): one |
| 25 | EOF |
| 26 | test_expect_success 'oneline reflog format' ' |
| 27 | git log -g -1 --oneline >actual && |
| 28 | test_cmp expect actual |
| 29 | ' |
| 30 | |
Michael J Gruber | 21d2616 | 2011-04-01 11:20:32 +0200 | [diff] [blame] | 31 | test_expect_success 'reflog default format' ' |
| 32 | git reflog -1 >actual && |
| 33 | test_cmp expect actual |
| 34 | ' |
| 35 | |
| 36 | cat >expect <<'EOF' |
| 37 | commit e46513e |
| 38 | Reflog: HEAD@{0} (C O Mitter <committer@example.com>) |
| 39 | Reflog message: commit (initial): one |
| 40 | Author: A U Thor <author@example.com> |
| 41 | |
| 42 | one |
| 43 | EOF |
Michael J Gruber | 4b56cf5 | 2011-04-01 11:20:33 +0200 | [diff] [blame] | 44 | test_expect_success 'override reflog default format' ' |
Michael J Gruber | 21d2616 | 2011-04-01 11:20:32 +0200 | [diff] [blame] | 45 | git reflog --format=short -1 >actual && |
| 46 | test_cmp expect actual |
| 47 | ' |
| 48 | |
Jeff King | cd43712 | 2009-03-20 02:00:43 -0400 | [diff] [blame] | 49 | cat >expect <<'EOF' |
| 50 | Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>) |
| 51 | Reflog message: commit (initial): one |
| 52 | EOF |
| 53 | test_expect_success 'using @{now} syntax shows reflog date (multiline)' ' |
| 54 | git log -g -1 HEAD@{now} >tmp && |
| 55 | grep ^Reflog <tmp >actual && |
| 56 | test_cmp expect actual |
| 57 | ' |
| 58 | |
| 59 | cat >expect <<'EOF' |
| 60 | e46513e HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one |
| 61 | EOF |
| 62 | test_expect_success 'using @{now} syntax shows reflog date (oneline)' ' |
| 63 | git log -g -1 --oneline HEAD@{now} >actual && |
| 64 | test_cmp expect actual |
| 65 | ' |
| 66 | |
| 67 | cat >expect <<'EOF' |
Jeff King | 7904af1 | 2012-05-04 01:23:14 -0400 | [diff] [blame] | 68 | HEAD@{Thu Apr 7 15:13:13 2005 -0700} |
| 69 | EOF |
| 70 | test_expect_success 'using @{now} syntax shows reflog date (format=%gd)' ' |
| 71 | git log -g -1 --format=%gd HEAD@{now} >actual && |
| 72 | test_cmp expect actual |
| 73 | ' |
| 74 | |
| 75 | cat >expect <<'EOF' |
Junio C Hamano | 55ccf85 | 2012-05-07 14:11:32 -0700 | [diff] [blame] | 76 | Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>) |
Jeff King | cd43712 | 2009-03-20 02:00:43 -0400 | [diff] [blame] | 77 | Reflog message: commit (initial): one |
| 78 | EOF |
| 79 | test_expect_success 'using --date= shows reflog date (multiline)' ' |
Junio C Hamano | 55ccf85 | 2012-05-07 14:11:32 -0700 | [diff] [blame] | 80 | git log -g -1 --date=default >tmp && |
Jeff King | cd43712 | 2009-03-20 02:00:43 -0400 | [diff] [blame] | 81 | grep ^Reflog <tmp >actual && |
| 82 | test_cmp expect actual |
| 83 | ' |
| 84 | |
| 85 | cat >expect <<'EOF' |
Junio C Hamano | 55ccf85 | 2012-05-07 14:11:32 -0700 | [diff] [blame] | 86 | e46513e HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one |
Jeff King | cd43712 | 2009-03-20 02:00:43 -0400 | [diff] [blame] | 87 | EOF |
| 88 | test_expect_success 'using --date= shows reflog date (oneline)' ' |
Junio C Hamano | 55ccf85 | 2012-05-07 14:11:32 -0700 | [diff] [blame] | 89 | git log -g -1 --oneline --date=default >actual && |
Jeff King | cd43712 | 2009-03-20 02:00:43 -0400 | [diff] [blame] | 90 | test_cmp expect actual |
| 91 | ' |
| 92 | |
Jeff King | 7904af1 | 2012-05-04 01:23:14 -0400 | [diff] [blame] | 93 | cat >expect <<'EOF' |
| 94 | HEAD@{1112911993 -0700} |
| 95 | EOF |
| 96 | test_expect_success 'using --date= shows reflog date (format=%gd)' ' |
| 97 | git log -g -1 --format=%gd --date=raw >actual && |
| 98 | test_cmp expect actual |
| 99 | ' |
| 100 | |
| 101 | cat >expect <<'EOF' |
| 102 | Reflog: HEAD@{0} (C O Mitter <committer@example.com>) |
| 103 | Reflog message: commit (initial): one |
| 104 | EOF |
| 105 | test_expect_success 'log.date does not invoke "--date" magic (multiline)' ' |
| 106 | test_config log.date raw && |
| 107 | git log -g -1 >tmp && |
| 108 | grep ^Reflog <tmp >actual && |
| 109 | test_cmp expect actual |
| 110 | ' |
| 111 | |
| 112 | cat >expect <<'EOF' |
| 113 | e46513e HEAD@{0}: commit (initial): one |
| 114 | EOF |
| 115 | test_expect_success 'log.date does not invoke "--date" magic (oneline)' ' |
| 116 | test_config log.date raw && |
| 117 | git log -g -1 --oneline >actual && |
| 118 | test_cmp expect actual |
| 119 | ' |
| 120 | |
| 121 | cat >expect <<'EOF' |
| 122 | HEAD@{0} |
| 123 | EOF |
Jeff King | f026c75 | 2012-05-04 01:25:18 -0400 | [diff] [blame] | 124 | test_expect_success 'log.date does not invoke "--date" magic (format=%gd)' ' |
Jeff King | 7904af1 | 2012-05-04 01:23:14 -0400 | [diff] [blame] | 125 | test_config log.date raw && |
| 126 | git log -g -1 --format=%gd >actual && |
| 127 | test_cmp expect actual |
| 128 | ' |
| 129 | |
Jeff King | 794151e | 2012-05-04 01:27:25 -0400 | [diff] [blame] | 130 | cat >expect <<'EOF' |
| 131 | HEAD@{0} |
| 132 | EOF |
| 133 | test_expect_success '--date magic does not override explicit @{0} syntax' ' |
| 134 | git log -g -1 --format=%gd --date=raw HEAD@{0} >actual && |
| 135 | test_cmp expect actual |
| 136 | ' |
| 137 | |
Dave Olszewski | 8fcaca3 | 2010-03-13 14:47:05 -0800 | [diff] [blame] | 138 | : >expect |
| 139 | test_expect_success 'empty reflog file' ' |
| 140 | git branch empty && |
| 141 | : >.git/logs/refs/heads/empty && |
| 142 | |
| 143 | git log -g empty >actual && |
| 144 | test_cmp expect actual |
| 145 | ' |
| 146 | |
Jeff King | cd43712 | 2009-03-20 02:00:43 -0400 | [diff] [blame] | 147 | test_done |