From: "Michal Gorny (mgorny)" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog git-r3.eclass
Date: Sun, 2 Mar 2014 11:46:16 +0000 (UTC) [thread overview]
Message-ID: <20140302114616.0F96B2004C@flycatcher.gentoo.org> (raw)
mgorny 14/03/02 11:46:15
Modified: ChangeLog git-r3.eclass
Log:
Fix support for non-master default branch.
Revision Changes Path
1.1154 eclass/ChangeLog
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1154&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1154&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.1153&r2=1.1154
Index: ChangeLog
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
retrieving revision 1.1153
retrieving revision 1.1154
diff -u -r1.1153 -r1.1154
--- ChangeLog 2 Mar 2014 11:45:41 -0000 1.1153
+++ ChangeLog 2 Mar 2014 11:46:15 -0000 1.1154
@@ -1,6 +1,9 @@
# ChangeLog for eclass directory
# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1153 2014/03/02 11:45:41 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1154 2014/03/02 11:46:15 mgorny Exp $
+
+ 02 Mar 2014; Michał Górny <mgorny@gentoo.org> git-r3.eclass:
+ Fix support for non-master default branch.
02 Mar 2014; Michał Górny <mgorny@gentoo.org> git-r3.eclass:
Replace "git fetch" checkout with more efficient and compatible pseudo-shared
1.29 eclass/git-r3.eclass
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?rev=1.29&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?rev=1.29&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?r1=1.28&r2=1.29
Index: git-r3.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- git-r3.eclass 2 Mar 2014 11:45:41 -0000 1.28
+++ git-r3.eclass 2 Mar 2014 11:46:15 -0000 1.29
@@ -1,6 +1,6 @@
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.28 2014/03/02 11:45:41 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.29 2014/03/02 11:46:15 mgorny Exp $
# @ECLASS: git-r3.eclass
# @MAINTAINER:
@@ -270,6 +270,42 @@
[[ ${uri} == file://* || ${uri} == /* ]]
}
+# @FUNCTION: _git-r3_update_head
+# @USAGE: <remote-head-ref>
+# @INTERNAL
+# @DESCRIPTION:
+# Given a ref to which remote HEAD was fetched, try to match
+# a local branch and update symbolic HEAD appropriately.
+_git-r3_update_head()
+{
+ debug-print-function ${FUNCNAME} "$@"
+
+ local head_ref=${1}
+ local head_hash=$(git rev-parse --verify "${1}" || die)
+ local matching_ref
+
+ # TODO: some transports support peeking at symbolic remote refs
+ # find a way to use that rather than guessing
+
+ # (based on guess_remote_head() in git-1.9.0/remote.c)
+ local h ref
+ while read h ref; do
+ # look for matching head
+ if [[ ${h} == ${head_hash} ]]; then
+ # either take the first matching ref, or master if it is there
+ if [[ ! ${matching_ref} || ${ref} == refs/heads/master ]]; then
+ matching_ref=${ref}
+ fi
+ fi
+ done < <(git show-ref --heads || die)
+
+ if [[ ! ${matching_ref} ]]; then
+ die "Unable to find a matching branch for remote HEAD (${head_hash})"
+ fi
+
+ git symbolic-ref HEAD "${matching_ref}" || die
+}
+
# @FUNCTION: git-r3_fetch
# @USAGE: [<repo-uri> [<remote-ref> [<local-id>]]]
# @DESCRIPTION:
@@ -335,11 +371,17 @@
"refs/tags/*:refs/tags/*"
# notes in case something needs them
"refs/notes/*:refs/notes/*"
+ # and HEAD in case we need the default branch
+ # (we keep it in refs/git-r3 since otherwise --prune interferes)
+ HEAD:refs/git-r3/HEAD
)
set -- "${fetch_command[@]}"
echo "${@}" >&2
if "${@}"; then
+ # find remote HEAD and update our HEAD properly
+ _git-r3_update_head refs/git-r3/HEAD
+
# now let's see what the user wants from us
local full_remote_ref=$(
git rev-parse --verify --symbolic-full-name "${remote_ref}"
next reply other threads:[~2014-03-02 11:46 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-02 11:46 Michal Gorny (mgorny) [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-08-08 9:32 [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog git-r3.eclass Michal Gorny (mgorny)
2015-07-09 20:21 Michal Gorny (mgorny)
2015-06-22 8:39 Manuel Rueger (mrueg)
2014-07-28 14:13 Michal Gorny (mgorny)
2014-07-28 14:12 Michal Gorny (mgorny)
2014-07-07 14:41 Michal Gorny (mgorny)
2014-06-20 11:40 Michal Gorny (mgorny)
2014-06-01 22:07 Michal Gorny (mgorny)
2014-05-23 7:09 Michal Gorny (mgorny)
2014-04-17 20:28 Michal Gorny (mgorny)
2014-03-24 21:32 Michal Gorny (mgorny)
2014-03-03 21:45 Michal Gorny (mgorny)
2014-03-02 11:50 Michal Gorny (mgorny)
2014-03-02 11:50 Michal Gorny (mgorny)
2014-03-02 11:49 Michal Gorny (mgorny)
2014-03-02 11:49 Michal Gorny (mgorny)
2014-03-02 11:48 Michal Gorny (mgorny)
2014-03-02 11:48 Michal Gorny (mgorny)
2014-03-02 11:47 Michal Gorny (mgorny)
2014-03-02 11:47 Michal Gorny (mgorny)
2014-03-02 11:46 Michal Gorny (mgorny)
2014-03-02 11:45 Michal Gorny (mgorny)
2014-03-02 11:44 Michal Gorny (mgorny)
2014-02-25 13:01 Michal Gorny (mgorny)
2014-02-24 8:43 Michal Gorny (mgorny)
2014-02-23 22:05 Michal Gorny (mgorny)
2013-11-15 23:03 Michal Gorny (mgorny)
2013-10-30 19:21 Michal Gorny (mgorny)
2013-10-27 13:44 Michal Gorny (mgorny)
2013-10-27 13:33 Michal Gorny (mgorny)
2013-10-26 6:19 Michal Gorny (mgorny)
2013-10-13 7:14 Michal Gorny (mgorny)
2013-10-09 17:14 Michal Gorny (mgorny)
2013-10-05 16:48 Michal Gorny (mgorny)
2013-09-27 16:22 Michal Gorny (mgorny)
2013-09-26 21:04 Michal Gorny (mgorny)
2013-09-26 12:38 Michal Gorny (mgorny)
2013-09-25 11:19 Michal Gorny (mgorny)
2013-09-25 10:49 Michal Gorny (mgorny)
2013-09-19 9:42 Michal Gorny (mgorny)
2013-09-19 9:37 Michal Gorny (mgorny)
2013-09-13 15:08 Michal Gorny (mgorny)
2013-09-13 15:04 Michal Gorny (mgorny)
2013-09-09 16:01 Michal Gorny (mgorny)
2013-09-05 22:40 Michal Gorny (mgorny)
2013-09-05 20:24 Michal Gorny (mgorny)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140302114616.0F96B2004C@flycatcher.gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox