3 # Copyright (c) 2006 Junio C Hamano
 
   6 test_description='Various diff formatting options'
 
  13 test_expect_success setup '
 
  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 &&
 
  21         for i in 1 2 3; do echo $i; done >file0 &&
 
  22         for i in A B; do echo $i; done >dir/sub &&
 
  24         git add file0 file2 dir/sub &&
 
  25         git commit -m Initial &&
 
  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 &&
 
  34         for i in 4 5 6; do echo $i; done >>file0 &&
 
  35         for i in C D; do echo $i; done >>dir/sub &&
 
  37         git update-index --remove file0 file2 dir/sub &&
 
  38         git commit -m "Second${LF}${LF}This is the second commit." &&
 
  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 &&
 
  44         for i in A B C; do echo $i; done >file1 &&
 
  46         for i in E F; do echo $i; done >>dir/sub &&
 
  47         git update-index dir/sub &&
 
  48         git commit -m Third &&
 
  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 &&
 
  55         for i in A B C; do echo $i; done >>file0 &&
 
  56         for i in 1 2; do echo $i; done >>dir/sub &&
 
  59         git update-index file0 dir/sub &&
 
  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 &&
 
  66         git checkout master &&
 
  67         git pull -s ours . side &&
 
  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 &&
 
  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 &&
 
  78         cp dir/sub dir3/sub &&
 
  79         test-chmtime +1 dir3/sub &&
 
  81         git config log.showroot false &&
 
  84         GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
 
  85         GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
 
  86         export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
 
  87         git checkout -b rearrange initial &&
 
  88         for i in B A; do echo $i; done >dir/sub &&
 
  90         git commit -m "Rearranged lines in dir/sub" &&
 
  91         git checkout master &&
 
  98  * [master] Merge branch 'side'
 
  99   ! [rearrange] Rearranged lines in dir/sub
 
 102   +  [rearrange] Rearranged lines in dir/sub
 
 103  -   [master] Merge branch 'side'
 
 107 +*++ [initial] Initial
 
 110 V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
 
 114         '' | '#'*) continue ;;
 
 116         test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
 
 117         pfx=`printf "%04d" $test_count`
 
 118         expect="$TEST_DIRECTORY/t4013/diff.$test"
 
 119         actual="$pfx-diff.$test"
 
 121         test_expect_success "git $cmd" '
 
 125                         sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
 
 126                             -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
 
 131                         test_cmp "$expect" "$actual" &&
 
 134                         # this is to help developing new tests.
 
 135                         cp "$actual" "$expect"
 
 142 diff-tree -r --abbrev initial
 
 143 diff-tree -r --abbrev=4 initial
 
 144 diff-tree --root initial
 
 145 diff-tree --root --abbrev initial
 
 146 diff-tree --root -r initial
 
 147 diff-tree --root -r --abbrev initial
 
 148 diff-tree --root -r --abbrev=4 initial
 
 150 diff-tree --root -p initial
 
 151 diff-tree --patch-with-stat initial
 
 152 diff-tree --root --patch-with-stat initial
 
 153 diff-tree --patch-with-raw initial
 
 154 diff-tree --root --patch-with-raw initial
 
 156 diff-tree --pretty initial
 
 157 diff-tree --pretty --root initial
 
 158 diff-tree --pretty -p initial
 
 159 diff-tree --pretty --stat initial
 
 160 diff-tree --pretty --summary initial
 
 161 diff-tree --pretty --stat --summary initial
 
 162 diff-tree --pretty --root -p initial
 
 163 diff-tree --pretty --root --stat initial
 
 164 # improved by Timo's patch
 
 165 diff-tree --pretty --root --summary initial
 
 166 # improved by Timo's patch
 
 167 diff-tree --pretty --root --summary -r initial
 
 168 diff-tree --pretty --root --stat --summary initial
 
 169 diff-tree --pretty --patch-with-stat initial
 
 170 diff-tree --pretty --root --patch-with-stat initial
 
 171 diff-tree --pretty --patch-with-raw initial
 
 172 diff-tree --pretty --root --patch-with-raw initial
 
 174 diff-tree --pretty=oneline initial
 
 175 diff-tree --pretty=oneline --root initial
 
 176 diff-tree --pretty=oneline -p initial
 
 177 diff-tree --pretty=oneline --root -p initial
 
 178 diff-tree --pretty=oneline --patch-with-stat initial
 
 179 # improved by Timo's patch
 
 180 diff-tree --pretty=oneline --root --patch-with-stat initial
 
 181 diff-tree --pretty=oneline --patch-with-raw initial
 
 182 diff-tree --pretty=oneline --root --patch-with-raw initial
 
 184 diff-tree --pretty side
 
 185 diff-tree --pretty -p side
 
 186 diff-tree --pretty --patch-with-stat side
 
 190 diff-tree -p -m master
 
 192 diff-tree -c --abbrev master
 
 193 diff-tree --cc master
 
 194 # stat only should show the diffstat with the first parent
 
 195 diff-tree -c --stat master
 
 196 diff-tree --cc --stat master
 
 197 diff-tree -c --stat --summary master
 
 198 diff-tree --cc --stat --summary master
 
 199 # stat summary should show the diffstat and summary with the first parent
 
 200 diff-tree -c --stat --summary side
 
 201 diff-tree --cc --stat --summary side
 
 202 # improved by Timo's patch
 
 203 diff-tree --cc --patch-with-stat master
 
 204 # improved by Timo's patch
 
 205 diff-tree --cc --patch-with-stat --summary master
 
 207 diff-tree --cc --patch-with-stat --summary side
 
 213 log --patch-with-stat master
 
 214 log --root --patch-with-stat master
 
 215 log --root --patch-with-stat --summary master
 
 216 # improved by Timo's patch
 
 217 log --root -c --patch-with-stat --summary master
 
 218 # improved by Timo's patch
 
 219 log --root --cc --patch-with-stat --summary master
 
 220 log -p --first-parent master
 
 221 log -m -p --first-parent master
 
 226 log -SF master --max-count=0
 
 227 log -SF master --max-count=1
 
 228 log -SF master --max-count=2
 
 231 log -GF -p --pickaxe-all master
 
 233 log --decorate=full --all
 
 235 rev-list --parents HEAD
 
 236 rev-list --children HEAD
 
 239 whatchanged -p master
 
 240 whatchanged --root master
 
 241 whatchanged --root -p master
 
 242 whatchanged --patch-with-stat master
 
 243 whatchanged --root --patch-with-stat master
 
 244 whatchanged --root --patch-with-stat --summary master
 
 245 # improved by Timo's patch
 
 246 whatchanged --root -c --patch-with-stat --summary master
 
 247 # improved by Timo's patch
 
 248 whatchanged --root --cc --patch-with-stat --summary master
 
 249 whatchanged -SF master
 
 250 whatchanged -SF -p master
 
 252 log --patch-with-stat master -- dir/
 
 253 whatchanged --patch-with-stat master -- dir/
 
 254 log --patch-with-stat --summary master -- dir/
 
 255 whatchanged --patch-with-stat --summary master -- dir/
 
 263 show --first-parent master
 
 265 show --stat --summary side
 
 266 show --patch-with-stat side
 
 267 show --patch-with-raw side
 
 268 show --patch-with-stat --summary side
 
 270 format-patch --stdout initial..side
 
 271 format-patch --stdout initial..master^
 
 272 format-patch --stdout initial..master
 
 273 format-patch --stdout --no-numbered initial..master
 
 274 format-patch --stdout --numbered initial..master
 
 275 format-patch --attach --stdout initial..side
 
 276 format-patch --attach --stdout --suffix=.diff initial..side
 
 277 format-patch --attach --stdout initial..master^
 
 278 format-patch --attach --stdout initial..master
 
 279 format-patch --inline --stdout initial..side
 
 280 format-patch --inline --stdout initial..master^
 
 281 format-patch --inline --stdout --numbered-files initial..master
 
 282 format-patch --inline --stdout initial..master
 
 283 format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
 
 284 config format.subjectprefix DIFFERENT_PREFIX
 
 285 format-patch --inline --stdout initial..master^^
 
 286 format-patch --stdout --cover-letter -n initial..master^
 
 288 diff --abbrev initial..side
 
 289 diff -r initial..side
 
 290 diff --stat initial..side
 
 291 diff -r --stat initial..side
 
 293 diff --patch-with-stat initial..side
 
 294 diff --patch-with-raw initial..side
 
 295 diff --patch-with-stat -r initial..side
 
 296 diff --patch-with-raw -r initial..side
 
 297 diff --name-status dir2 dir
 
 298 diff --no-index --name-status dir2 dir
 
 299 diff --no-index --name-status -- dir2 dir
 
 300 diff --no-index dir dir3
 
 301 diff master master^ side
 
 302 diff --dirstat master~1 master~2
 
 303 diff --dirstat initial rearrange
 
 304 diff --dirstat-by-file initial rearrange
 
 307 test_expect_success 'log -S requires an argument' '
 
 308         test_must_fail git log -S
 
 311 test_expect_success 'diff --cached on unborn branch' '
 
 312         echo ref: refs/heads/unborn >.git/HEAD &&
 
 313         git diff --cached >result &&
 
 314         test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result
 
 317 test_expect_success 'diff --cached -- file on unborn branch' '
 
 318         git diff --cached -- file0 >result &&
 
 319         test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result