t / t5580-clone-push-unc.shon commit Merge branch 'sb/trailers-docfix' (ae4e3f4)
   1#!/bin/sh
   2
   3test_description='various Windows-only path tests'
   4. ./test-lib.sh
   5
   6if test_have_prereq CYGWIN
   7then
   8        alias winpwd='cygpath -aw .'
   9elif test_have_prereq MINGW
  10then
  11        alias winpwd=pwd
  12else
  13        skip_all='skipping Windows-only path tests'
  14        test_done
  15fi
  16
  17UNCPATH="$(winpwd)"
  18case "$UNCPATH" in
  19[A-Z]:*)
  20        # Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git
  21        # (we use forward slashes here because MSYS2 and Git accept them, and
  22        # they are easier on the eyes)
  23        UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}"
  24        test -d "$UNCPATH" || {
  25                skip_all='could not access administrative share; skipping'
  26                test_done
  27        }
  28        ;;
  29*)
  30        skip_all='skipping UNC path tests, cannot determine current path as UNC'
  31        test_done
  32        ;;
  33esac
  34
  35test_expect_success setup '
  36        test_commit initial
  37'
  38
  39test_expect_success clone '
  40        git clone "file://$UNCPATH" clone
  41'
  42
  43test_expect_success push '
  44        (
  45                cd clone &&
  46                git checkout -b to-push &&
  47                test_commit to-push &&
  48                git push origin HEAD
  49        ) &&
  50        rev="$(git -C clone rev-parse --verify refs/heads/to-push)" &&
  51        test "$rev" = "$(git rev-parse --verify refs/heads/to-push)"
  52'
  53
  54test_expect_success MINGW 'remote nick cannot contain backslashes' '
  55        BACKSLASHED="$(winpwd | tr / \\\\)" &&
  56        git ls-remote "$BACKSLASHED" >out 2>err &&
  57        test_i18ngrep ! "unable to access" err
  58'
  59
  60test_done