Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git log' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success setup ' |
| 8 | |
| 9 | echo one >one && |
| 10 | git add one && |
| 11 | test_tick && |
| 12 | git commit -m initial && |
| 13 | |
| 14 | echo ichi >one && |
| 15 | git add one && |
| 16 | test_tick && |
| 17 | git commit -m second && |
| 18 | |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 19 | git mv one ichi && |
| 20 | test_tick && |
| 21 | git commit -m third && |
| 22 | |
| 23 | cp ichi ein && |
| 24 | git add ein && |
| 25 | test_tick && |
| 26 | git commit -m fourth && |
| 27 | |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 28 | mkdir a && |
| 29 | echo ni >a/two && |
| 30 | git add a/two && |
| 31 | test_tick && |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 32 | git commit -m fifth && |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 33 | |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 34 | git rm a/two && |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 35 | test_tick && |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 36 | git commit -m sixth |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 37 | |
| 38 | ' |
| 39 | |
Felipe Contreras | bb93afd | 2009-02-24 23:06:37 +0200 | [diff] [blame] | 40 | printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect |
| 41 | test_expect_success 'pretty' ' |
| 42 | |
| 43 | git log --pretty="format:%s" > actual && |
| 44 | test_cmp expect actual |
| 45 | ' |
| 46 | |
| 47 | printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect |
| 48 | test_expect_success 'pretty (tformat)' ' |
| 49 | |
| 50 | git log --pretty="tformat:%s" > actual && |
| 51 | test_cmp expect actual |
| 52 | ' |
| 53 | |
| 54 | test_expect_success 'pretty (shortcut)' ' |
| 55 | |
| 56 | git log --pretty="%s" > actual && |
| 57 | test_cmp expect actual |
| 58 | ' |
| 59 | |
| 60 | test_expect_success 'format' ' |
| 61 | |
| 62 | git log --format="%s" > actual && |
| 63 | test_cmp expect actual |
| 64 | ' |
| 65 | |
| 66 | cat > expect << EOF |
| 67 | 804a787 sixth |
| 68 | 394ef78 fifth |
| 69 | 5d31159 fourth |
| 70 | 2fbe8c0 third |
| 71 | f7dab8e second |
| 72 | 3a2fdcb initial |
| 73 | EOF |
| 74 | test_expect_success 'oneline' ' |
| 75 | |
| 76 | git log --oneline > actual && |
| 77 | test_cmp expect actual |
| 78 | ' |
| 79 | |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 80 | test_expect_success 'diff-filter=A' ' |
| 81 | |
| 82 | actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) && |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 83 | expect=$(echo fifth ; echo fourth ; echo third ; echo initial) && |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 84 | test "$actual" = "$expect" || { |
| 85 | echo Oops |
| 86 | echo "Actual: $actual" |
| 87 | false |
| 88 | } |
| 89 | |
| 90 | ' |
| 91 | |
| 92 | test_expect_success 'diff-filter=M' ' |
| 93 | |
| 94 | actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) && |
| 95 | expect=$(echo second) && |
| 96 | test "$actual" = "$expect" || { |
| 97 | echo Oops |
| 98 | echo "Actual: $actual" |
| 99 | false |
| 100 | } |
| 101 | |
| 102 | ' |
| 103 | |
| 104 | test_expect_success 'diff-filter=D' ' |
| 105 | |
| 106 | actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) && |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 107 | expect=$(echo sixth ; echo third) && |
| 108 | test "$actual" = "$expect" || { |
| 109 | echo Oops |
| 110 | echo "Actual: $actual" |
| 111 | false |
| 112 | } |
| 113 | |
| 114 | ' |
| 115 | |
| 116 | test_expect_success 'diff-filter=R' ' |
| 117 | |
| 118 | actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) && |
| 119 | expect=$(echo third) && |
| 120 | test "$actual" = "$expect" || { |
| 121 | echo Oops |
| 122 | echo "Actual: $actual" |
| 123 | false |
| 124 | } |
| 125 | |
| 126 | ' |
| 127 | |
| 128 | test_expect_success 'diff-filter=C' ' |
| 129 | |
| 130 | actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) && |
| 131 | expect=$(echo fourth) && |
| 132 | test "$actual" = "$expect" || { |
| 133 | echo Oops |
| 134 | echo "Actual: $actual" |
| 135 | false |
| 136 | } |
| 137 | |
| 138 | ' |
| 139 | |
| 140 | test_expect_success 'git log --follow' ' |
| 141 | |
| 142 | actual=$(git log --follow --pretty="format:%s" ichi) && |
| 143 | expect=$(echo third ; echo second ; echo initial) && |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 144 | test "$actual" = "$expect" || { |
| 145 | echo Oops |
| 146 | echo "Actual: $actual" |
| 147 | false |
| 148 | } |
| 149 | |
| 150 | ' |
| 151 | |
Jeff King | 0843acf | 2008-08-25 02:15:05 -0400 | [diff] [blame] | 152 | test_expect_success 'setup case sensitivity tests' ' |
| 153 | echo case >one && |
| 154 | test_tick && |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 155 | git add one |
Jeff King | 0843acf | 2008-08-25 02:15:05 -0400 | [diff] [blame] | 156 | git commit -a -m Second |
| 157 | ' |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 158 | |
Jeff King | 0843acf | 2008-08-25 02:15:05 -0400 | [diff] [blame] | 159 | test_expect_success 'log --grep' ' |
| 160 | echo second >expect && |
| 161 | git log -1 --pretty="tformat:%s" --grep=sec >actual && |
| 162 | test_cmp expect actual |
| 163 | ' |
| 164 | |
| 165 | test_expect_success 'log -i --grep' ' |
| 166 | echo Second >expect && |
| 167 | git log -1 --pretty="tformat:%s" -i --grep=sec >actual && |
| 168 | test_cmp expect actual |
| 169 | ' |
| 170 | |
| 171 | test_expect_success 'log --grep -i' ' |
| 172 | echo Second >expect && |
| 173 | git log -1 --pretty="tformat:%s" --grep=sec -i >actual && |
| 174 | test_cmp expect actual |
| 175 | ' |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 176 | |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 177 | cat > expect <<EOF |
| 178 | * Second |
| 179 | * sixth |
| 180 | * fifth |
| 181 | * fourth |
| 182 | * third |
| 183 | * second |
| 184 | * initial |
| 185 | EOF |
| 186 | |
| 187 | test_expect_success 'simple log --graph' ' |
| 188 | git log --graph --pretty=tformat:%s >actual && |
| 189 | test_cmp expect actual |
| 190 | ' |
| 191 | |
| 192 | test_expect_success 'set up merge history' ' |
| 193 | git checkout -b side HEAD~4 && |
| 194 | test_commit side-1 1 1 && |
| 195 | test_commit side-2 2 2 && |
| 196 | git checkout master && |
| 197 | git merge side |
| 198 | ' |
| 199 | |
| 200 | cat > expect <<\EOF |
| 201 | * Merge branch 'side' |
| 202 | |\ |
| 203 | | * side-2 |
| 204 | | * side-1 |
| 205 | * | Second |
| 206 | * | sixth |
| 207 | * | fifth |
| 208 | * | fourth |
| 209 | |/ |
| 210 | * third |
| 211 | * second |
| 212 | * initial |
| 213 | EOF |
| 214 | |
| 215 | test_expect_success 'log --graph with merge' ' |
| 216 | git log --graph --date-order --pretty=tformat:%s | |
| 217 | sed "s/ *$//" >actual && |
| 218 | test_cmp expect actual |
| 219 | ' |
| 220 | |
| 221 | cat > expect <<\EOF |
| 222 | * commit master |
| 223 | |\ Merge: A B |
| 224 | | | Author: A U Thor <author@example.com> |
| 225 | | | |
| 226 | | | Merge branch 'side' |
| 227 | | | |
| 228 | | * commit side |
| 229 | | | Author: A U Thor <author@example.com> |
| 230 | | | |
| 231 | | | side-2 |
| 232 | | | |
| 233 | | * commit tags/side-1 |
| 234 | | | Author: A U Thor <author@example.com> |
| 235 | | | |
| 236 | | | side-1 |
| 237 | | | |
| 238 | * | commit master~1 |
| 239 | | | Author: A U Thor <author@example.com> |
| 240 | | | |
| 241 | | | Second |
| 242 | | | |
| 243 | * | commit master~2 |
| 244 | | | Author: A U Thor <author@example.com> |
| 245 | | | |
| 246 | | | sixth |
| 247 | | | |
| 248 | * | commit master~3 |
| 249 | | | Author: A U Thor <author@example.com> |
| 250 | | | |
| 251 | | | fifth |
| 252 | | | |
| 253 | * | commit master~4 |
| 254 | |/ Author: A U Thor <author@example.com> |
| 255 | | |
| 256 | | fourth |
| 257 | | |
| 258 | * commit tags/side-1~1 |
| 259 | | Author: A U Thor <author@example.com> |
| 260 | | |
| 261 | | third |
| 262 | | |
| 263 | * commit tags/side-1~2 |
| 264 | | Author: A U Thor <author@example.com> |
| 265 | | |
| 266 | | second |
| 267 | | |
| 268 | * commit tags/side-1~3 |
| 269 | Author: A U Thor <author@example.com> |
| 270 | |
| 271 | initial |
| 272 | EOF |
| 273 | |
| 274 | test_expect_success 'log --graph with full output' ' |
| 275 | git log --graph --date-order --pretty=short | |
| 276 | git name-rev --name-only --stdin | |
| 277 | sed "s/Merge:.*/Merge: A B/;s/ *$//" >actual && |
| 278 | test_cmp expect actual |
| 279 | ' |
| 280 | |
| 281 | test_expect_success 'set up more tangled history' ' |
| 282 | git checkout -b tangle HEAD~6 && |
| 283 | test_commit tangle-a tangle-a a && |
| 284 | git merge master~3 && |
| 285 | git merge side~1 && |
| 286 | git checkout master && |
Allan Caffee | 7b1d626 | 2009-04-22 17:27:15 -0400 | [diff] [blame] | 287 | git merge tangle && |
| 288 | git checkout -b reach && |
| 289 | test_commit reach && |
| 290 | git checkout master && |
| 291 | git checkout -b octopus-a && |
| 292 | test_commit octopus-a && |
| 293 | git checkout master && |
| 294 | git checkout -b octopus-b && |
| 295 | test_commit octopus-b && |
| 296 | git checkout master && |
| 297 | test_commit seventh && |
| 298 | git merge octopus-a octopus-b |
| 299 | git merge reach |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 300 | ' |
| 301 | |
| 302 | cat > expect <<\EOF |
Allan Caffee | 7b1d626 | 2009-04-22 17:27:15 -0400 | [diff] [blame] | 303 | * Merge branch 'reach' |
| 304 | |\ |
| 305 | | \ |
| 306 | | \ |
| 307 | *-. \ Merge branches 'octopus-a' and 'octopus-b' |
| 308 | |\ \ \ |
| 309 | * | | | seventh |
| 310 | | | * | octopus-b |
| 311 | | |/ / |
| 312 | |/| | |
| 313 | | * | octopus-a |
| 314 | |/ / |
| 315 | | * reach |
| 316 | |/ |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 317 | * Merge branch 'tangle' |
| 318 | |\ |
| 319 | | * Merge branch 'side' (early part) into tangle |
| 320 | | |\ |
| 321 | | * \ Merge branch 'master' (early part) into tangle |
| 322 | | |\ \ |
| 323 | | * | | tangle-a |
| 324 | * | | | Merge branch 'side' |
| 325 | |\ \ \ \ |
| 326 | | * | | | side-2 |
| 327 | | | | |/ |
| 328 | | | |/| |
| 329 | | |/| | |
| 330 | | * | | side-1 |
| 331 | * | | | Second |
| 332 | * | | | sixth |
| 333 | | | |/ |
| 334 | | |/| |
| 335 | |/| | |
| 336 | * | | fifth |
| 337 | * | | fourth |
| 338 | |/ / |
| 339 | * | third |
| 340 | |/ |
| 341 | * second |
| 342 | * initial |
| 343 | EOF |
| 344 | |
Linus Torvalds | 95110d7 | 2009-04-26 12:29:13 -0700 | [diff] [blame^] | 345 | test_expect_success 'log --graph with merge' ' |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 346 | git log --graph --date-order --pretty=tformat:%s | |
| 347 | sed "s/ *$//" >actual && |
| 348 | test_cmp expect actual |
| 349 | ' |
| 350 | |
Brandon Casey | c65233f | 2008-07-22 16:23:31 -0500 | [diff] [blame] | 351 | test_done |
| 352 | |