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 |
René Scharfe | 37bb5d7 | 2009-11-22 17:15:29 +0100 | [diff] [blame] | 67 | This is |
| 68 | the sixth |
| 69 | commit. |
| 70 | This is |
| 71 | the fifth |
| 72 | commit. |
| 73 | EOF |
| 74 | |
| 75 | test_expect_success 'format %w(12,1,2)' ' |
| 76 | |
| 77 | git log -2 --format="%w(12,1,2)This is the %s commit." > actual && |
| 78 | test_cmp expect actual |
| 79 | ' |
| 80 | |
| 81 | test_expect_success 'format %w(,1,2)' ' |
| 82 | |
| 83 | git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual && |
| 84 | test_cmp expect actual |
| 85 | ' |
| 86 | |
| 87 | cat > expect << EOF |
Felipe Contreras | bb93afd | 2009-02-24 23:06:37 +0200 | [diff] [blame] | 88 | 804a787 sixth |
| 89 | 394ef78 fifth |
| 90 | 5d31159 fourth |
| 91 | 2fbe8c0 third |
| 92 | f7dab8e second |
| 93 | 3a2fdcb initial |
| 94 | EOF |
| 95 | test_expect_success 'oneline' ' |
| 96 | |
| 97 | git log --oneline > actual && |
| 98 | test_cmp expect actual |
| 99 | ' |
| 100 | |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 101 | test_expect_success 'diff-filter=A' ' |
| 102 | |
| 103 | actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) && |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 104 | expect=$(echo fifth ; echo fourth ; echo third ; echo initial) && |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 105 | test "$actual" = "$expect" || { |
| 106 | echo Oops |
| 107 | echo "Actual: $actual" |
| 108 | false |
| 109 | } |
| 110 | |
| 111 | ' |
| 112 | |
| 113 | test_expect_success 'diff-filter=M' ' |
| 114 | |
| 115 | actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) && |
| 116 | expect=$(echo second) && |
| 117 | test "$actual" = "$expect" || { |
| 118 | echo Oops |
| 119 | echo "Actual: $actual" |
| 120 | false |
| 121 | } |
| 122 | |
| 123 | ' |
| 124 | |
| 125 | test_expect_success 'diff-filter=D' ' |
| 126 | |
| 127 | actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) && |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 128 | expect=$(echo sixth ; echo third) && |
| 129 | test "$actual" = "$expect" || { |
| 130 | echo Oops |
| 131 | echo "Actual: $actual" |
| 132 | false |
| 133 | } |
| 134 | |
| 135 | ' |
| 136 | |
| 137 | test_expect_success 'diff-filter=R' ' |
| 138 | |
| 139 | actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) && |
| 140 | expect=$(echo third) && |
| 141 | test "$actual" = "$expect" || { |
| 142 | echo Oops |
| 143 | echo "Actual: $actual" |
| 144 | false |
| 145 | } |
| 146 | |
| 147 | ' |
| 148 | |
| 149 | test_expect_success 'diff-filter=C' ' |
| 150 | |
| 151 | actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) && |
| 152 | expect=$(echo fourth) && |
| 153 | test "$actual" = "$expect" || { |
| 154 | echo Oops |
| 155 | echo "Actual: $actual" |
| 156 | false |
| 157 | } |
| 158 | |
| 159 | ' |
| 160 | |
| 161 | test_expect_success 'git log --follow' ' |
| 162 | |
| 163 | actual=$(git log --follow --pretty="format:%s" ichi) && |
| 164 | expect=$(echo third ; echo second ; echo initial) && |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 165 | test "$actual" = "$expect" || { |
| 166 | echo Oops |
| 167 | echo "Actual: $actual" |
| 168 | false |
| 169 | } |
| 170 | |
| 171 | ' |
| 172 | |
Michael J Gruber | d5cee0f | 2009-07-17 16:28:06 +0200 | [diff] [blame] | 173 | cat > expect << EOF |
| 174 | 804a787 sixth |
| 175 | 394ef78 fifth |
| 176 | 5d31159 fourth |
| 177 | EOF |
| 178 | test_expect_success 'git log --no-walk <commits> sorts by commit time' ' |
| 179 | git log --no-walk --oneline 5d31159 804a787 394ef78 > actual && |
| 180 | test_cmp expect actual |
| 181 | ' |
| 182 | |
| 183 | cat > expect << EOF |
| 184 | 5d31159 fourth |
| 185 | 804a787 sixth |
| 186 | 394ef78 fifth |
| 187 | EOF |
| 188 | test_expect_success 'git show <commits> leaves list of commits as given' ' |
| 189 | git show --oneline -s 5d31159 804a787 394ef78 > actual && |
| 190 | test_cmp expect actual |
| 191 | ' |
| 192 | |
Jeff King | 0843acf | 2008-08-25 02:15:05 -0400 | [diff] [blame] | 193 | test_expect_success 'setup case sensitivity tests' ' |
| 194 | echo case >one && |
| 195 | test_tick && |
Arjen Laarhoven | d930508 | 2009-01-22 17:37:24 +0100 | [diff] [blame] | 196 | git add one |
Jeff King | 0843acf | 2008-08-25 02:15:05 -0400 | [diff] [blame] | 197 | git commit -a -m Second |
| 198 | ' |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 199 | |
Jeff King | 0843acf | 2008-08-25 02:15:05 -0400 | [diff] [blame] | 200 | test_expect_success 'log --grep' ' |
| 201 | echo second >expect && |
| 202 | git log -1 --pretty="tformat:%s" --grep=sec >actual && |
| 203 | test_cmp expect actual |
| 204 | ' |
| 205 | |
| 206 | test_expect_success 'log -i --grep' ' |
| 207 | echo Second >expect && |
| 208 | git log -1 --pretty="tformat:%s" -i --grep=sec >actual && |
| 209 | test_cmp expect actual |
| 210 | ' |
| 211 | |
| 212 | test_expect_success 'log --grep -i' ' |
| 213 | echo Second >expect && |
| 214 | git log -1 --pretty="tformat:%s" --grep=sec -i >actual && |
| 215 | test_cmp expect actual |
| 216 | ' |
Arjen Laarhoven | 0faf2da | 2007-12-25 12:06:47 +0100 | [diff] [blame] | 217 | |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 218 | cat > expect <<EOF |
| 219 | * Second |
| 220 | * sixth |
| 221 | * fifth |
| 222 | * fourth |
| 223 | * third |
| 224 | * second |
| 225 | * initial |
| 226 | EOF |
| 227 | |
| 228 | test_expect_success 'simple log --graph' ' |
| 229 | git log --graph --pretty=tformat:%s >actual && |
| 230 | test_cmp expect actual |
| 231 | ' |
| 232 | |
| 233 | test_expect_success 'set up merge history' ' |
| 234 | git checkout -b side HEAD~4 && |
| 235 | test_commit side-1 1 1 && |
| 236 | test_commit side-2 2 2 && |
| 237 | git checkout master && |
| 238 | git merge side |
| 239 | ' |
| 240 | |
| 241 | cat > expect <<\EOF |
| 242 | * Merge branch 'side' |
| 243 | |\ |
| 244 | | * side-2 |
| 245 | | * side-1 |
| 246 | * | Second |
| 247 | * | sixth |
| 248 | * | fifth |
| 249 | * | fourth |
| 250 | |/ |
| 251 | * third |
| 252 | * second |
| 253 | * initial |
| 254 | EOF |
| 255 | |
| 256 | test_expect_success 'log --graph with merge' ' |
| 257 | git log --graph --date-order --pretty=tformat:%s | |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 258 | sed "s/ *\$//" >actual && |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 259 | test_cmp expect actual |
| 260 | ' |
| 261 | |
| 262 | cat > expect <<\EOF |
| 263 | * commit master |
| 264 | |\ Merge: A B |
| 265 | | | Author: A U Thor <author@example.com> |
| 266 | | | |
| 267 | | | Merge branch 'side' |
| 268 | | | |
| 269 | | * commit side |
| 270 | | | Author: A U Thor <author@example.com> |
| 271 | | | |
| 272 | | | side-2 |
| 273 | | | |
| 274 | | * commit tags/side-1 |
| 275 | | | Author: A U Thor <author@example.com> |
| 276 | | | |
| 277 | | | side-1 |
| 278 | | | |
| 279 | * | commit master~1 |
| 280 | | | Author: A U Thor <author@example.com> |
| 281 | | | |
| 282 | | | Second |
| 283 | | | |
| 284 | * | commit master~2 |
| 285 | | | Author: A U Thor <author@example.com> |
| 286 | | | |
| 287 | | | sixth |
| 288 | | | |
| 289 | * | commit master~3 |
| 290 | | | Author: A U Thor <author@example.com> |
| 291 | | | |
| 292 | | | fifth |
| 293 | | | |
| 294 | * | commit master~4 |
| 295 | |/ Author: A U Thor <author@example.com> |
| 296 | | |
| 297 | | fourth |
| 298 | | |
| 299 | * commit tags/side-1~1 |
| 300 | | Author: A U Thor <author@example.com> |
| 301 | | |
| 302 | | third |
| 303 | | |
| 304 | * commit tags/side-1~2 |
| 305 | | Author: A U Thor <author@example.com> |
| 306 | | |
| 307 | | second |
| 308 | | |
| 309 | * commit tags/side-1~3 |
| 310 | Author: A U Thor <author@example.com> |
| 311 | |
| 312 | initial |
| 313 | EOF |
| 314 | |
| 315 | test_expect_success 'log --graph with full output' ' |
| 316 | git log --graph --date-order --pretty=short | |
| 317 | git name-rev --name-only --stdin | |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 318 | sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 319 | test_cmp expect actual |
| 320 | ' |
| 321 | |
| 322 | test_expect_success 'set up more tangled history' ' |
| 323 | git checkout -b tangle HEAD~6 && |
| 324 | test_commit tangle-a tangle-a a && |
| 325 | git merge master~3 && |
| 326 | git merge side~1 && |
| 327 | git checkout master && |
Allan Caffee | 7b1d626 | 2009-04-22 17:27:15 -0400 | [diff] [blame] | 328 | git merge tangle && |
| 329 | git checkout -b reach && |
| 330 | test_commit reach && |
| 331 | git checkout master && |
| 332 | git checkout -b octopus-a && |
| 333 | test_commit octopus-a && |
| 334 | git checkout master && |
| 335 | git checkout -b octopus-b && |
| 336 | test_commit octopus-b && |
| 337 | git checkout master && |
| 338 | test_commit seventh && |
| 339 | git merge octopus-a octopus-b |
| 340 | git merge reach |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 341 | ' |
| 342 | |
| 343 | cat > expect <<\EOF |
Jeff King | 751c597 | 2009-08-09 06:02:24 -0400 | [diff] [blame] | 344 | * Merge commit 'reach' |
Allan Caffee | 7b1d626 | 2009-04-22 17:27:15 -0400 | [diff] [blame] | 345 | |\ |
| 346 | | \ |
| 347 | | \ |
Jeff King | 751c597 | 2009-08-09 06:02:24 -0400 | [diff] [blame] | 348 | *-. \ Merge commit 'octopus-a'; commit 'octopus-b' |
Allan Caffee | 7b1d626 | 2009-04-22 17:27:15 -0400 | [diff] [blame] | 349 | |\ \ \ |
| 350 | * | | | seventh |
| 351 | | | * | octopus-b |
| 352 | | |/ / |
| 353 | |/| | |
| 354 | | * | octopus-a |
| 355 | |/ / |
| 356 | | * reach |
| 357 | |/ |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 358 | * Merge branch 'tangle' |
| 359 | |\ |
| 360 | | * Merge branch 'side' (early part) into tangle |
| 361 | | |\ |
| 362 | | * \ Merge branch 'master' (early part) into tangle |
| 363 | | |\ \ |
| 364 | | * | | tangle-a |
| 365 | * | | | Merge branch 'side' |
| 366 | |\ \ \ \ |
| 367 | | * | | | side-2 |
Allan Caffee | eaf158f | 2009-04-21 08:47:01 -0400 | [diff] [blame] | 368 | | | |_|/ |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 369 | | |/| | |
| 370 | | * | | side-1 |
| 371 | * | | | Second |
| 372 | * | | | sixth |
Allan Caffee | eaf158f | 2009-04-21 08:47:01 -0400 | [diff] [blame] | 373 | | |_|/ |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 374 | |/| | |
| 375 | * | | fifth |
| 376 | * | | fourth |
| 377 | |/ / |
| 378 | * | third |
| 379 | |/ |
| 380 | * second |
| 381 | * initial |
| 382 | EOF |
| 383 | |
Linus Torvalds | 95110d7 | 2009-04-26 12:29:13 -0700 | [diff] [blame] | 384 | test_expect_success 'log --graph with merge' ' |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 385 | git log --graph --date-order --pretty=tformat:%s | |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 386 | sed "s/ *\$//" >actual && |
Thomas Rast | 289e162 | 2009-02-19 12:13:38 +0100 | [diff] [blame] | 387 | test_cmp expect actual |
| 388 | ' |
| 389 | |
Junio C Hamano | 8a3d203 | 2010-02-17 10:20:49 -0800 | [diff] [blame] | 390 | test_expect_success 'log.decorate configuration' ' |
| 391 | git config --unset-all log.decorate || : |
| 392 | |
Junio C Hamano | 4f62c2b | 2010-04-08 10:17:17 -0700 | [diff] [blame^] | 393 | git log --oneline >expect.none && |
| 394 | git log --oneline --decorate >expect.short && |
| 395 | git log --oneline --decorate=full >expect.full && |
Junio C Hamano | 8a3d203 | 2010-02-17 10:20:49 -0800 | [diff] [blame] | 396 | |
| 397 | echo "[log] decorate" >>.git/config && |
Junio C Hamano | 635530a | 2010-04-06 14:48:55 -0700 | [diff] [blame] | 398 | git log --oneline >actual && |
Junio C Hamano | 4f62c2b | 2010-04-08 10:17:17 -0700 | [diff] [blame^] | 399 | test_cmp expect.short actual && |
Junio C Hamano | 8a3d203 | 2010-02-17 10:20:49 -0800 | [diff] [blame] | 400 | |
| 401 | git config --unset-all log.decorate && |
| 402 | git config log.decorate true && |
Junio C Hamano | 635530a | 2010-04-06 14:48:55 -0700 | [diff] [blame] | 403 | git log --oneline >actual && |
Junio C Hamano | 4f62c2b | 2010-04-08 10:17:17 -0700 | [diff] [blame^] | 404 | test_cmp expect.short actual && |
| 405 | git log --oneline --decorate=full >actual && |
| 406 | test_cmp expect.full actual && |
| 407 | git log --oneline --decorate=no >actual && |
| 408 | test_cmp expect.none actual && |
Junio C Hamano | 8a3d203 | 2010-02-17 10:20:49 -0800 | [diff] [blame] | 409 | |
| 410 | git config --unset-all log.decorate && |
| 411 | git config log.decorate no && |
Junio C Hamano | 635530a | 2010-04-06 14:48:55 -0700 | [diff] [blame] | 412 | git log --oneline >actual && |
Junio C Hamano | 4f62c2b | 2010-04-08 10:17:17 -0700 | [diff] [blame^] | 413 | test_cmp expect.none actual && |
| 414 | git log --oneline --decorate >actual && |
| 415 | test_cmp expect.short actual && |
| 416 | git log --oneline --decorate=full >actual && |
| 417 | test_cmp expect.full actual && |
Junio C Hamano | 8a3d203 | 2010-02-17 10:20:49 -0800 | [diff] [blame] | 418 | |
| 419 | git config --unset-all log.decorate && |
| 420 | git config log.decorate short && |
Junio C Hamano | 635530a | 2010-04-06 14:48:55 -0700 | [diff] [blame] | 421 | git log --oneline >actual && |
Junio C Hamano | 4f62c2b | 2010-04-08 10:17:17 -0700 | [diff] [blame^] | 422 | test_cmp expect.short actual && |
| 423 | git log --oneline --no-decorate >actual && |
| 424 | test_cmp expect.none actual && |
| 425 | git log --oneline --decorate=full >actual && |
| 426 | test_cmp expect.full actual && |
Junio C Hamano | 8a3d203 | 2010-02-17 10:20:49 -0800 | [diff] [blame] | 427 | |
| 428 | git config --unset-all log.decorate && |
| 429 | git config log.decorate full && |
Junio C Hamano | 635530a | 2010-04-06 14:48:55 -0700 | [diff] [blame] | 430 | git log --oneline >actual && |
Junio C Hamano | 4f62c2b | 2010-04-08 10:17:17 -0700 | [diff] [blame^] | 431 | test_cmp expect.full actual && |
| 432 | git log --oneline --no-decorate >actual && |
| 433 | test_cmp expect.none actual && |
| 434 | git log --oneline --decorate >actual && |
| 435 | test_cmp expect.short actual |
Junio C Hamano | 8a3d203 | 2010-02-17 10:20:49 -0800 | [diff] [blame] | 436 | |
| 437 | ' |
| 438 | |
Brandon Casey | c65233f | 2008-07-22 16:23:31 -0500 | [diff] [blame] | 439 | test_done |
| 440 | |