blob: dd48e9cba832a06a34fd1e2c895bb1b19792168f [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 &&
9 cd import &&
10 echo hello > readme &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040011 svn_cmd import -m "initial" . "$svnrepo" &&
Eric Wong27e9fb82006-06-27 19:39:12 -070012 cd .. &&
13 echo hello > readme &&
14 git update-index --add readme &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040015 git commit -a -m "initial" &&
Eric Wong27e9fb82006-06-27 19:39:12 -070016 echo world >> readme &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040017 git commit -a -m "another"
18 '
Eric Wong27e9fb82006-06-27 19:39:12 -070019
20head=`git rev-parse --verify HEAD^0`
21prev=`git rev-parse --verify HEAD^1`
22
23# the internals of the commit-diff command are the same as the regular
24# commit, so only a basic test of functionality is needed since we've
25# already tested commit extensively elsewhere
26
Bryan Donlanf69e8362008-05-04 01:37:59 -040027test_expect_success 'test the commit-diff command' '
28 test -n "$prev" && test -n "$head" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090029 git svn commit-diff -r1 "$prev" "$head" "$svnrepo" &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040030 svn_cmd co "$svnrepo" wc &&
Eric Wong27e9fb82006-06-27 19:39:12 -070031 cmp readme wc/readme
Bryan Donlanf69e8362008-05-04 01:37:59 -040032 '
Eric Wong27e9fb82006-06-27 19:39:12 -070033
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090034test_expect_success 'commit-diff to a sub-directory (with git svn config)' '
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040035 svn_cmd import -m "sub-directory" import "$svnrepo"/subdir &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090036 git svn init --minimize-url "$svnrepo"/subdir &&
37 git svn fetch &&
38 git svn commit-diff -r3 "$prev" "$head" &&
Eygene Ryabinkinda083d62009-05-08 12:06:16 +040039 svn_cmd cat "$svnrepo"/subdir/readme > readme.2 &&
Eric Wongd3a840d2007-01-26 01:32:45 -080040 cmp readme readme.2
Bryan Donlanf69e8362008-05-04 01:37:59 -040041 '
Eric Wongd3a840d2007-01-26 01:32:45 -080042
Eric Wong27e9fb82006-06-27 19:39:12 -070043test_done