t / t3600-rm.shon commit Merge branch 'maint' (2486927)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Carl D. Worth
   4#
   5
   6test_description='Test of the various options to git-rm.'
   7
   8. ./test-lib.sh
   9
  10# Setup some files to be removed, some with funny characters
  11touch -- foo bar baz 'space embedded' 'tab      embedded' 'newline
  12embedded' -q
  13git-add -- foo bar baz 'space embedded' 'tab    embedded' 'newline
  14embedded' -q
  15git-commit -m "add files"
  16
  17test_expect_success \
  18    'Pre-check that foo exists and is in index before git-rm foo' \
  19    '[ -f foo ] && git-ls-files --error-unmatch foo'
  20
  21test_expect_success \
  22    'Test that git-rm foo succeeds' \
  23    'git-rm foo'
  24
  25test_expect_success \
  26    'Post-check that foo exists but is not in index after git-rm foo' \
  27    '[ -f foo ] && ! git-ls-files --error-unmatch foo'
  28
  29test_expect_success \
  30    'Pre-check that bar exists and is in index before "git-rm -f bar"' \
  31    '[ -f bar ] && git-ls-files --error-unmatch bar'
  32
  33test_expect_success \
  34    'Test that "git-rm -f bar" succeeds' \
  35    'git-rm -f bar'
  36
  37test_expect_success \
  38    'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \
  39    '! [ -f bar ] && ! git-ls-files --error-unmatch bar'
  40
  41test_expect_success \
  42    'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \
  43    'git-rm -- -q'
  44
  45test_expect_success \
  46    "Test that \"git-rm -f\" succeeds with embedded space, tab, or newline characters." \
  47    "git-rm -f 'space embedded' 'tab    embedded' 'newline
  48embedded'"
  49
  50chmod u-w .
  51test_expect_failure \
  52    'Test that "git-rm -f" fails if its rm fails' \
  53    'git-rm -f baz'
  54chmod u+w .
  55
  56test_expect_success \
  57    'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
  58    'git-ls-files --error-unmatch baz'
  59
  60test_done