X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=dgit;h=a18f45cad6cf2235c2d8e7befc8fc523d40bf400;hb=72b520b9648a0734800a8ca2dc40ddda1ef4bb66;hp=12f7510033cbede7ee554e3106553da7636e2967;hpb=a044d7cb75d12393b4bdc4d652c250e2e677fb15;p=dgit.git
diff --git a/dgit b/dgit
index 12f75100..a18f45ca 100755
--- a/dgit
+++ b/dgit
@@ -1,4 +1,22 @@
#!/usr/bin/perl -w
+# dgit
+# Integration between git and Debian-style archives
+#
+# Copyright (C)2013 Ian Jackson
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
use strict;
use IO::Handle;
@@ -216,6 +234,16 @@ END
my $lastupl_ref = "refs/remotes/$remotename/upload/$suite";
+sub rev_parse ($) {
+ return cmdoutput qw(git rev-parse --), "$_[0]~0";
+}
+
+sub is_fast_fwd ($$) {
+ my ($ancestor,$child) = @_;
+ my $mb = cmdoutput qw(git merge-base), $dsc_hash, $lastupl_hash;
+ return rev_parse($mb) eq rev_parse($ancestor);
+}
+
sub fetch_from_archive () {
# ensures that $lastupl_ref is what is actually in the archive,
# one way or another
@@ -230,10 +258,9 @@ sub fetch_from_archive () {
$hash = generate_commit_from_dsc();
}
if ($lastupl_hash) {
- my $mb = cmdoutput qw(git merge-base), $dsc_hash, $lastupl_hash;
die "not fast forward on last upload branch!".
" (archive's version left in DGIT_ARCHIVE)"
- unless $mb eq $lastupl_hash;
+ unless is_fast_fwd($lastupl_hash, $dsc_hash);
}
if ($lastupl_ref ne $hash) {
cmdoutput qw(git update-ref -m), 'dgit fetch', $lastupl_ref, $hash;
@@ -297,8 +324,11 @@ sub push () {
runcmd qw(git fetch), $alioth_git,
map { "$_:refs/remotes/$remotename/$_" }
(mainbranch(), uploadbranch());
-
die <