Skip to content

Commit 7a1cb0c

Browse files
committed
merge-to-svn: use cherry-pick when commit is not a merge
1 parent 6549f6e commit 7a1cb0c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

git-merge-to-svn

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,23 @@ def rev_list ref
2424
%x(git rev-list --reverse --first-parent #{ref}).split(/\n/)
2525
end
2626

27+
def patch_id hash
28+
id = %x(git show #{hash} | git patch-id).sub(/\n$/,'')
29+
id.empty? ? nil : id
30+
end
31+
32+
def merge? hash
33+
patch_id.nil?
34+
end
35+
2736
def merge_to_svn ref, opts={}
2837
hashes = rev_list ref
2938
hashes.each do |hash|
30-
%x(git merge -q --squash #{hash} && git commit -C #{hash})
39+
if merge? hash
40+
%x(git merge -q --squash #{hash} && git commit -C #{hash})
41+
else
42+
%x(git cherry-pick #{hash})
43+
end
3144
end
3245
end
3346

0 commit comments

Comments
 (0)