t / t4016-diff-quote.shon commit diff --stat: add a test for output with COLUMNS=40 (c4432d5)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Junio C Hamano
   4#
   5
   6test_description='Quoting paths in diff output.
   7'
   8
   9. ./test-lib.sh
  10
  11P0='pathname'
  12P1='pathname    with HT'
  13P2='pathname with SP'
  14P3='pathname
  15with LF'
  16if : 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1"
  17then
  18        test_set_prereq TABS_IN_FILENAMES
  19else
  20        say 'Your filesystem does not allow tabs in filenames'
  21fi
  22
  23test_expect_success TABS_IN_FILENAMES setup '
  24        echo P0.0 >"$P0.0" &&
  25        echo P0.1 >"$P0.1" &&
  26        echo P0.2 >"$P0.2" &&
  27        echo P0.3 >"$P0.3" &&
  28        echo P1.0 >"$P1.0" &&
  29        echo P1.2 >"$P1.2" &&
  30        echo P1.3 >"$P1.3" &&
  31        git add . &&
  32        git commit -m initial &&
  33        git mv "$P0.0" "R$P0.0" &&
  34        git mv "$P0.1" "R$P1.0" &&
  35        git mv "$P0.2" "R$P2.0" &&
  36        git mv "$P0.3" "R$P3.0" &&
  37        git mv "$P1.0" "R$P0.1" &&
  38        git mv "$P1.2" "R$P2.1" &&
  39        git mv "$P1.3" "R$P3.1" &&
  40        :
  41'
  42
  43test_expect_success TABS_IN_FILENAMES 'setup expected files' '
  44cat >expect <<\EOF
  45 rename pathname.1 => "Rpathname\twith HT.0" (100%)
  46 rename pathname.3 => "Rpathname\nwith LF.0" (100%)
  47 rename "pathname\twith HT.3" => "Rpathname\nwith LF.1" (100%)
  48 rename pathname.2 => Rpathname with SP.0 (100%)
  49 rename "pathname\twith HT.2" => Rpathname with SP.1 (100%)
  50 rename pathname.0 => Rpathname.0 (100%)
  51 rename "pathname\twith HT.0" => Rpathname.1 (100%)
  52EOF
  53'
  54
  55test_expect_success TABS_IN_FILENAMES 'git diff --summary -M HEAD' '
  56        git diff --summary -M HEAD >actual &&
  57        test_cmp expect actual
  58'
  59
  60test_expect_success TABS_IN_FILENAMES 'setup expected files' '
  61cat >expect <<\EOF
  62 pathname.1 => "Rpathname\twith HT.0"            |    0
  63 pathname.3 => "Rpathname\nwith LF.0"            |    0
  64 "pathname\twith HT.3" => "Rpathname\nwith LF.1" |    0
  65 pathname.2 => Rpathname with SP.0               |    0
  66 "pathname\twith HT.2" => Rpathname with SP.1    |    0
  67 pathname.0 => Rpathname.0                       |    0
  68 "pathname\twith HT.0" => Rpathname.1            |    0
  69 7 files changed, 0 insertions(+), 0 deletions(-)
  70EOF
  71'
  72
  73test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' '
  74        git diff --stat -M HEAD >actual &&
  75        test_cmp expect actual
  76'
  77
  78test_done