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