t / t9115-git-svn-dcommit-funky-renames.shon commit Merge branch 'md/url-parse-harden' (f9089e8)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Eric Wong
   4
   5
   6test_description='git svn dcommit can commit renames of files with ugly names'
   7
   8. ./lib-git-svn.sh
   9
  10test_expect_success 'load repository with strange names' '
  11        svnadmin load -q "$rawsvnrepo" <"$TEST_DIRECTORY"/t9115/funky-names.dump
  12'
  13
  14maybe_start_httpd gtk+
  15
  16test_expect_success 'init and fetch repository' '
  17        git svn init "$svnrepo" &&
  18        git svn fetch &&
  19        git reset --hard git-svn
  20        '
  21
  22test_expect_success 'create file in existing ugly and empty dir' '
  23        mkdir -p "#{bad_directory_name}" &&
  24        echo hi > "#{bad_directory_name}/ foo" &&
  25        git update-index --add "#{bad_directory_name}/ foo" &&
  26        git commit -m "new file in ugly parent" &&
  27        git svn dcommit
  28        '
  29
  30test_expect_success 'rename ugly file' '
  31        git mv "#{bad_directory_name}/ foo" "file name with feces" &&
  32        git commit -m "rename ugly file" &&
  33        git svn dcommit
  34        '
  35
  36test_expect_success 'rename pretty file' '
  37        echo :x > pretty &&
  38        git update-index --add pretty &&
  39        git commit -m "pretty :x" &&
  40        git svn dcommit &&
  41        mkdir -p regular_dir_name &&
  42        git mv pretty regular_dir_name/pretty &&
  43        git commit -m "moved pretty file" &&
  44        git svn dcommit
  45        '
  46
  47test_expect_success 'rename pretty file into ugly one' '
  48        git mv regular_dir_name/pretty "#{bad_directory_name}/ booboo" &&
  49        git commit -m booboo &&
  50        git svn dcommit
  51        '
  52
  53test_expect_success 'add a file with plus signs' '
  54        echo .. > +_+ &&
  55        git update-index --add +_+ &&
  56        git commit -m plus &&
  57        mkdir gtk+ &&
  58        git mv +_+ gtk+/_+_ &&
  59        git commit -m plus_dir &&
  60        git svn dcommit
  61        '
  62
  63test_expect_success 'clone the repository to test rebase' '
  64        git svn clone "$svnrepo" test-rebase &&
  65        (
  66                cd test-rebase &&
  67                echo test-rebase >test-rebase &&
  68                git add test-rebase &&
  69                git commit -m test-rebase
  70        )
  71        '
  72
  73test_expect_success 'make a commit to test rebase' '
  74                echo test-rebase-main > test-rebase-main &&
  75                git add test-rebase-main &&
  76                git commit -m test-rebase-main &&
  77                git svn dcommit
  78        '
  79
  80test_expect_success 'git svn rebase works inside a fresh-cloned repository' '
  81        (
  82                cd test-rebase &&
  83                git svn rebase &&
  84                test -e test-rebase-main &&
  85                test -e test-rebase
  86        )'
  87
  88# Without this, LC_ALL=C as set in test-lib.sh, and Cygwin converts
  89# non-ASCII characters in filenames unexpectedly, and causes errors.
  90# https://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-specialchars
  91# > Some characters are disallowed in filenames on Windows filesystems. ...
  92# ...
  93# > ... All of the above characters, except for the backslash, are converted
  94# > to special UNICODE characters in the range 0xf000 to 0xf0ff (the
  95# > "Private use area") when creating or accessing files.
  96prepare_a_utf8_locale
  97test_expect_success UTF8,!MINGW,!UTF8_NFD_TO_NFC 'svn.pathnameencoding=cp932 new file on dcommit' '
  98        LC_ALL=$a_utf8_locale &&
  99        export LC_ALL &&
 100        neq=$(printf "\201\202") &&
 101        git config svn.pathnameencoding cp932 &&
 102        echo neq >"$neq" &&
 103        git add "$neq" &&
 104        git commit -m "neq" &&
 105        git svn dcommit
 106'
 107
 108# See the comment on the above test for setting of LC_ALL.
 109test_expect_success !MINGW,!UTF8_NFD_TO_NFC 'svn.pathnameencoding=cp932 rename on dcommit' '
 110        LC_ALL=$a_utf8_locale &&
 111        export LC_ALL &&
 112        inf=$(printf "\201\207") &&
 113        git config svn.pathnameencoding cp932 &&
 114        echo inf >"$inf" &&
 115        git add "$inf" &&
 116        git commit -m "inf" &&
 117        git svn dcommit &&
 118        git mv "$inf" inf &&
 119        git commit -m "inf rename" &&
 120        git svn dcommit
 121'
 122
 123test_done