blob: 5d0afeae6caf03ca34d7ef883baed512bcbcec51 [file] [log] [blame]
Eric Wong27e9fb82006-06-27 19:39:12 -07001#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
Nanako Shiraishi1364ff22008-09-08 19:02:08 +09004test_description='git svn commit-diff'
Eric Wong27e9fb82006-06-27 19:39:12 -07005. ./lib-git-svn.sh
6
Bryan Donlanf69e8362008-05-04 01:37:59 -04007test_expect_success 'initialize repo' '
Eric Wong27e9fb82006-06-27 19:39:12 -07008 mkdir import &&
Jonathan Nieder18a82692010-09-06 20:42:54 -05009 (
10 cd import &&
11 echo hello >readme &&
12 svn_cmd import -m "initial" . "$svnrepo"
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020013 ) &&
Eric Wong27e9fb82006-06-27 19:39:12 -070014 echo hello > readme &&
15 git update-index --add readme &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040016 git commit -a -m "initial" &&
Eric Wong27e9fb82006-06-27 19:39:12 -070017 echo world >> readme &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040018 git commit -a -m "another"
19 '
Eric Wong27e9fb82006-06-27 19:39:12 -070020
21head=`git rev-parse --verify HEAD^0`
22prev=`git rev-parse --verify HEAD^1`
23
24# the internals of the commit-diff command are the same as the regular
25# commit, so only a basic test of functionality is needed since we've
26# already tested commit extensively elsewhere
27
Bryan Donlanf69e8362008-05-04 01:37:59 -040028test_expect_success 'test the commit-diff command' '
29 test -n "$prev" && test -n "$head" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090030 git svn commit-diff -r1 "$prev" "$head" "$svnrepo" &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040031 svn_cmd co "$svnrepo" wc &&
Eric Wong27e9fb82006-06-27 19:39:12 -070032 cmp readme wc/readme
Bryan Donlanf69e8362008-05-04 01:37:59 -040033 '
Eric Wong27e9fb82006-06-27 19:39:12 -070034
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090035test_expect_success 'commit-diff to a sub-directory (with git svn config)' '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040036 svn_cmd import -m "sub-directory" import "$svnrepo"/subdir &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090037 git svn init --minimize-url "$svnrepo"/subdir &&
38 git svn fetch &&
39 git svn commit-diff -r3 "$prev" "$head" &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040040 svn_cmd cat "$svnrepo"/subdir/readme > readme.2 &&
Eric Wongd3a840d2007-01-26 01:32:45 -080041 cmp readme readme.2
Bryan Donlanf69e8362008-05-04 01:37:59 -040042 '
Eric Wongd3a840d2007-01-26 01:32:45 -080043
Eric Wong27e9fb82006-06-27 19:39:12 -070044test_done