t / t6000-rev-list-misc.shon commit t5310: increase the number of bitmapped commits (1ac96cd)
   1#!/bin/sh
   2
   3test_description='miscellaneous rev-list tests'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8        echo content1 >wanted_file &&
   9        echo content2 >unwanted_file &&
  10        git add wanted_file unwanted_file &&
  11        git commit -m one
  12'
  13
  14test_expect_success 'rev-list --objects heeds pathspecs' '
  15        git rev-list --objects HEAD -- wanted_file >output &&
  16        grep wanted_file output &&
  17        ! grep unwanted_file output
  18'
  19
  20test_expect_success 'rev-list --objects with pathspecs and deeper paths' '
  21        mkdir foo &&
  22        >foo/file &&
  23        git add foo/file &&
  24        git commit -m two &&
  25
  26        git rev-list --objects HEAD -- foo >output &&
  27        grep foo/file output &&
  28
  29        git rev-list --objects HEAD -- foo/file >output &&
  30        grep foo/file output &&
  31        ! grep unwanted_file output
  32'
  33
  34test_expect_success 'rev-list --objects with pathspecs and copied files' '
  35        git checkout --orphan junio-testcase &&
  36        git rm -rf . &&
  37
  38        mkdir two &&
  39        echo frotz >one &&
  40        cp one two/three &&
  41        git add one two/three &&
  42        test_tick &&
  43        git commit -m that &&
  44
  45        ONE=$(git rev-parse HEAD:one) &&
  46        git rev-list --objects HEAD two >output &&
  47        grep "$ONE two/three" output &&
  48        ! grep one output
  49'
  50
  51test_expect_success 'rev-list A..B and rev-list ^A B are the same' '
  52        git commit --allow-empty -m another &&
  53        git tag -a -m "annotated" v1.0 &&
  54        git rev-list --objects ^v1.0^ v1.0 >expect &&
  55        git rev-list --objects v1.0^..v1.0 >actual &&
  56        test_cmp expect actual
  57'
  58
  59test_expect_success 'propagate uninteresting flag down correctly' '
  60        git rev-list --objects ^HEAD^{tree} HEAD^{tree} >actual &&
  61        test_must_be_empty actual
  62'
  63
  64test_expect_success 'symleft flag bit is propagated down from tag' '
  65        git log --format="%m %s" --left-right v1.0...master >actual &&
  66        cat >expect <<-\EOF &&
  67        > two
  68        > one
  69        < another
  70        < that
  71        EOF
  72        test_cmp expect actual
  73'
  74
  75test_expect_success 'rev-list can show index objects' '
  76        # Of the blobs and trees in the index, note:
  77        #
  78        #   - we do not show two/three, because it is the
  79        #     same blob as "one", and we show objects only once
  80        #
  81        #   - we do show the tree "two", because it has a valid cache tree
  82        #     from the last commit
  83        #
  84        #   - we do not show the root tree; since we updated the index, it
  85        #     does not have a valid cache tree
  86        #
  87        cat >expect <<-\EOF &&
  88        8e4020bb5a8d8c873b25de15933e75cc0fc275df one
  89        d9d3a7417b9605cfd88ee6306b28dadc29e6ab08 only-in-index
  90        9200b628cf9dc883a85a7abc8d6e6730baee589c two
  91        EOF
  92        echo only-in-index >only-in-index &&
  93        test_when_finished "git reset --hard" &&
  94        git add only-in-index &&
  95        git rev-list --objects --indexed-objects >actual &&
  96        test_cmp expect actual
  97'
  98
  99test_expect_success 'rev-list can negate index objects' '
 100        git rev-parse HEAD >expect &&
 101        git rev-list -1 --objects HEAD --not --indexed-objects >actual &&
 102        test_cmp expect actual
 103'
 104
 105test_expect_success '--bisect and --first-parent can not be combined' '
 106        test_must_fail git rev-list --bisect --first-parent HEAD
 107'
 108
 109test_expect_success '--header shows a NUL after each commit' '
 110        # We know that there is no Q in the true payload; names and
 111        # addresses of the authors and the committers do not have
 112        # any, and object names or header names do not, either.
 113        git rev-list --header --max-count=2 HEAD |
 114        nul_to_q |
 115        grep "^Q" >actual &&
 116        cat >expect <<-EOF &&
 117        Q$(git rev-parse HEAD~1)
 118        Q
 119        EOF
 120        test_cmp expect actual
 121'
 122
 123test_done