[ARVADOS] updated: bd5a371cc0f57aea20c0954f532db5890dae5c59
Git user
git at public.curoverse.com
Wed Sep 13 15:11:25 EDT 2017
Summary of changes:
services/api/app/models/commit.rb | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
via bd5a371cc0f57aea20c0954f532db5890dae5c59 (commit)
from 32341a4777692a28358f2af5afa0d9e975e2da73 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit bd5a371cc0f57aea20c0954f532db5890dae5c59
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Wed Sep 13 09:32:46 2017 -0400
12107: Fix unreliable use of git-fetch.
Git-fetch does not fetch by sha1. If we can't find and fetch a branch
containing the desired commit, we still need to fall back on
pack-objects|unpack-objects.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/services/api/app/models/commit.rb b/services/api/app/models/commit.rb
index 2baf1d6..aa38462 100644
--- a/services/api/app/models/commit.rb
+++ b/services/api/app/models/commit.rb
@@ -154,11 +154,31 @@ class Commit < ActiveRecord::Base
commit_in_dst = false
end
+ tag_cmd = "tag --force #{tag.shellescape} #{sha1.shellescape}^{commit}"
if commit_in_dst == sha1
- must_git(dst_gitdir, "tag --force #{tag.shellescape} #{sha1.shellescape}")
+ must_git(dst_gitdir, tag_cmd)
else
- refspec = "#{sha1}:refs/tags/#{tag}"
- must_git(dst_gitdir, "fetch --no-tags file://#{src_gitdir.shellescape} #{refspec.shellescape}")
+ # git-fetch is faster than pack-objects|unpack-objects, but
+ # git-fetch can't fetch by sha1. So we first try to fetch a
+ # branch that has the desired commit, and if that fails (there
+ # is no such branch, or the branch we choose changes under us in
+ # race), we fall back to pack|unpack.
+ begin
+ branches = must_git("branch --contains #{sha1.shellescape}^{commit}")
+ m = branches.match(/^. (\w+)\n/)
+ if !m
+ raise GitError.new "commit is not on any branch"
+ end
+ branch = m[1]
+ must_git(dst_gitdir,
+ "fetch file://#{src_gitdir.shellescape} #{branch.shellescape}")
+ must_git(dst_gitdir, tag_cmd)
+ rescue GitError
+ must_pipe("echo #{sha1.shellescape}",
+ "git --git-dir #{src_gitdir.shellescape} pack-objects -q --revs --stdout",
+ "git --git-dir #{dst_gitdir.shellescape} unpack-objects -q")
+ must_git(dst_gitdir, tag_cmd)
+ end
end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list