t / t5001-archive-attr.shon commit Fix severe breakage in "git-apply --whitespace=fix" (422a82f)
   1#!/bin/sh
   2
   3test_description='git archive attribute tests'
   4
   5. ./test-lib.sh
   6
   7SUBSTFORMAT=%H%n
   8
   9test_expect_exists() {
  10        test_expect_success " $1 exists" "test -e $1"
  11}
  12
  13test_expect_missing() {
  14        test_expect_success " $1 does not exist" "test ! -e $1"
  15}
  16
  17test_expect_success 'setup' '
  18        echo ignored >ignored &&
  19        echo ignored export-ignore >>.git/info/attributes &&
  20        git add ignored &&
  21
  22        echo ignored by tree >ignored-by-tree &&
  23        echo ignored-by-tree export-ignore >.gitattributes &&
  24        git add ignored-by-tree .gitattributes &&
  25
  26        echo ignored by worktree >ignored-by-worktree &&
  27        echo ignored-by-worktree export-ignore >.gitattributes &&
  28        git add ignored-by-worktree &&
  29
  30        printf "A\$Format:%s\$O" "$SUBSTFORMAT" >nosubstfile &&
  31        printf "A\$Format:%s\$O" "$SUBSTFORMAT" >substfile1 &&
  32        printf "A not substituted O" >substfile2 &&
  33        echo "substfile?" export-subst >>.git/info/attributes &&
  34        git add nosubstfile substfile1 substfile2 &&
  35
  36        git commit -m. &&
  37
  38        git clone --bare . bare &&
  39        cp .git/info/attributes bare/info/attributes
  40'
  41
  42test_expect_success 'git archive' '
  43        git archive HEAD >archive.tar &&
  44        (mkdir archive && cd archive && "$TAR" xf -) <archive.tar
  45'
  46
  47test_expect_missing     archive/ignored
  48test_expect_missing     archive/ignored-by-tree
  49test_expect_exists      archive/ignored-by-worktree
  50
  51test_expect_success 'git archive with worktree attributes' '
  52        git archive --worktree-attributes HEAD >worktree.tar &&
  53        (mkdir worktree && cd worktree && "$TAR" xf -) <worktree.tar
  54'
  55
  56test_expect_missing     worktree/ignored
  57test_expect_exists      worktree/ignored-by-tree
  58test_expect_missing     worktree/ignored-by-worktree
  59
  60test_expect_success 'git archive vs. bare' '
  61        (cd bare && git archive HEAD) >bare-archive.tar &&
  62        test_cmp archive.tar bare-archive.tar
  63'
  64
  65test_expect_success 'git archive with worktree attributes, bare' '
  66        (cd bare && git archive --worktree-attributes HEAD) >bare-worktree.tar &&
  67        (mkdir bare-worktree && cd bare-worktree && "$TAR" xf -) <bare-worktree.tar
  68'
  69
  70test_expect_missing     bare-worktree/ignored
  71test_expect_exists      bare-worktree/ignored-by-tree
  72test_expect_exists      bare-worktree/ignored-by-worktree
  73
  74test_expect_success 'export-subst' '
  75        git log "--pretty=format:A${SUBSTFORMAT}O" HEAD >substfile1.expected &&
  76        test_cmp nosubstfile archive/nosubstfile &&
  77        test_cmp substfile1.expected archive/substfile1 &&
  78        test_cmp substfile2 archive/substfile2
  79'
  80
  81test_expect_success 'git tar-tree vs. git archive with worktree attributes' '
  82        git tar-tree HEAD >tar-tree.tar &&
  83        test_cmp worktree.tar tar-tree.tar
  84'
  85
  86test_expect_success 'git tar-tree vs. git archive with worktree attrs, bare' '
  87        (cd bare && git tar-tree HEAD) >bare-tar-tree.tar &&
  88        test_cmp bare-worktree.tar bare-tar-tree.tar
  89'
  90
  91test_done