t / t9101-git-svn-props.shon commit gitweb: Convert project name to UTF-8 (0417941)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Eric Wong
   4#
   5
   6test_description='git-svn property tests'
   7. ./lib-git-svn.sh
   8
   9mkdir import
  10
  11a_crlf=
  12a_lf=
  13a_cr=
  14a_ne_crlf=
  15a_ne_lf=
  16a_ne_cr=
  17a_empty=
  18a_empty_lf=
  19a_empty_cr=
  20a_empty_crlf=
  21
  22cd import
  23        cat >> kw.c <<\EOF
  24/* Somebody prematurely put a keyword into this file */
  25/* $Id$ */
  26EOF
  27
  28        printf "Hello\r\nWorld\r\n" > crlf
  29        a_crlf=`git-hash-object -w crlf`
  30        printf "Hello\rWorld\r" > cr
  31        a_cr=`git-hash-object -w cr`
  32        printf "Hello\nWorld\n" > lf
  33        a_lf=`git-hash-object -w lf`
  34
  35        printf "Hello\r\nWorld" > ne_crlf
  36        a_ne_crlf=`git-hash-object -w ne_crlf`
  37        printf "Hello\nWorld" > ne_lf
  38        a_ne_lf=`git-hash-object -w ne_lf`
  39        printf "Hello\rWorld" > ne_cr
  40        a_ne_cr=`git-hash-object -w ne_cr`
  41
  42        touch empty
  43        a_empty=`git-hash-object -w empty`
  44        printf "\n" > empty_lf
  45        a_empty_lf=`git-hash-object -w empty_lf`
  46        printf "\r" > empty_cr
  47        a_empty_cr=`git-hash-object -w empty_cr`
  48        printf "\r\n" > empty_crlf
  49        a_empty_crlf=`git-hash-object -w empty_crlf`
  50
  51        svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
  52cd ..
  53
  54rm -rf import
  55test_expect_success 'checkout working copy from svn' "svn co $svnrepo test_wc"
  56test_expect_success 'setup some commits to svn' \
  57        'cd test_wc &&
  58                echo Greetings >> kw.c &&
  59                svn commit -m "Not yet an Id" &&
  60                echo Hello world >> kw.c &&
  61                svn commit -m "Modified file, but still not yet an Id" &&
  62                svn propset svn:keywords Id kw.c &&
  63                svn commit -m "Propset Id"
  64        cd ..'
  65
  66test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
  67test_expect_success 'fetch revisions from svn' 'git-svn fetch'
  68
  69name='test svn:keywords ignoring'
  70test_expect_success "$name" \
  71        'git checkout -b mybranch remotes/git-svn &&
  72        echo Hi again >> kw.c &&
  73        git commit -a -m "test keywords ignoring" &&
  74        git-svn set-tree remotes/git-svn..mybranch &&
  75        git pull . remotes/git-svn'
  76
  77expect='/* $Id$ */'
  78got="`sed -ne 2p kw.c`"
  79test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'"
  80
  81test_expect_success "propset CR on crlf files" \
  82        'cd test_wc &&
  83                svn propset svn:eol-style CR empty &&
  84                svn propset svn:eol-style CR crlf &&
  85                svn propset svn:eol-style CR ne_crlf &&
  86                svn commit -m "propset CR on crlf files"
  87         cd ..'
  88
  89test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
  90        "git-svn fetch &&
  91         git pull . remotes/git-svn &&
  92         svn co $svnrepo new_wc"
  93
  94for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf
  95do
  96        test_expect_success "Comparing $i" "cmp $i new_wc/$i"
  97done
  98
  99
 100cd test_wc
 101        printf '$Id$\rHello\rWorld\r' > cr
 102        printf '$Id$\rHello\rWorld' > ne_cr
 103        a_cr=`printf '$Id$\r\nHello\r\nWorld\r\n' | git-hash-object --stdin`
 104        a_ne_cr=`printf '$Id$\r\nHello\r\nWorld' | git-hash-object --stdin`
 105        test_expect_success 'Set CRLF on cr files' \
 106        'svn propset svn:eol-style CRLF cr &&
 107         svn propset svn:eol-style CRLF ne_cr &&
 108         svn propset svn:keywords Id cr &&
 109         svn propset svn:keywords Id ne_cr &&
 110         svn commit -m "propset CRLF on cr files"'
 111cd ..
 112test_expect_success 'fetch and pull latest from svn' \
 113        'git-svn fetch && git pull . remotes/git-svn'
 114
 115b_cr="`git-hash-object cr`"
 116b_ne_cr="`git-hash-object ne_cr`"
 117
 118test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'"
 119test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'"
 120
 121test_done