t / t3700-add.shon commit gitweb: Fix shortlog only showing HEAD revision. (d222984)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Carl D. Worth
   4#
   5
   6test_description='Test of git-add, including the -- option.'
   7
   8. ./test-lib.sh
   9
  10test_expect_success \
  11    'Test of git-add' \
  12    'touch foo && git-add foo'
  13
  14test_expect_success \
  15    'Post-check that foo is in the index' \
  16    'git-ls-files foo | grep foo'
  17
  18test_expect_success \
  19    'Test that "git-add -- -q" works' \
  20    'touch -- -q && git-add -- -q'
  21
  22test_expect_success \
  23        'git-add: Test that executable bit is not used if core.filemode=0' \
  24        'git repo-config core.filemode 0 &&
  25         echo foo >xfoo1 &&
  26         chmod 755 xfoo1 &&
  27         git-add xfoo1 &&
  28         case "`git-ls-files --stage xfoo1`" in
  29         100644" "*xfoo1) echo ok;;
  30         *) echo fail; git-ls-files --stage xfoo1; (exit 1);;
  31         esac'
  32
  33test_expect_success \
  34        'git-update-index --add: Test that executable bit is not used...' \
  35        'git repo-config core.filemode 0 &&
  36         echo foo >xfoo2 &&
  37         chmod 755 xfoo2 &&
  38         git-update-index --add xfoo2 &&
  39         case "`git-ls-files --stage xfoo2`" in
  40         100644" "*xfoo2) echo ok;;
  41         *) echo fail; git-ls-files --stage xfoo2; (exit 1);;
  42         esac'
  43
  44test_expect_success \
  45        'git-update-index --add: Test that executable bit is not used...' \
  46        'git repo-config core.filemode 0 &&
  47         ln -s xfoo2 xfoo3 &&
  48         git-update-index --add xfoo3 &&
  49         case "`git-ls-files --stage xfoo3`" in
  50         120000" "*xfoo3) echo ok;;
  51         *) echo fail; git-ls-files --stage xfoo3; (exit 1);;
  52         esac'
  53
  54test_expect_success '.gitignore test setup' '
  55        echo "*.ig" >.gitignore &&
  56        mkdir c.if d.ig &&
  57        >a.ig && >b.if &&
  58        >c.if/c.if && >c.if/c.ig &&
  59        >d.ig/d.if && >d.ig/d.ig
  60'
  61
  62test_expect_success '.gitignore is honored' '
  63        git-add . &&
  64        ! git-ls-files | grep "\\.ig"
  65'
  66
  67test_expect_success 'error out when attempting to add ignored ones without -f' '
  68        ! git-add a.?? &&
  69        ! git-ls-files | grep "\\.ig"
  70'
  71
  72test_expect_success 'error out when attempting to add ignored ones without -f' '
  73        ! git-add d.?? &&
  74        ! git-ls-files | grep "\\.ig"
  75'
  76
  77test_expect_success 'add ignored ones with -f' '
  78        git-add -f a.?? &&
  79        git-ls-files --error-unmatch a.ig
  80'
  81
  82test_expect_success 'add ignored ones with -f' '
  83        git-add -f d.??/* &&
  84        git-ls-files --error-unmatch d.ig/d.if d.ig/d.ig
  85'
  86
  87test_done