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