/[gentoo-x86]/eclass/git-r3.eclass
Gentoo

Diff of /eclass/git-r3.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.28 Revision 1.29
1# Copyright 1999-2014 Gentoo Foundation 1# Copyright 1999-2014 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.28 2014/03/02 11:45:41 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.29 2014/03/02 11:46:15 mgorny Exp $
4 4
5# @ECLASS: git-r3.eclass 5# @ECLASS: git-r3.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Michał Górny <mgorny@gentoo.org> 7# Michał Górny <mgorny@gentoo.org>
8# @BLURB: Eclass for fetching and unpacking git repositories. 8# @BLURB: Eclass for fetching and unpacking git repositories.
268 local uri=${1} 268 local uri=${1}
269 269
270 [[ ${uri} == file://* || ${uri} == /* ]] 270 [[ ${uri} == file://* || ${uri} == /* ]]
271} 271}
272 272
273# @FUNCTION: _git-r3_update_head
274# @USAGE: <remote-head-ref>
275# @INTERNAL
276# @DESCRIPTION:
277# Given a ref to which remote HEAD was fetched, try to match
278# a local branch and update symbolic HEAD appropriately.
279_git-r3_update_head()
280{
281 debug-print-function ${FUNCNAME} "$@"
282
283 local head_ref=${1}
284 local head_hash=$(git rev-parse --verify "${1}" || die)
285 local matching_ref
286
287 # TODO: some transports support peeking at symbolic remote refs
288 # find a way to use that rather than guessing
289
290 # (based on guess_remote_head() in git-1.9.0/remote.c)
291 local h ref
292 while read h ref; do
293 # look for matching head
294 if [[ ${h} == ${head_hash} ]]; then
295 # either take the first matching ref, or master if it is there
296 if [[ ! ${matching_ref} || ${ref} == refs/heads/master ]]; then
297 matching_ref=${ref}
298 fi
299 fi
300 done < <(git show-ref --heads || die)
301
302 if [[ ! ${matching_ref} ]]; then
303 die "Unable to find a matching branch for remote HEAD (${head_hash})"
304 fi
305
306 git symbolic-ref HEAD "${matching_ref}" || die
307}
308
273# @FUNCTION: git-r3_fetch 309# @FUNCTION: git-r3_fetch
274# @USAGE: [<repo-uri> [<remote-ref> [<local-id>]]] 310# @USAGE: [<repo-uri> [<remote-ref> [<local-id>]]]
275# @DESCRIPTION: 311# @DESCRIPTION:
276# Fetch new commits to the local clone of repository. 312# Fetch new commits to the local clone of repository.
277# 313#
333 "refs/heads/*:refs/heads/*" 369 "refs/heads/*:refs/heads/*"
334 # pull tags explicitly in order to prune them properly 370 # pull tags explicitly in order to prune them properly
335 "refs/tags/*:refs/tags/*" 371 "refs/tags/*:refs/tags/*"
336 # notes in case something needs them 372 # notes in case something needs them
337 "refs/notes/*:refs/notes/*" 373 "refs/notes/*:refs/notes/*"
374 # and HEAD in case we need the default branch
375 # (we keep it in refs/git-r3 since otherwise --prune interferes)
376 HEAD:refs/git-r3/HEAD
338 ) 377 )
339 378
340 set -- "${fetch_command[@]}" 379 set -- "${fetch_command[@]}"
341 echo "${@}" >&2 380 echo "${@}" >&2
342 if "${@}"; then 381 if "${@}"; then
382 # find remote HEAD and update our HEAD properly
383 _git-r3_update_head refs/git-r3/HEAD
384
343 # now let's see what the user wants from us 385 # now let's see what the user wants from us
344 local full_remote_ref=$( 386 local full_remote_ref=$(
345 git rev-parse --verify --symbolic-full-name "${remote_ref}" 387 git rev-parse --verify --symbolic-full-name "${remote_ref}"
346 ) 388 )
347 389

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

  ViewVC Help
Powered by ViewVC 1.1.20