t / t4013-diff-various.shon commit Fix behavior with non-commit upstream references (57ffc5f)
   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        mkdir dir3 &&
  78        cp dir/sub dir3/sub &&
  79        test-chmtime +1 dir3/sub &&
  80
  81        git config log.showroot false &&
  82        git commit --amend &&
  83        git show-branch
  84'
  85
  86: <<\EOF
  87! [initial] Initial
  88 * [master] Merge branch 'side'
  89  ! [side] Side
  90---
  91 -  [master] Merge branch 'side'
  92 *+ [side] Side
  93 *  [master^] Second
  94+*+ [initial] Initial
  95EOF
  96
  97V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
  98while read cmd
  99do
 100        case "$cmd" in
 101        '' | '#'*) continue ;;
 102        esac
 103        test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
 104        cnt=`expr $test_count + 1`
 105        pfx=`printf "%04d" $cnt`
 106        expect="$TEST_DIRECTORY/t4013/diff.$test"
 107        actual="$pfx-diff.$test"
 108
 109        test_expect_success "git $cmd" '
 110                {
 111                        echo "\$ git $cmd"
 112                        git $cmd |
 113                        sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
 114                            -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
 115                        echo "\$"
 116                } >"$actual" &&
 117                if test -f "$expect"
 118                then
 119                        test_cmp "$expect" "$actual" &&
 120                        rm -f "$actual"
 121                else
 122                        # this is to help developing new tests.
 123                        cp "$actual" "$expect"
 124                        false
 125                fi
 126        '
 127done <<\EOF
 128diff-tree initial
 129diff-tree -r initial
 130diff-tree -r --abbrev initial
 131diff-tree -r --abbrev=4 initial
 132diff-tree --root initial
 133diff-tree --root --abbrev initial
 134diff-tree --root -r initial
 135diff-tree --root -r --abbrev initial
 136diff-tree --root -r --abbrev=4 initial
 137diff-tree -p initial
 138diff-tree --root -p initial
 139diff-tree --patch-with-stat initial
 140diff-tree --root --patch-with-stat initial
 141diff-tree --patch-with-raw initial
 142diff-tree --root --patch-with-raw initial
 143
 144diff-tree --pretty initial
 145diff-tree --pretty --root initial
 146diff-tree --pretty -p initial
 147diff-tree --pretty --stat initial
 148diff-tree --pretty --summary initial
 149diff-tree --pretty --stat --summary initial
 150diff-tree --pretty --root -p initial
 151diff-tree --pretty --root --stat initial
 152# improved by Timo's patch
 153diff-tree --pretty --root --summary initial
 154# improved by Timo's patch
 155diff-tree --pretty --root --summary -r initial
 156diff-tree --pretty --root --stat --summary initial
 157diff-tree --pretty --patch-with-stat initial
 158diff-tree --pretty --root --patch-with-stat initial
 159diff-tree --pretty --patch-with-raw initial
 160diff-tree --pretty --root --patch-with-raw initial
 161
 162diff-tree --pretty=oneline initial
 163diff-tree --pretty=oneline --root initial
 164diff-tree --pretty=oneline -p initial
 165diff-tree --pretty=oneline --root -p initial
 166diff-tree --pretty=oneline --patch-with-stat initial
 167# improved by Timo's patch
 168diff-tree --pretty=oneline --root --patch-with-stat initial
 169diff-tree --pretty=oneline --patch-with-raw initial
 170diff-tree --pretty=oneline --root --patch-with-raw initial
 171
 172diff-tree --pretty side
 173diff-tree --pretty -p side
 174diff-tree --pretty --patch-with-stat side
 175
 176diff-tree master
 177diff-tree -p master
 178diff-tree -p -m master
 179diff-tree -c master
 180diff-tree -c --abbrev master
 181diff-tree --cc master
 182# stat only should show the diffstat with the first parent
 183diff-tree -c --stat master
 184diff-tree --cc --stat master
 185diff-tree -c --stat --summary master
 186diff-tree --cc --stat --summary master
 187# stat summary should show the diffstat and summary with the first parent
 188diff-tree -c --stat --summary side
 189diff-tree --cc --stat --summary side
 190# improved by Timo's patch
 191diff-tree --cc --patch-with-stat master
 192# improved by Timo's patch
 193diff-tree --cc --patch-with-stat --summary master
 194# this is correct
 195diff-tree --cc --patch-with-stat --summary side
 196
 197log master
 198log -p master
 199log --root master
 200log --root -p master
 201log --patch-with-stat master
 202log --root --patch-with-stat master
 203log --root --patch-with-stat --summary master
 204# improved by Timo's patch
 205log --root -c --patch-with-stat --summary master
 206# improved by Timo's patch
 207log --root --cc --patch-with-stat --summary master
 208log -SF master
 209log -SF -p master
 210
 211whatchanged master
 212whatchanged -p master
 213whatchanged --root master
 214whatchanged --root -p master
 215whatchanged --patch-with-stat master
 216whatchanged --root --patch-with-stat master
 217whatchanged --root --patch-with-stat --summary master
 218# improved by Timo's patch
 219whatchanged --root -c --patch-with-stat --summary master
 220# improved by Timo's patch
 221whatchanged --root --cc --patch-with-stat --summary master
 222whatchanged -SF master
 223whatchanged -SF -p master
 224
 225log --patch-with-stat master -- dir/
 226whatchanged --patch-with-stat master -- dir/
 227log --patch-with-stat --summary master -- dir/
 228whatchanged --patch-with-stat --summary master -- dir/
 229
 230show initial
 231show --root initial
 232show side
 233show master
 234show --stat side
 235show --stat --summary side
 236show --patch-with-stat side
 237show --patch-with-raw side
 238show --patch-with-stat --summary side
 239
 240format-patch --stdout initial..side
 241format-patch --stdout initial..master^
 242format-patch --stdout initial..master
 243format-patch --stdout --no-numbered initial..master
 244format-patch --stdout --numbered initial..master
 245format-patch --attach --stdout initial..side
 246format-patch --attach --stdout initial..master^
 247format-patch --attach --stdout initial..master
 248format-patch --inline --stdout initial..side
 249format-patch --inline --stdout initial..master^
 250format-patch --inline --stdout initial..master
 251format-patch --inline --stdout initial..master
 252format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
 253config format.subjectprefix DIFFERENT_PREFIX
 254format-patch --inline --stdout initial..master^^
 255format-patch --stdout --cover-letter -n initial..master^
 256
 257diff --abbrev initial..side
 258diff -r initial..side
 259diff --stat initial..side
 260diff -r --stat initial..side
 261diff initial..side
 262diff --patch-with-stat initial..side
 263diff --patch-with-raw initial..side
 264diff --patch-with-stat -r initial..side
 265diff --patch-with-raw -r initial..side
 266diff --name-status dir2 dir
 267diff --no-index --name-status dir2 dir
 268diff --no-index --name-status -- dir2 dir
 269diff --no-index dir dir3
 270diff master master^ side
 271EOF
 272
 273test_done