t / t4066-diff-emit-delay.shon commit notes: avoid potential use-after-free during insertion (60fe477)
   1#!/bin/sh
   2
   3test_description='test combined/stat/moved interaction'
   4. ./test-lib.sh
   5
   6# This test covers a weird 3-way interaction between "--cc -p", which will run
   7# the combined diff code, along with "--stat", which will be computed as a
   8# first-parent stat during the combined diff, and "--color-moved", which
   9# enables the emitted_symbols list to store the diff in memory.
  10
  11test_expect_success 'set up history with a merge' '
  12        test_commit A &&
  13        test_commit B &&
  14        git checkout -b side HEAD^ &&
  15        test_commit C &&
  16        git merge -m M master &&
  17        test_commit D
  18'
  19
  20test_expect_success 'log --cc -p --stat --color-moved' '
  21        cat >expect <<-\EOF &&
  22        commit D
  23        ---
  24         D.t | 1 +
  25         1 file changed, 1 insertion(+)
  26
  27        diff --git a/D.t b/D.t
  28        new file mode 100644
  29        index 0000000..1784810
  30        --- /dev/null
  31        +++ b/D.t
  32        @@ -0,0 +1 @@
  33        +D
  34        commit M
  35
  36         B.t | 1 +
  37         1 file changed, 1 insertion(+)
  38        commit C
  39        ---
  40         C.t | 1 +
  41         1 file changed, 1 insertion(+)
  42
  43        diff --git a/C.t b/C.t
  44        new file mode 100644
  45        index 0000000..3cc58df
  46        --- /dev/null
  47        +++ b/C.t
  48        @@ -0,0 +1 @@
  49        +C
  50        commit B
  51        ---
  52         B.t | 1 +
  53         1 file changed, 1 insertion(+)
  54
  55        diff --git a/B.t b/B.t
  56        new file mode 100644
  57        index 0000000..223b783
  58        --- /dev/null
  59        +++ b/B.t
  60        @@ -0,0 +1 @@
  61        +B
  62        commit A
  63        ---
  64         A.t | 1 +
  65         1 file changed, 1 insertion(+)
  66
  67        diff --git a/A.t b/A.t
  68        new file mode 100644
  69        index 0000000..f70f10e
  70        --- /dev/null
  71        +++ b/A.t
  72        @@ -0,0 +1 @@
  73        +A
  74        EOF
  75        git log --format="commit %s" --cc -p --stat --color-moved >actual &&
  76        test_cmp expect actual
  77'
  78
  79test_done