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

Diff of /eclass/git.eclass

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

Revision 1.44 Revision 1.45
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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/Attic/git.eclass,v 1.44 2010/03/17 15:17:10 sping Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/git.eclass,v 1.45 2010/07/26 02:22:18 reavertm Exp $
4 4
5# @ECLASS: git.eclass 5# @ECLASS: git.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Tomas Chvatal <scarabeus@gentoo.org> 7# Tomas Chvatal <scarabeus@gentoo.org>
8# Donnie Berkholz <dberkholz@gentoo.org> 8# Donnie Berkholz <dberkholz@gentoo.org>
32# define some nice defaults but only if nothing is set already 32# define some nice defaults but only if nothing is set already
33: ${HOMEPAGE:=http://git-scm.com/} 33: ${HOMEPAGE:=http://git-scm.com/}
34 34
35# @ECLASS-VARIABLE: EGIT_QUIET 35# @ECLASS-VARIABLE: EGIT_QUIET
36# @DESCRIPTION: 36# @DESCRIPTION:
37# Enables user specified verbosity for the eclass elog informations. 37# Set to nonempty value to supress some eclass messages.
38# The user just needs to add EGIT_QUIET="ON" to the /etc/make.conf. 38: ${EGIT_QUIET:=${ESCM_QUIET}}
39: ${EGIT_QUIET:="OFF"}
40 39
41# @ECLASS-VARIABLE: EGIT_STORE_DIR 40# @ECLASS-VARIABLE: EGIT_STORE_DIR
42# @DESCRIPTION: 41# @DESCRIPTION:
43# Storage directory for git sources. 42# Storage directory for git sources.
44# Can be redefined. 43# Can be redefined.
45[[ -z ${EGIT_STORE_DIR} ]] && EGIT_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/git-src" 44[[ -z ${EGIT_STORE_DIR} ]] && EGIT_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/git-src"
46 45
47# @ECLASS-VARIABLE: EGIT_HAS_SUBMODULES 46# @ECLASS-VARIABLE: EGIT_HAS_SUBMODULES
48# @DESCRIPTION: 47# @DESCRIPTION:
49# Set this to "true" to enable the (slower) submodule support. 48# Set this to nonzero value to enable submodule support (slower).
50# This variable should be set before inheriting git.eclass
51: ${EGIT_HAS_SUBMODULES:=false} 49: ${EGIT_HAS_SUBMODULES:=}
52 50
53# @ECLASS-VARIABLE: EGIT_FETCH_CMD 51# @ECLASS-VARIABLE: EGIT_FETCH_CMD
54# @DESCRIPTION: 52# @DESCRIPTION:
55# Command for cloning the repository. 53# Command for cloning the repository.
56: ${EGIT_FETCH_CMD:="git clone"} 54: ${EGIT_FETCH_CMD:="git clone"}
57 55
58# @ECLASS-VARIABLE: EGIT_UPDATE_CMD 56# @ECLASS-VARIABLE: EGIT_UPDATE_CMD
59# @DESCRIPTION: 57# @DESCRIPTION:
60# Git fetch command. 58# Git fetch command.
61if ${EGIT_HAS_SUBMODULES}; then 59if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
62 EGIT_UPDATE_CMD="git pull -f -u" 60 EGIT_UPDATE_CMD="git pull -f -u"
63else 61else
64 EGIT_UPDATE_CMD="git fetch -f -u" 62 EGIT_UPDATE_CMD="git fetch -f -u"
65fi 63fi
66 64
116# @ECLASS-VARIABLE: EGIT_OFFLINE 114# @ECLASS-VARIABLE: EGIT_OFFLINE
117# @DESCRIPTION: 115# @DESCRIPTION:
118# Set this variable to a non-empty value to disable the automatic updating of 116# Set this variable to a non-empty value to disable the automatic updating of
119# an GIT source tree. This is intended to be set outside the git source 117# an GIT source tree. This is intended to be set outside the git source
120# tree by users. 118# tree by users.
121EGIT_OFFLINE="${EGIT_OFFLINE:-${ESCM_OFFLINE}}" 119: ${EGIT_OFFLINE:=${ESCM_OFFLINE}}
122 120
123# @ECLASS-VARIABLE: EGIT_PATCHES 121# @ECLASS-VARIABLE: EGIT_PATCHES
124# @DESCRIPTION: 122# @DESCRIPTION:
125# Similar to PATCHES array from base.eclass 123# Similar to PATCHES array from base.eclass
126# Only difference is that this patches are applied before bootstrap. 124# Only difference is that this patches are applied before bootstrap.
148 146
149# @ECLASS-VARIABLE: EGIT_REPACK 147# @ECLASS-VARIABLE: EGIT_REPACK
150# @DESCRIPTION: 148# @DESCRIPTION:
151# git eclass will repack objects to save disk space. However this can take a 149# git eclass will repack objects to save disk space. However this can take a
152# long time with VERY big repositories. 150# long time with VERY big repositories.
153: ${EGIT_REPACK:=false} 151: ${EGIT_REPACK:=}
154 152
155# @ECLASS-VARIABLE: EGIT_PRUNE 153# @ECLASS-VARIABLE: EGIT_PRUNE
156# @DESCRIPTION: 154# @DESCRIPTION:
157# git eclass can prune the local clone. This is useful if upstream rewinds and 155# git eclass can prune the local clone. This is useful if upstream rewinds and
158# rebases branches too often. 156# rebases branches too often.
159: ${EGIT_PRUNE:=false} 157: ${EGIT_PRUNE:=}
160 158
161# @FUNCTION: git_submodules 159# @FUNCTION: git_submodules
162# @DESCRIPTION: 160# @DESCRIPTION:
163# Internal function wrapping the submodule initialisation and update 161# Internal function wrapping the submodule initialisation and update
164git_submodules() { 162git_submodules() {
165 if ${EGIT_HAS_SUBMODULES}; then 163 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
166 debug-print "git submodule init" 164 debug-print "git submodule init"
167 git submodule init 165 git submodule init
168 debug-print "git submodule update" 166 debug-print "git submodule update"
169 git submodule update 167 git submodule update
170 fi 168 fi
191# Gets repository from EGIT_REPO_URI and store it in specified EGIT_STORE_DIR 189# Gets repository from EGIT_REPO_URI and store it in specified EGIT_STORE_DIR
192git_fetch() { 190git_fetch() {
193 debug-print-function ${FUNCNAME} "$@" 191 debug-print-function ${FUNCNAME} "$@"
194 192
195 local GIT_DIR EGIT_CLONE_DIR oldsha1 cursha1 extra_clone_opts upstream_branch 193 local GIT_DIR EGIT_CLONE_DIR oldsha1 cursha1 extra_clone_opts upstream_branch
196 ${EGIT_HAS_SUBMODULES} || export GIT_DIR 194 [[ -z ${EGIT_HAS_SUBMODULES} ]] && export GIT_DIR
197 195
198 # choose if user wants elog or just einfo. 196 # choose if user wants elog or just einfo.
199 if [[ ${EGIT_QUIET} != OFF ]]; then 197 if [[ -n ${EGIT_QUIET} ]]; then
200 elogcmd="einfo" 198 elogcmd="einfo"
201 else 199 else
202 elogcmd="elog" 200 elogcmd="elog"
203 fi 201 fi
204 202
252 if [[ -e "${GIT_DIR}/shallow" ]]; then 250 if [[ -e "${GIT_DIR}/shallow" ]]; then
253 rm -rf "${GIT_DIR}" 251 rm -rf "${GIT_DIR}"
254 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching." 252 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching."
255 fi 253 fi
256 # repack from bare copy to normal one 254 # repack from bare copy to normal one
257 if ${EGIT_HAS_SUBMODULES} && [[ -d ${GIT_DIR} && ! -d "${GIT_DIR}/.git/" ]]; then 255 if [[ -n ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && ! -d "${GIT_DIR}/.git/" ]]; then
258 rm -rf "${GIT_DIR}" 256 rm -rf "${GIT_DIR}"
259 einfo "The ${EGIT_CLONE_DIR} was bare copy. Refetching." 257 einfo "The ${EGIT_CLONE_DIR} was bare copy. Refetching."
260 fi 258 fi
261 if ! ${EGIT_HAS_SUBMODULES} && [[ -d ${GIT_DIR} && -d ${GIT_DIR}/.git ]]; then 259 if [[ -z ${EGIT_HAS_SUBMODULES} ]] && [[ -d ${GIT_DIR} && -d ${GIT_DIR}/.git ]]; then
262 rm -rf "${GIT_DIR}" 260 rm -rf "${GIT_DIR}"
263 einfo "The ${EGIT_CLONE_DIR} was not a bare copy. Refetching." 261 einfo "The ${EGIT_CLONE_DIR} was not a bare copy. Refetching."
264 fi 262 fi
265 263
266 if ${EGIT_HAS_SUBMODULES}; then 264 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
267 upstream_branch=origin/${EGIT_BRANCH} 265 upstream_branch=origin/${EGIT_BRANCH}
268 else 266 else
269 upstream_branch=${EGIT_BRANCH} 267 upstream_branch=${EGIT_BRANCH}
270 extra_clone_opts=--bare 268 extra_clone_opts=--bare
271 fi 269 fi
301 ${elogcmd} "GIT update -->" 299 ${elogcmd} "GIT update -->"
302 ${elogcmd} " repository: ${EGIT_REPO_URI}" 300 ${elogcmd} " repository: ${EGIT_REPO_URI}"
303 301
304 oldsha1=$(git rev-parse ${upstream_branch}) 302 oldsha1=$(git rev-parse ${upstream_branch})
305 303
306 if ${EGIT_HAS_SUBMODULES}; then 304 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
307 debug-print "${EGIT_UPDATE_CMD} ${EGIT_OPTIONS}" 305 debug-print "${EGIT_UPDATE_CMD} ${EGIT_OPTIONS}"
308 # fix branching 306 # fix branching
309 git checkout ${EGIT_MASTER} 307 git checkout ${EGIT_MASTER}
310 for x in $(git branch |grep -v "* ${EGIT_MASTER}" |tr '\n' ' '); do 308 for x in $(git branch |grep -v "* ${EGIT_MASTER}" |tr '\n' ' '); do
311 git branch -D ${x} 309 git branch -D ${x}
341 ${EGIT_DIFFSTAT_CMD} ${oldsha1}..${upstream_branch} 339 ${EGIT_DIFFSTAT_CMD} ${oldsha1}..${upstream_branch}
342 popd &> /dev/null 340 popd &> /dev/null
343 fi 341 fi
344 342
345 pushd "${GIT_DIR}" &> /dev/null 343 pushd "${GIT_DIR}" &> /dev/null
346 if ${EGIT_REPACK} || ${EGIT_PRUNE} ; then 344 if [[ -n ${EGIT_REPACK} ]] || [[ -n ${EGIT_PRUNE} ]]; then
347 ebegin "Garbage collecting the repository" 345 ebegin "Garbage collecting the repository"
348 git gc $(${EGIT_PRUNE} && echo '--prune') 346 git gc $(${EGIT_PRUNE} && echo '--prune')
349 eend $? 347 eend $?
350 fi 348 fi
351 popd &> /dev/null 349 popd &> /dev/null
356 # log the repo state 354 # log the repo state
357 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] && elog " commit: ${EGIT_COMMIT}" 355 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] && elog " commit: ${EGIT_COMMIT}"
358 ${elogcmd} " branch: ${EGIT_BRANCH}" 356 ${elogcmd} " branch: ${EGIT_BRANCH}"
359 ${elogcmd} " storage directory: \"${GIT_DIR}\"" 357 ${elogcmd} " storage directory: \"${GIT_DIR}\""
360 358
361 if ${EGIT_HAS_SUBMODULES}; then 359 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
362 pushd "${GIT_DIR}" &> /dev/null 360 pushd "${GIT_DIR}" &> /dev/null
363 debug-print "rsync -rlpgo . \"${S}\"" 361 debug-print "rsync -rlpgo . \"${S}\""
364 time rsync -rlpgo . "${S}" 362 time rsync -rlpgo . "${S}"
365 popd &> /dev/null 363 popd &> /dev/null
366 else 364 else

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

  ViewVC Help
Powered by ViewVC 1.1.20