t / t4013-diff-various.shon commit Allow rebase to run if upstream is completely merged (1308c17)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Junio C Hamano
   4#
   5
   6test_description='Various diff formatting options'
   7
   8. ./test-lib.sh
   9
  10LF='
  11'
  12
  13test_expect_success setup '
  14
  15        GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
  16        GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
  17        export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
  18
  19        mkdir dir &&
  20        mkdir dir2 &&
  21        for i in 1 2 3; do echo $i; done >file0 &&
  22        for i in A B; do echo $i; done >dir/sub &&
  23        cat file0 >file2 &&
  24        git add file0 file2 dir/sub &&
  25        git commit -m Initial &&
  26
  27        git branch initial &&
  28        git branch side &&
  29
  30        GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" &&
  31        GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" &&
  32        export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
  33
  34        for i in 4 5 6; do echo $i; done >>file0 &&
  35        for i in C D; do echo $i; done >>dir/sub &&
  36        rm -f file2 &&
  37        git update-index --remove file0 file2 dir/sub &&
  38        git commit -m "Second${LF}${LF}This is the second commit." &&
  39
  40        GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" &&
  41        GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" &&
  42        export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
  43
  44        for i in A B C; do echo $i; done >file1 &&
  45        git add file1 &&
  46        for i in E F; do echo $i; done >>dir/sub &&
  47        git update-index dir/sub &&
  48        git commit -m Third &&
  49
  50        GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" &&
  51        GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" &&
  52        export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
  53
  54        git checkout side &&
  55        for i in A B C; do echo $i; done >>file0 &&
  56        for i in 1 2; do echo $i; done >>dir/sub &&
  57        cat dir/sub >file3 &&
  58        git add file3 &&
  59        git update-index file0 dir/sub &&
  60        git commit -m Side &&
  61
  62        GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" &&
  63        GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" &&
  64        export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
  65
  66        git checkout master &&
  67        git pull -s ours . side &&
  68
  69        GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" &&
  70        GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" &&
  71        export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
  72
  73        for i in A B C; do echo $i; done >>file0 &&
  74        for i in 1 2; do echo $i; done >>dir/sub &&
  75        git update-index file0 dir/sub &&
  76
  77        git config log.showroot false &&
  78        git commit --amend &&
  79        git show-branch
  80'
  81
  82: <<\EOF
  83! [initial] Initial
  84 * [master] Merge branch 'side'
  85  ! [side] Side
  86---
  87 -  [master] Merge branch 'side'
  88 *+ [side] Side
  89 *  [master^] Second
  90+*+ [initial] Initial
  91EOF
  92
  93V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
  94while read cmd
  95do
  96        case "$cmd" in
  97        '' | '#'*) continue ;;
  98        esac
  99        test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
 100        cnt=`expr $test_count + 1`
 101        pfx=`printf "%04d" $cnt`
 102        expect="../t4013/diff.$test"
 103        actual="$pfx-diff.$test"
 104
 105        test_expect_success "git $cmd" '
 106                {
 107                        echo "\$ git $cmd"
 108                        git $cmd |
 109                        sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
 110                            -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
 111                        echo "\$"
 112                } >"$actual" &&
 113                if test -f "$expect"
 114                then
 115                        git diff "$expect" "$actual" &&
 116                        rm -f "$actual"
 117                else
 118                        # this is to help developing new tests.
 119                        cp "$actual" "$expect"
 120                        false
 121                fi
 122        '
 123done <<\EOF
 124diff-tree initial
 125diff-tree -r initial
 126diff-tree -r --abbrev initial
 127diff-tree -r --abbrev=4 initial
 128diff-tree --root initial
 129diff-tree --root --abbrev initial
 130diff-tree --root -r initial
 131diff-tree --root -r --abbrev initial
 132diff-tree --root -r --abbrev=4 initial
 133diff-tree -p initial
 134diff-tree --root -p initial
 135diff-tree --patch-with-stat initial
 136diff-tree --root --patch-with-stat initial
 137diff-tree --patch-with-raw initial
 138diff-tree --root --patch-with-raw initial
 139
 140diff-tree --pretty initial
 141diff-tree --pretty --root initial
 142diff-tree --pretty -p initial
 143diff-tree --pretty --stat initial
 144diff-tree --pretty --summary initial
 145diff-tree --pretty --stat --summary initial
 146diff-tree --pretty --root -p initial
 147diff-tree --pretty --root --stat initial
 148# improved by Timo's patch
 149diff-tree --pretty --root --summary initial
 150# improved by Timo's patch
 151diff-tree --pretty --root --summary -r initial
 152diff-tree --pretty --root --stat --summary initial
 153diff-tree --pretty --patch-with-stat initial
 154diff-tree --pretty --root --patch-with-stat initial
 155diff-tree --pretty --patch-with-raw initial
 156diff-tree --pretty --root --patch-with-raw initial
 157
 158diff-tree --pretty=oneline initial
 159diff-tree --pretty=oneline --root initial
 160diff-tree --pretty=oneline -p initial
 161diff-tree --pretty=oneline --root -p initial
 162diff-tree --pretty=oneline --patch-with-stat initial
 163# improved by Timo's patch
 164diff-tree --pretty=oneline --root --patch-with-stat initial
 165diff-tree --pretty=oneline --patch-with-raw initial
 166diff-tree --pretty=oneline --root --patch-with-raw initial
 167
 168diff-tree --pretty side
 169diff-tree --pretty -p side
 170diff-tree --pretty --patch-with-stat side
 171
 172diff-tree master
 173diff-tree -p master
 174diff-tree -p -m master
 175diff-tree -c master
 176diff-tree -c --abbrev master
 177diff-tree --cc master
 178# stat only should show the diffstat with the first parent
 179diff-tree -c --stat master
 180diff-tree --cc --stat master
 181diff-tree -c --stat --summary master
 182diff-tree --cc --stat --summary master
 183# stat summary should show the diffstat and summary with the first parent
 184diff-tree -c --stat --summary side
 185diff-tree --cc --stat --summary side
 186# improved by Timo's patch
 187diff-tree --cc --patch-with-stat master
 188# improved by Timo's patch
 189diff-tree --cc --patch-with-stat --summary master
 190# this is correct
 191diff-tree --cc --patch-with-stat --summary side
 192
 193log master
 194log -p master
 195log --root master
 196log --root -p master
 197log --patch-with-stat master
 198log --root --patch-with-stat master
 199log --root --patch-with-stat --summary master
 200# improved by Timo's patch
 201log --root -c --patch-with-stat --summary master
 202# improved by Timo's patch
 203log --root --cc --patch-with-stat --summary master
 204log -SF master
 205log -SF -p master
 206
 207whatchanged master
 208whatchanged -p master
 209whatchanged --root master
 210whatchanged --root -p master
 211whatchanged --patch-with-stat master
 212whatchanged --root --patch-with-stat master
 213whatchanged --root --patch-with-stat --summary master
 214# improved by Timo's patch
 215whatchanged --root -c --patch-with-stat --summary master
 216# improved by Timo's patch
 217whatchanged --root --cc --patch-with-stat --summary master
 218whatchanged -SF master
 219whatchanged -SF -p master
 220
 221log --patch-with-stat master -- dir/
 222whatchanged --patch-with-stat master -- dir/
 223log --patch-with-stat --summary master -- dir/
 224whatchanged --patch-with-stat --summary master -- dir/
 225
 226show initial
 227show --root initial
 228show side
 229show master
 230show --stat side
 231show --stat --summary side
 232show --patch-with-stat side
 233show --patch-with-raw side
 234show --patch-with-stat --summary side
 235
 236format-patch --stdout initial..side
 237format-patch --stdout initial..master^
 238format-patch --stdout initial..master
 239format-patch --attach --stdout initial..side
 240format-patch --attach --stdout initial..master^
 241format-patch --attach --stdout initial..master
 242format-patch --inline --stdout initial..side
 243format-patch --inline --stdout initial..master^
 244format-patch --inline --stdout initial..master
 245format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
 246config format.subjectprefix DIFFERENT_PREFIX
 247format-patch --inline --stdout initial..master^^
 248
 249diff --abbrev initial..side
 250diff -r initial..side
 251diff --stat initial..side
 252diff -r --stat initial..side
 253diff initial..side
 254diff --patch-with-stat initial..side
 255diff --patch-with-raw initial..side
 256diff --patch-with-stat -r initial..side
 257diff --patch-with-raw -r initial..side
 258diff --name-status dir2 dir
 259EOF
 260
 261test_done