t / t6004-rev-list-path-optim.shon commit Merge branch 'bc/maint-makefile-fixes' (aa57328)
   1#!/bin/sh
   2
   3test_description='git rev-list trivial path optimization test'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8echo Hello > a &&
   9git add a &&
  10git commit -m "Initial commit" a &&
  11initial=$(git rev-parse --verify HEAD)
  12'
  13
  14test_expect_success path-optimization '
  15    commit=$(echo "Unchanged tree" | git commit-tree "HEAD^{tree}" -p HEAD) &&
  16    test $(git rev-list $commit | wc -l) = 2 &&
  17    test $(git rev-list $commit -- . | wc -l) = 1
  18'
  19
  20test_expect_success 'further setup' '
  21        git checkout -b side &&
  22        echo Irrelevant >c &&
  23        git add c &&
  24        git commit -m "Side makes an irrelevant commit" &&
  25        echo "More Irrelevancy" >c &&
  26        git add c &&
  27        git commit -m "Side makes another irrelevant commit" &&
  28        echo Bye >a &&
  29        git add a &&
  30        git commit -m "Side touches a" &&
  31        side=$(git rev-parse --verify HEAD) &&
  32        echo "Yet more Irrelevancy" >c &&
  33        git add c &&
  34        git commit -m "Side makes yet another irrelevant commit" &&
  35        git checkout master &&
  36        echo Another >b &&
  37        git add b &&
  38        git commit -m "Master touches b" &&
  39        git merge side &&
  40        echo Touched >b &&
  41        git add b &&
  42        git commit -m "Master touches b again"
  43'
  44
  45test_expect_success 'path optimization 2' '
  46        ( echo "$side"; echo "$initial" ) >expected &&
  47        git rev-list HEAD -- a >actual &&
  48        test_cmp expected actual
  49'
  50
  51test_done