Merge branch 'jk/bash-completion'
authorJunio C Hamano <gitster@pobox.com>
Thu, 11 Jul 2013 20:05:28 +0000 (13:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Jul 2013 20:05:28 +0000 (13:05 -0700)
* jk/bash-completion:
completion: learn about --man-path
completion: handle unstuck form of base git options

1  2 
contrib/completion/git-completion.bash
t/t9902-completion.sh
index ebc40d4845586bcdd7df8f02c34db9b157cfe149,b13c880e9ac586ea4db16388565f1e91bd82fa78..fa3ae1e8535c786dc724ab7a73cccb6f3bfca8de
@@@ -33,6 -33,8 +33,6 @@@ esa
  # returns location of .git repo
  __gitdir ()
  {
 -      # Note: this function is duplicated in git-prompt.sh
 -      # When updating it, make sure you update the other one to match.
        if [ -z "${1-}" ]; then
                if [ -n "${__git_dir-}" ]; then
                        echo "$__git_dir"
@@@ -2490,9 -2492,10 +2490,10 @@@ __git_main (
                i="${words[c]}"
                case "$i" in
                --git-dir=*) __git_dir="${i#--git-dir=}" ;;
+               --git-dir)   ((c++)) ; __git_dir="${words[c]}" ;;
                --bare)      __git_dir="." ;;
                --help) command="help"; break ;;
-               -c) c=$((++c)) ;;
+               -c|--work-tree|--namespace) ((c++)) ;;
                -*) ;;
                *) command="$i"; break ;;
                esac
                        --exec-path
                        --exec-path=
                        --html-path
+                       --man-path
                        --info-path
                        --work-tree=
                        --namespace=
diff --combined t/t9902-completion.sh
index 5469dee8d1f39e6cae4205501a774d36913fff73,14d605af1ab469aeed3c7f929e7a06e0aae6bb6b..d9e3103af597ec1f21ea56ca18500fbfcc8c2563
@@@ -122,140 -122,6 +122,140 @@@ test_gitcomp_nl (
  
  invalid_variable_name='${foo.bar}'
  
 +actual="$TRASH_DIRECTORY/actual"
 +
 +test_expect_success 'setup for __gitdir tests' '
 +      mkdir -p subdir/subsubdir &&
 +      git init otherrepo
 +'
 +
 +test_expect_success '__gitdir - from command line (through $__git_dir)' '
 +      echo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&
 +      (
 +              __git_dir="$TRASH_DIRECTORY/otherrepo/.git" &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - repo as argument' '
 +      echo "otherrepo/.git" >expected &&
 +      __gitdir "otherrepo" >"$actual" &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - remote as argument' '
 +      echo "remote" >expected &&
 +      __gitdir "remote" >"$actual" &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - .git directory in cwd' '
 +      echo ".git" >expected &&
 +      __gitdir >"$actual" &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - .git directory in parent' '
 +      echo "$(pwd -P)/.git" >expected &&
 +      (
 +              cd subdir/subsubdir &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - cwd is a .git directory' '
 +      echo "." >expected &&
 +      (
 +              cd .git &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - parent is a .git directory' '
 +      echo "$(pwd -P)/.git" >expected &&
 +      (
 +              cd .git/refs/heads &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - $GIT_DIR set while .git directory in cwd' '
 +      echo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&
 +      (
 +              GIT_DIR="$TRASH_DIRECTORY/otherrepo/.git" &&
 +              export GIT_DIR &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - $GIT_DIR set while .git directory in parent' '
 +      echo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&
 +      (
 +              GIT_DIR="$TRASH_DIRECTORY/otherrepo/.git" &&
 +              export GIT_DIR &&
 +              cd subdir &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - non-existing $GIT_DIR' '
 +      (
 +              GIT_DIR="$TRASH_DIRECTORY/non-existing" &&
 +              export GIT_DIR &&
 +              test_must_fail __gitdir
 +      )
 +'
 +
 +test_expect_success '__gitdir - gitfile in cwd' '
 +      echo "$(pwd -P)/otherrepo/.git" >expected &&
 +      echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" >subdir/.git &&
 +      test_when_finished "rm -f subdir/.git" &&
 +      (
 +              cd subdir &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - gitfile in parent' '
 +      echo "$(pwd -P)/otherrepo/.git" >expected &&
 +      echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" >subdir/.git &&
 +      test_when_finished "rm -f subdir/.git" &&
 +      (
 +              cd subdir/subsubdir &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success SYMLINKS '__gitdir - resulting path avoids symlinks' '
 +      echo "$(pwd -P)/otherrepo/.git" >expected &&
 +      mkdir otherrepo/dir &&
 +      test_when_finished "rm -rf otherrepo/dir" &&
 +      ln -s otherrepo/dir link &&
 +      test_when_finished "rm -f link" &&
 +      (
 +              cd link &&
 +              __gitdir >"$actual"
 +      ) &&
 +      test_cmp expected "$actual"
 +'
 +
 +test_expect_success '__gitdir - not a git repository' '
 +      (
 +              cd subdir/subsubdir &&
 +              GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY" &&
 +              export GIT_CEILING_DIRECTORIES &&
 +              test_must_fail __gitdir
 +      )
 +'
 +
  test_expect_success '__gitcomp - trailing space - options' '
        test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
                --reset-author" <<-EOF
@@@ -365,6 -231,7 +365,7 @@@ test_expect_success 'double dash "git" 
        --exec-path Z
        --exec-path=
        --html-path Z
+       --man-path Z
        --info-path Z
        --work-tree=
        --namespace=