#!/bin/sh # # Copyright (c) 2006 Eric Wong global test_description := ''git svn commit-diff'' source ./lib-git-svn.sh test_expect_success 'initialize repo' ' mkdir import && ( cd import && echo hello >readme && svn_cmd import -m "initial" . "$svnrepo" ) && echo hello > readme && git update-index --add readme && git commit -a -m "initial" && echo world >> readme && git commit -a -m "another" ' global head := $[git rev-parse --verify HEAD^0] global prev := $[git rev-parse --verify HEAD^1] # the internals of the commit-diff command are the same as the regular # commit, so only a basic test of functionality is needed since we've # already tested commit extensively elsewhere test_expect_success 'test the commit-diff command' ' test -n "$prev" && test -n "$head" && git svn commit-diff -r1 "$prev" "$head" "$svnrepo" && svn_cmd co "$svnrepo" wc && cmp readme wc/readme ' test_expect_success 'commit-diff to a sub-directory (with git svn config)' ' svn_cmd import -m "sub-directory" import "$svnrepo"/subdir && git svn init --minimize-url "$svnrepo"/subdir && git svn fetch && git svn commit-diff -r3 "$prev" "$head" && svn_cmd cat "$svnrepo"/subdir/readme > readme.2 && cmp readme readme.2 ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git svn commit-diff">)} spids: [9] ) ] spids: [9] ) (C {(.)} {(./lib-git-svn.sh)}) (C {(test_expect_success)} {(SQ <"initialize repo">)} { (SQ <"\n"> <"\tmkdir import &&\n"> <"\t(\n"> <"\t\tcd import &&\n"> <"\t\techo hello >readme &&\n"> <"\t\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n"> <"\t) &&\n"> <"\techo hello > readme &&\n"> <"\tgit update-index --add readme &&\n"> <"\tgit commit -a -m \"initial\" &&\n"> <"\techo world >> readme &&\n"> <"\tgit commit -a -m \"another\"\n"> <"\t"> ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:head) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(rev-parse)} {(--verify)} {(HEAD) (Lit_Other "^") (0)})] ) left_token: spids: [43 53] ) } spids: [42] ) ] spids: [42] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:prev) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(rev-parse)} {(--verify)} {(HEAD) (Lit_Other "^") (1)})] ) left_token: spids: [56 66] ) } spids: [55] ) ] spids: [55] ) (C {(test_expect_success)} {(SQ <"test the commit-diff command">)} { (SQ <"\n"> <"\ttest -n \"$prev\" && test -n \"$head\" &&\n"> <"\tgit svn commit-diff -r1 \"$prev\" \"$head\" \"$svnrepo\" &&\n"> <"\tsvn_cmd co \"$svnrepo\" wc &&\n"> <"\tcmp readme wc/readme\n"> <"\t"> ) } ) (C {(test_expect_success)} {(SQ <"commit-diff to a sub-directory (with git svn config)">)} { (SQ <"\n"> <"\tsvn_cmd import -m \"sub-directory\" import \"$svnrepo\"/subdir &&\n"> <"\tgit svn init --minimize-url \"$svnrepo\"/subdir &&\n"> <"\tgit svn fetch &&\n"> <"\tgit svn commit-diff -r3 \"$prev\" \"$head\" &&\n"> <"\tsvn_cmd cat \"$svnrepo\"/subdir/readme > readme.2 &&\n"> <"\tcmp readme readme.2\n"> <"\t"> ) } ) (C {(test_done)}) ] )