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

Diff of /eclass/git-2.eclass

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

Revision 1.18 Revision 1.21
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 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-2.eclass,v 1.18 2011/09/23 13:57:28 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.21 2011/09/23 13:58:09 mgorny Exp $
4 4
5# @ECLASS: git-2.eclass 5# @ECLASS: git-2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Donnie Berkholz <dberkholz@gentoo.org> 7# Donnie Berkholz <dberkholz@gentoo.org>
8# @BLURB: Eclass for fetching and unpacking git repositories. 8# @BLURB: Eclass for fetching and unpacking git repositories.
215git-2_gc() { 215git-2_gc() {
216 debug-print-function ${FUNCNAME} "$@" 216 debug-print-function ${FUNCNAME} "$@"
217 217
218 local args 218 local args
219 219
220 pushd "${EGIT_DIR}" > /dev/null
221 if [[ ${EGIT_REPACK} || ${EGIT_PRUNE} ]]; then 220 if [[ ${EGIT_REPACK} || ${EGIT_PRUNE} ]]; then
221 pushd "${EGIT_DIR}" > /dev/null
222 ebegin "Garbage collecting the repository" 222 ebegin "Garbage collecting the repository"
223 [[ ${EGIT_PRUNE} ]] && args='--prune' 223 [[ ${EGIT_PRUNE} ]] && args='--prune'
224 debug-print "${FUNCNAME}: git gc ${args}" 224 debug-print "${FUNCNAME}: git gc ${args}"
225 git gc ${args} 225 git gc ${args}
226 eend $? 226 eend $?
227 fi
228 popd > /dev/null 227 popd > /dev/null
228 fi
229} 229}
230 230
231# @FUNCTION: git-2_prepare_storedir 231# @FUNCTION: git-2_prepare_storedir
232# @DESCRIPTION: 232# @DESCRIPTION:
233# Internal function preparing directory where we are going to store SCM 233# Internal function preparing directory where we are going to store SCM
445# This function also set some global variables that differ between 445# This function also set some global variables that differ between
446# bare and non-bare checkout. 446# bare and non-bare checkout.
447git-2_migrate_repository() { 447git-2_migrate_repository() {
448 debug-print-function ${FUNCNAME} "$@" 448 debug-print-function ${FUNCNAME} "$@"
449 449
450 local target returnstate 450 local bare returnstate
451 451
452 # first find out if we have submodules 452 # first find out if we have submodules
453 # or user explicitly wants us to use non-bare clones
453 if [[ ! ${EGIT_HAS_SUBMODULES} ]]; then 454 if ! [[ ${EGIT_HAS_SUBMODULES} || ${EGIT_NONBARE} ]]; then
454 target="bare" 455 bare=1
455 else
456 target="full"
457 fi
458 # check if user didn't specify that we want non-bare repo
459 if [[ ${EGIT_NONBARE} ]]; then
460 target="full"
461 EGIT_LOCAL_NONBARE="true"
462 fi 456 fi
463 457
464 # test if we already have some repo and if so find out if we have 458 # test if we already have some repo and if so find out if we have
465 # to migrate the data 459 # to migrate the data
466 if [[ -d ${EGIT_DIR} ]]; then 460 if [[ -d ${EGIT_DIR} ]]; then
467 if [[ ${target} == bare && -d ${EGIT_DIR}/.git ]]; then 461 if [[ ${bare} && -d ${EGIT_DIR}/.git ]]; then
468 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy" 462 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy"
469 463
470 ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy" 464 ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy"
471 mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare" 465 mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare"
472 export GIT_DIR="${EGIT_DIR}.bare" 466 export GIT_DIR="${EGIT_DIR}.bare"
474 returnstate=$? 468 returnstate=$?
475 unset GIT_DIR 469 unset GIT_DIR
476 rm -rf "${EGIT_DIR}" 470 rm -rf "${EGIT_DIR}"
477 mv "${EGIT_DIR}.bare" "${EGIT_DIR}" 471 mv "${EGIT_DIR}.bare" "${EGIT_DIR}"
478 eend ${returnstate} 472 eend ${returnstate}
479 fi
480 if [[ ${target} == full && ! -d ${EGIT_DIR}/.git ]]; then 473 elif [[ ! ${bare} && ! -d ${EGIT_DIR}/.git ]]; then
481 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy" 474 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy"
482 475
483 ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy" 476 ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy"
484 git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null 477 git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null
485 returnstate=$? 478 returnstate=$?
495 einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch." 488 einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch."
496 rm -rf "${EGIT_DIR}" 489 rm -rf "${EGIT_DIR}"
497 fi 490 fi
498 491
499 # set various options to work with both targets 492 # set various options to work with both targets
500 if [[ ${target} == bare ]]; then 493 if [[ ${bare} ]]; then
501 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\"" 494 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
502 EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare" 495 EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
503 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }" 496 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
504 EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}" 497 EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
505 UPSTREAM_BRANCH="${EGIT_BRANCH}" 498 UPSTREAM_BRANCH="${EGIT_BRANCH}"

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20