t / t9106-git-svn-commit-diff-clobber.shon commit check_filename: tighten dwim-wildcard ambiguity (df714f8)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Eric Wong
   4test_description='git svn commit-diff clobber'
   5. ./lib-git-svn.sh
   6
   7test_expect_success 'initialize repo' '
   8        mkdir import &&
   9        (
  10                cd import &&
  11                echo initial >file &&
  12                svn_cmd import -m "initial" . "$svnrepo"
  13        ) &&
  14        echo initial > file &&
  15        git update-index --add file &&
  16        git commit -a -m "initial"
  17        '
  18test_expect_success 'commit change from svn side' '
  19        svn_cmd co "$svnrepo" t.svn &&
  20        (
  21                cd t.svn &&
  22                echo second line from svn >>file &&
  23                poke file &&
  24                svn_cmd commit -m "second line from svn"
  25        ) &&
  26        rm -rf t.svn
  27        '
  28
  29test_expect_success 'commit conflicting change from git' '
  30        echo second line from git >> file &&
  31        git commit -a -m "second line from git" &&
  32        test_must_fail git svn commit-diff -r1 HEAD~1 HEAD "$svnrepo"
  33'
  34
  35test_expect_success 'commit complementing change from git' '
  36        git reset --hard HEAD~1 &&
  37        echo second line from svn >> file &&
  38        git commit -a -m "second line from svn" &&
  39        echo third line from git >> file &&
  40        git commit -a -m "third line from git" &&
  41        git svn commit-diff -r2 HEAD~1 HEAD "$svnrepo"
  42        '
  43
  44test_expect_success 'dcommit fails to commit because of conflict' '
  45        git svn init "$svnrepo" &&
  46        git svn fetch &&
  47        git reset --hard refs/${remotes_git_svn} &&
  48        svn_cmd co "$svnrepo" t.svn &&
  49        (
  50                cd t.svn &&
  51                echo fourth line from svn >>file &&
  52                poke file &&
  53                svn_cmd commit -m "fourth line from svn"
  54        ) &&
  55        rm -rf t.svn &&
  56        echo "fourth line from git" >> file &&
  57        git commit -a -m "fourth line from git" &&
  58        test_must_fail git svn dcommit
  59        '
  60
  61test_expect_success 'dcommit does the svn equivalent of an index merge' "
  62        git reset --hard refs/${remotes_git_svn} &&
  63        echo 'index merge' > file2 &&
  64        git update-index --add file2 &&
  65        git commit -a -m 'index merge' &&
  66        echo 'more changes' >> file2 &&
  67        git update-index file2 &&
  68        git commit -a -m 'more changes' &&
  69        git svn dcommit
  70        "
  71
  72test_expect_success 'commit another change from svn side' '
  73        svn_cmd co "$svnrepo" t.svn &&
  74        (
  75                cd t.svn &&
  76                echo third line from svn >>file &&
  77                poke file &&
  78                svn_cmd commit -m "third line from svn"
  79        ) &&
  80        rm -rf t.svn
  81        '
  82
  83test_expect_success 'multiple dcommit from git svn will not clobber svn' "
  84        git reset --hard refs/${remotes_git_svn} &&
  85        echo new file >> new-file &&
  86        git update-index --add new-file &&
  87        git commit -a -m 'new file' &&
  88        echo clobber > file &&
  89        git commit -a -m 'clobber' &&
  90        test_must_fail git svn dcommit
  91        "
  92
  93
  94test_expect_success 'check that rebase really failed' '
  95        test -d .git/rebase-apply
  96'
  97
  98test_expect_success 'resolve, continue the rebase and dcommit' "
  99        echo clobber and I really mean it > file &&
 100        git update-index file &&
 101        git rebase --continue &&
 102        git svn dcommit
 103        "
 104
 105test_done