t / t5303-hash-object.shon commit Merge branch 'jc/sha1-lookup' (e9f9d4f)
   1#!/bin/sh
   2
   3test_description=git-hash-object
   4
   5. ./test-lib.sh
   6
   7test_expect_success \
   8    'git hash-object -w --stdin saves the object' \
   9    'obname=$(echo foo | git hash-object -w --stdin) &&
  10    obpath=$(echo $obname | sed -e "s/\(..\)/\1\//") &&
  11    test -r .git/objects/"$obpath" &&
  12    rm -f .git/objects/"$obpath"'
  13    
  14test_expect_success \
  15    'git hash-object --stdin -w saves the object' \
  16    'obname=$(echo foo | git hash-object --stdin -w) &&
  17    obpath=$(echo $obname | sed -e "s/\(..\)/\1\//") &&
  18    test -r .git/objects/"$obpath" &&
  19    rm -f .git/objects/"$obpath"'    
  20
  21test_expect_success \
  22    'git hash-object --stdin file1 <file0 first operates on file0, then file1' \
  23    'echo foo > file1 &&
  24    obname0=$(echo bar | git hash-object --stdin) &&
  25    obname1=$(git hash-object file1) &&
  26    obname0new=$(echo bar | git hash-object --stdin file1 | sed -n -e 1p) &&
  27    obname1new=$(echo bar | git hash-object --stdin file1 | sed -n -e 2p) &&
  28    test "$obname0" = "$obname0new" &&
  29    test "$obname1" = "$obname1new"'
  30
  31test_expect_success \
  32    'git hash-object refuses multiple --stdin arguments' \
  33    '! git hash-object --stdin --stdin < file1'
  34
  35test_done