/[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.19 Revision 1.20
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.19 2011/09/23 13:57:42 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.20 2011/09/23 13:57:55 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.
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 fi 456 fi
462 457
463 # 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
464 # to migrate the data 459 # to migrate the data
465 if [[ -d ${EGIT_DIR} ]]; then 460 if [[ -d ${EGIT_DIR} ]]; then
466 if [[ ${target} == bare && -d ${EGIT_DIR}/.git ]]; then 461 if [[ ${bare} && -d ${EGIT_DIR}/.git ]]; then
467 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy" 462 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy"
468 463
469 ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy" 464 ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy"
470 mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare" 465 mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare"
471 export GIT_DIR="${EGIT_DIR}.bare" 466 export GIT_DIR="${EGIT_DIR}.bare"
473 returnstate=$? 468 returnstate=$?
474 unset GIT_DIR 469 unset GIT_DIR
475 rm -rf "${EGIT_DIR}" 470 rm -rf "${EGIT_DIR}"
476 mv "${EGIT_DIR}.bare" "${EGIT_DIR}" 471 mv "${EGIT_DIR}.bare" "${EGIT_DIR}"
477 eend ${returnstate} 472 eend ${returnstate}
478 fi
479 if [[ ${target} == full && ! -d ${EGIT_DIR}/.git ]]; then 473 elif [[ ! ${bare} && ! -d ${EGIT_DIR}/.git ]]; then
480 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy" 474 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy"
481 475
482 ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy" 476 ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy"
483 git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null 477 git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null
484 returnstate=$? 478 returnstate=$?
494 einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch." 488 einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch."
495 rm -rf "${EGIT_DIR}" 489 rm -rf "${EGIT_DIR}"
496 fi 490 fi
497 491
498 # set various options to work with both targets 492 # set various options to work with both targets
499 if [[ ${target} == bare ]]; then 493 if [[ ${bare} ]]; then
500 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\"" 494 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
501 EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare" 495 EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
502 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }" 496 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
503 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}"
504 UPSTREAM_BRANCH="${EGIT_BRANCH}" 498 UPSTREAM_BRANCH="${EGIT_BRANCH}"

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20