t / t6100-rev-list-in-order.shon commit Merge branch 'master' of https://github.com/vnwildman/git (26a567e)
   1#!/bin/sh
   2
   3test_description='rev-list testing in-commit-order'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup a commit history with trees, blobs' '
   8        for x in one two three four
   9        do
  10                echo $x >$x &&
  11                git add $x &&
  12                git commit -m "add file $x" ||
  13                return 1
  14        done &&
  15        for x in four three
  16        do
  17                git rm $x &&
  18                git commit -m "remove $x" ||
  19                return 1
  20        done
  21'
  22
  23test_expect_success 'rev-list --in-commit-order' '
  24        git rev-list --in-commit-order --objects HEAD >actual.raw &&
  25        cut -c 1-40 >actual <actual.raw &&
  26
  27        git cat-file --batch-check="%(objectname)" >expect.raw <<-\EOF &&
  28                HEAD^{commit}
  29                HEAD^{tree}
  30                HEAD^{tree}:one
  31                HEAD^{tree}:two
  32                HEAD~1^{commit}
  33                HEAD~1^{tree}
  34                HEAD~1^{tree}:three
  35                HEAD~2^{commit}
  36                HEAD~2^{tree}
  37                HEAD~2^{tree}:four
  38                HEAD~3^{commit}
  39                # HEAD~3^{tree} skipped, same as HEAD~1^{tree}
  40                HEAD~4^{commit}
  41                # HEAD~4^{tree} skipped, same as HEAD^{tree}
  42                HEAD~5^{commit}
  43                HEAD~5^{tree}
  44        EOF
  45        grep -v "#" >expect <expect.raw &&
  46
  47        test_cmp expect actual
  48'
  49
  50test_expect_success 'rev-list lists blobs and trees after commits' '
  51        git rev-list --objects HEAD >actual.raw &&
  52        cut -c 1-40 >actual <actual.raw &&
  53
  54        git cat-file --batch-check="%(objectname)" >expect.raw <<-\EOF &&
  55                HEAD^{commit}
  56                HEAD~1^{commit}
  57                HEAD~2^{commit}
  58                HEAD~3^{commit}
  59                HEAD~4^{commit}
  60                HEAD~5^{commit}
  61                HEAD^{tree}
  62                HEAD^{tree}:one
  63                HEAD^{tree}:two
  64                HEAD~1^{tree}
  65                HEAD~1^{tree}:three
  66                HEAD~2^{tree}
  67                HEAD~2^{tree}:four
  68                # HEAD~3^{tree} skipped, same as HEAD~1^{tree}
  69                # HEAD~4^{tree} skipped, same as HEAD^{tree}
  70                HEAD~5^{tree}
  71        EOF
  72        grep -v "#" >expect <expect.raw &&
  73
  74        test_cmp expect actual
  75'
  76
  77test_done