chiark / gitweb /
In push, do git fetch as well as archive fetch, or archive fetch can fail.
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 41375195d6cdd997ff79ff8aff572930647af1bf..f9c46c036cb00c037a6457e87546eac5f6a35c30 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -456,9 +456,7 @@ sub create_remote_git_repo () {
        runcmd_ordryrun
            (access_cfg('ssh'),access_gituserhost(),
             "set -e; cd ".access_cfg('git-path').";".
-            " mkdir -p $package.git;".
-            " cd $package.git;".
-            " if ! test -d objects; then git init --bare; fi");
+            " cp -a _template $package.git");
     } else {
        badcfg "unknown git-create \`$how'";
     }
@@ -661,11 +659,12 @@ sub fetch_from_archive () {
     if (defined $dsc_hash) {
        fail "missing git history even though dsc has hash -".
            " could not find commit $dsc_hash".
-           " (should be in ".access_giturl()."#".rref().")"
+           " (should be in ".access_giturl()."#".rrref().")"
            unless $upload_hash;
        $hash = $dsc_hash;
        ensure_we_have_orig();
-       if (is_fast_fwd($dsc_hash,$upload_hash)) {
+       if ($dsc_hash eq $upload_hash) {
+       } elsif (is_fast_fwd($dsc_hash,$upload_hash)) {
            print STDERR <<END or die $!;
 
 Git commit in archive is behind the last version allegedly pushed/uploaded.
@@ -674,6 +673,9 @@ Last allegedly pushed/uploaded: $upload_hash
 $later_warning_msg
 END
            $hash = $upload_hash;
+       } else {
+           fail "archive's .dsc refers to ".$dsc_hash.
+               " but this is an ancestor of ".$upload_hash;
        }
     } else {
        $hash = generate_commit_from_dsc();
@@ -936,6 +938,9 @@ sub cmd_push {
     } else {
        badusage "incorrect arguments to dgit push";
     }
+    if (check_for_git()) {
+       git_fetch_us();
+    }
     if (fetch_from_archive()) {
        is_fast_fwd(lrref(), 'HEAD') or die;
     } else {