Hello all,

I've prepared a bunch of patches to git-2.eclass.

1-2 -- replacing scary unreadable parts of code with nicer ones.
3-4 -- basically just coding style changes.
5-7 -- little logic simplification.
  8 -- eclassdoc fixes.
  9 -- prevents environment injection of internal var.
 10 -- tries to migrate git.eclass clones to git-2.eclass (#383761).
 11 -- removes old git.eclass clones to not waste diskspace.

In the future, I will probably attempt to remove most of directory
changes in favor of GIT_DIR setting as well.

-- 
Best regards,
Michał Górny
From fca7c940dea8d30648e33c007a2795ea43109fdf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 19:43:36 +0200
Subject: [PATCH 01/11] Replace variable 'eval's with ${!foo}.

---
 eclass/git-2.eclass |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index 0caa3d4..d3abd4c 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -127,8 +127,6 @@ DEPEND="dev-vcs/git"
 git-2_init_variables() {
 	debug-print-function ${FUNCNAME} "$@"
 
-	local x
-
 	: ${EGIT_SOURCEDIR="${S}"}
 
 	: ${EGIT_STORE_DIR:="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/egit-src"}
@@ -139,19 +137,20 @@ git-2_init_variables() {
 
 	: ${EGIT_MASTER:=master}
 
-	eval x="\$${PN//[-+]/_}_LIVE_REPO"
-	EGIT_REPO_URI=${x:-${EGIT_REPO_URI}}
+	local esc_pn=${PN//[-+]/_}
+	local liverepo=${esc_pn}_LIVE_REPO
+	EGIT_REPO_URI=${!liverepo:-${EGIT_REPO_URI}}
 	[[ -z ${EGIT_REPO_URI} ]] && die "EGIT_REPO_URI must have some value"
 
 	: ${EVCS_OFFLINE:=}
 
-	eval x="\$${PN//[-+]/_}_LIVE_BRANCH"
-	[[ -n ${x} ]] && ewarn "QA: using \"${PN//[-+]/_}_LIVE_BRANCH\" variable, you won't get any support"
-	EGIT_BRANCH=${x:-${EGIT_BRANCH:-${EGIT_MASTER}}}
+	local livebranch=${esc_pn}_LIVE_BRANCH
+	[[ -n ${!livebranch} ]] && ewarn "QA: using \"${esc_pn}_LIVE_BRANCH\" variable, you won't get any support"
+	EGIT_BRANCH=${!livebranch:-${EGIT_BRANCH:-${EGIT_MASTER}}}
 
-	eval x="\$${PN//[-+]/_}_LIVE_COMMIT"
-	[[ -n ${x} ]] && ewarn "QA: using \"${PN//[-+]/_}_LIVE_COMMIT\" variable, you won't get any support"
-	EGIT_COMMIT=${x:-${EGIT_COMMIT:-${EGIT_BRANCH}}}
+	local livecommit=${esc_pn}_LIVE_COMMIT
+	[[ -n ${!livecommit} ]] && ewarn "QA: using \"${esc_pn}_LIVE_COMMIT\" variable, you won't get any support"
+	EGIT_COMMIT=${!livecommit:-${EGIT_COMMIT:-${EGIT_BRANCH}}}
 
 	: ${EGIT_REPACK:=}
 
-- 
1.7.6.1

From ec3155c319f19f4eac3ef2ebecfdeeaaafc64b74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 20:03:53 +0200
Subject: [PATCH 02/11] Remove unnecessary scary trailing-slash check for
 EGIT_REPO_URI.

If the slash is not there, ${EGIT_REPO_URI%/} will simply do nothing.
---
 eclass/git-2.eclass |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index d3abd4c..980129c 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -249,7 +249,7 @@ git-2_prepare_storedir() {
 	# calculate the proper store dir for data
 	# If user didn't specify the EGIT_DIR, we check if he did specify
 	# the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
-	[[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}"
+	EGIT_REPO_URI=${EGIT_REPO_URI%/}
 	if [[ -z ${EGIT_DIR} ]]; then
 		if [[ -n ${EGIT_PROJECT} ]]; then
 			clone_dir=${EGIT_PROJECT}
-- 
1.7.6.1

From 7d3cf70813b3772eb7ee7308192a717f33ff77b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 20:12:02 +0200
Subject: [PATCH 03/11] Drop -n & -z test operators -- they're redundant in [[
 ]].

---
 eclass/git-2.eclass |   44 +++++++++++++++++++++-----------------------
 1 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index 980129c..f262a05 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -140,16 +140,16 @@ git-2_init_variables() {
 	local esc_pn=${PN//[-+]/_}
 	local liverepo=${esc_pn}_LIVE_REPO
 	EGIT_REPO_URI=${!liverepo:-${EGIT_REPO_URI}}
-	[[ -z ${EGIT_REPO_URI} ]] && die "EGIT_REPO_URI must have some value"
+	[[ ${EGIT_REPO_URI} ]] || die "EGIT_REPO_URI must have some value"
 
 	: ${EVCS_OFFLINE:=}
 
 	local livebranch=${esc_pn}_LIVE_BRANCH
-	[[ -n ${!livebranch} ]] && ewarn "QA: using \"${esc_pn}_LIVE_BRANCH\" variable, you won't get any support"
+	[[ ${!livebranch} ]] && ewarn "QA: using \"${esc_pn}_LIVE_BRANCH\" variable, you won't get any support"
 	EGIT_BRANCH=${!livebranch:-${EGIT_BRANCH:-${EGIT_MASTER}}}
 
 	local livecommit=${esc_pn}_LIVE_COMMIT
-	[[ -n ${!livecommit} ]] && ewarn "QA: using \"${esc_pn}_LIVE_COMMIT\" variable, you won't get any support"
+	[[ ${!livecommit} ]] && ewarn "QA: using \"${esc_pn}_LIVE_COMMIT\" variable, you won't get any support"
 	EGIT_COMMIT=${!livecommit:-${EGIT_COMMIT:-${EGIT_BRANCH}}}
 
 	: ${EGIT_REPACK:=}
@@ -162,8 +162,8 @@ git-2_init_variables() {
 # Internal function wrapping the submodule initialisation and update.
 git-2_submodules() {
 	debug-print-function ${FUNCNAME} "$@"
-	if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then
-		if [[ -n ${EVCS_OFFLINE} ]]; then
+	if [[ ${EGIT_HAS_SUBMODULES} ]]; then
+		if [[ ${EVCS_OFFLINE} ]]; then
 			# for submodules operations we need to be online
 			debug-print "${FUNCNAME}: not updating submodules in offline mode"
 			return 1
@@ -216,9 +216,9 @@ git-2_gc() {
 	local args
 
 	pushd "${EGIT_DIR}" > /dev/null
-	if [[ -n ${EGIT_REPACK} || -n ${EGIT_PRUNE} ]]; then
+	if [[ ${EGIT_REPACK} || ${EGIT_PRUNE} ]]; then
 		ebegin "Garbage collecting the repository"
-		[[ -n ${EGIT_PRUNE} ]] && args='--prune'
+		[[ ${EGIT_PRUNE} ]] && args='--prune'
 		debug-print "${FUNCNAME}: git gc ${args}"
 		git gc ${args}
 		eend $?
@@ -250,8 +250,8 @@ git-2_prepare_storedir() {
 	# If user didn't specify the EGIT_DIR, we check if he did specify
 	# the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
 	EGIT_REPO_URI=${EGIT_REPO_URI%/}
-	if [[ -z ${EGIT_DIR} ]]; then
-		if [[ -n ${EGIT_PROJECT} ]]; then
+	if [[ ! ${EGIT_DIR} ]]; then
+		if [[ ${EGIT_PROJECT} ]]; then
 			clone_dir=${EGIT_PROJECT}
 		else
 			clone_dir=${EGIT_REPO_URI##*/}
@@ -297,9 +297,8 @@ git-2_initial_clone() {
 		fi
 	done
 
-	if [[ -z ${EGIT_REPO_URI_SELECTED} ]]; then
-		die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}"
-	fi
+	[[ ${EGIT_REPO_URI_SELECTED} ]] \
+		|| die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}"
 }
 
 # @FUNCTION: git-2_update_repo
@@ -310,7 +309,7 @@ git-2_update_repo() {
 
 	local repo_uri
 
-	if [[ -n ${EGIT_LOCAL_NONBARE} ]]; then
+	if [[ ${EGIT_LOCAL_NONBARE} ]]; then
 		# checkout master branch and drop all other local branches
 		git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}"
 		for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do
@@ -334,9 +333,8 @@ git-2_update_repo() {
 		fi
 	done
 
-	if [[ -z ${EGIT_REPO_URI_SELECTED} ]]; then
-		die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}"
-	fi
+	[[ ${EGIT_REPO_URI_SELECTED} ]] \
+		|| die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}"
 }
 
 # @FUNCTION: git-2_fetch
@@ -348,7 +346,7 @@ git-2_fetch() {
 
 	local oldsha cursha repo_type
 
-	[[ -n ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
+	[[ ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
 
 	if [[ ! -d ${EGIT_DIR} ]]; then
 		git-2_initial_clone
@@ -359,7 +357,7 @@ git-2_fetch() {
 		echo "   at the commit:            ${cursha}"
 
 		popd > /dev/null
-	elif [[ -n ${EVCS_OFFLINE} ]]; then
+	elif [[ ${EVCS_OFFLINE} ]]; then
 		pushd "${EGIT_DIR}" > /dev/null
 		cursha=$(git rev-parse ${UPSTREAM_BRANCH})
 		echo "GIT offline update -->"
@@ -410,7 +408,7 @@ git-2_bootstrap() {
 	# enviroment the package will fail if there is no update, thus in
 	# combination with --keep-going it would lead in not-updating
 	# pakcages that are up-to-date.
-	if [[ -n ${EGIT_BOOTSTRAP} ]]; then
+	if [[ ${EGIT_BOOTSTRAP} ]]; then
 		pushd "${EGIT_SOURCEDIR}" > /dev/null
 		einfo "Starting bootstrap"
 
@@ -452,13 +450,13 @@ git-2_migrate_repository() {
 	local target returnstate
 
 	# first find out if we have submodules
-	if [[ -z ${EGIT_HAS_SUBMODULES} ]]; then
+	if [[ ! ${EGIT_HAS_SUBMODULES} ]]; then
 		target="bare"
 	else
 		target="full"
 	fi
 	# check if user didn't specify that we want non-bare repo
-	if [[ -n ${EGIT_NONBARE} ]]; then
+	if [[ ${EGIT_NONBARE} ]]; then
 		target="full"
 		EGIT_LOCAL_NONBARE="true"
 	fi
@@ -555,9 +553,9 @@ git-2_src_unpack() {
 
 	# Users can specify some SRC_URI and we should
 	# unpack the files too.
-	if [[ -z ${EGIT_NOUNPACK} ]]; then
+	if [[ ! ${EGIT_NOUNPACK} ]]; then
 		if has ${EAPI:-0} 0 1; then
-			[[ -n ${A} ]] && unpack ${A}
+			[[ ${A} ]] && unpack ${A}
 		else
 			default_src_unpack
 		fi
-- 
1.7.6.1

From d55b610a317b0543b0c6172354bf50bc4102a2e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 21:38:53 +0200
Subject: [PATCH 04/11] Replace redundant $? checks with explicit if..fi.

---
 eclass/git-2.eclass |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index f262a05..eaff789 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -288,8 +288,7 @@ git-2_initial_clone() {
 	EGIT_REPO_URI_SELECTED=""
 	for repo_uri in ${EGIT_REPO_URI}; do
 		debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\""
-		git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}"
-		if [[ $? -eq 0 ]]; then
+		if git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}"; then
 			# global variable containing the repo_name we will be using
 			debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
 			EGIT_REPO_URI_SELECTED="${repo_uri}"
@@ -324,8 +323,7 @@ git-2_update_repo() {
 		git config remote.origin.url "${repo_uri}"
 
 		debug-print "${EGIT_UPDATE_CMD}"
-		${EGIT_UPDATE_CMD} > /dev/null
-		if [[ $? -eq 0 ]]; then
+		if ${EGIT_UPDATE_CMD} > /dev/null; then
 			# global variable containing the repo_name we will be using
 			debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
 			EGIT_REPO_URI_SELECTED="${repo_uri}"
-- 
1.7.6.1

From 4809f2f3ac7b4803b2a45b62b4268796b7723b47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 20:28:29 +0200
Subject: [PATCH 05/11] Drop redundant EGIT_LOCAL_NONBARE setting.

It is set later in the function anyway.
---
 eclass/git-2.eclass |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index eaff789..73aeb75 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -456,7 +456,6 @@ git-2_migrate_repository() {
 	# check if user didn't specify that we want non-bare repo
 	if [[ ${EGIT_NONBARE} ]]; then
 		target="full"
-		EGIT_LOCAL_NONBARE="true"
 	fi
 
 	# test if we already have some repo and if so find out if we have
-- 
1.7.6.1

From 862292ea161aa1d4c32828001520b2919617aa1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 20:38:20 +0200
Subject: [PATCH 06/11] Simplify bare/non-bare logic.

---
 eclass/git-2.eclass |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index 73aeb75..1c6f4d1 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -445,23 +445,18 @@ git-2_bootstrap() {
 git-2_migrate_repository() {
 	debug-print-function ${FUNCNAME} "$@"
 
-	local target returnstate
+	local bare returnstate
 
 	# first find out if we have submodules
-	if [[ ! ${EGIT_HAS_SUBMODULES} ]]; then
-		target="bare"
-	else
-		target="full"
-	fi
-	# check if user didn't specify that we want non-bare repo
-	if [[ ${EGIT_NONBARE} ]]; then
-		target="full"
+	# or user explicitly wants us to use non-bare clones
+	if ! [[ ${EGIT_HAS_SUBMODULES} || ${EGIT_NONBARE} ]]; then
+		bare=1
 	fi
 
 	# test if we already have some repo and if so find out if we have
 	# to migrate the data
 	if [[ -d ${EGIT_DIR} ]]; then
-		if [[ ${target} == bare && -d ${EGIT_DIR}/.git ]]; then
+		if [[ ${bare} && -d ${EGIT_DIR}/.git ]]; then
 			debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy"
 
 			ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy"
@@ -473,8 +468,7 @@ git-2_migrate_repository() {
 			rm -rf "${EGIT_DIR}"
 			mv "${EGIT_DIR}.bare" "${EGIT_DIR}"
 			eend ${returnstate}
-		fi
-		if [[ ${target} == full && ! -d ${EGIT_DIR}/.git ]]; then
+		elif [[ ! ${bare} && ! -d ${EGIT_DIR}/.git ]]; then
 			debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy"
 
 			ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy"
@@ -494,7 +488,7 @@ git-2_migrate_repository() {
 	fi
 
 	# set various options to work with both targets
-	if [[ ${target} == bare ]]; then
+	if [[ ${bare} ]]; then
 		debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
 		EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
 		MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
-- 
1.7.6.1

From fe08fdc1610007aae4e4c448299ccfd63620b04a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 20:53:26 +0200
Subject: [PATCH 07/11] Move pushd/popds around to make code simpler.

---
 eclass/git-2.eclass |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index 1c6f4d1..b4b03ae 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -215,15 +215,15 @@ git-2_gc() {
 
 	local args
 
-	pushd "${EGIT_DIR}" > /dev/null
 	if [[ ${EGIT_REPACK} || ${EGIT_PRUNE} ]]; then
+		pushd "${EGIT_DIR}" > /dev/null
 		ebegin "Garbage collecting the repository"
 		[[ ${EGIT_PRUNE} ]] && args='--prune'
 		debug-print "${FUNCNAME}: git gc ${args}"
 		git gc ${args}
 		eend $?
+		popd > /dev/null
 	fi
-	popd > /dev/null
 }
 
 # @FUNCTION: git-2_prepare_storedir
@@ -353,15 +353,12 @@ git-2_fetch() {
 		echo "GIT NEW clone -->"
 		echo "   repository:               ${EGIT_REPO_URI_SELECTED}"
 		echo "   at the commit:            ${cursha}"
-
-		popd > /dev/null
 	elif [[ ${EVCS_OFFLINE} ]]; then
 		pushd "${EGIT_DIR}" > /dev/null
 		cursha=$(git rev-parse ${UPSTREAM_BRANCH})
 		echo "GIT offline update -->"
 		echo "   repository:               $(git config remote.origin.url)"
 		echo "   at the commit:            ${cursha}"
-		popd > /dev/null
 	else
 		pushd "${EGIT_DIR}" > /dev/null
 		oldsha=$(git rev-parse ${UPSTREAM_BRANCH})
@@ -381,8 +378,8 @@ git-2_fetch() {
 
 		# print nice statistic of what was changed
 		git --no-pager diff --stat ${oldsha}..${UPSTREAM_BRANCH}
-		popd > /dev/null
 	fi
+	popd > /dev/null
 	# export the version the repository is at
 	export EGIT_VERSION="${cursha}"
 	# log the repo state
-- 
1.7.6.1

From de5d01b4dd19f5388a293a9179f3a16c17435ff1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 21:05:30 +0200
Subject: [PATCH 08/11] Mark internal functions @INTERNAL.

---
 eclass/git-2.eclass |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index b4b03ae..8bdf108 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -120,6 +120,7 @@ DEPEND="dev-vcs/git"
 # Default behaviour is to unpack ${A} content.
 
 # @FUNCTION: git-2_init_variables
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function initializing all git variables.
 # We define it in function scope so user can define
@@ -158,6 +159,7 @@ git-2_init_variables() {
 }
 
 # @FUNCTION: git-2_submodules
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function wrapping the submodule initialisation and update.
 git-2_submodules() {
@@ -184,6 +186,7 @@ git-2_submodules() {
 }
 
 # @FUNCTION: git-2_branch
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function that changes branch for the repo based on EGIT_COMMIT and
 # EGIT_BRANCH variables.
@@ -208,6 +211,7 @@ git-2_branch() {
 }
 
 # @FUNCTION: git-2_gc
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function running garbage collector on checked out tree.
 git-2_gc() {
@@ -227,6 +231,7 @@ git-2_gc() {
 }
 
 # @FUNCTION: git-2_prepare_storedir
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function preparing directory where we are going to store SCM
 # repository.
@@ -263,6 +268,7 @@ git-2_prepare_storedir() {
 }
 
 # @FUNCTION: git-2_move_source
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function moving sources from the EGIT_DIR to EGIT_SOURCEDIR dir.
 git-2_move_source() {
@@ -278,6 +284,7 @@ git-2_move_source() {
 }
 
 # @FUNCTION: git-2_initial_clone
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function running initial clone on specified repo_uri.
 git-2_initial_clone() {
@@ -301,6 +308,7 @@ git-2_initial_clone() {
 }
 
 # @FUNCTION: git-2_update_repo
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function running update command on specified repo_uri.
 git-2_update_repo() {
@@ -336,6 +344,7 @@ git-2_update_repo() {
 }
 
 # @FUNCTION: git-2_fetch
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function fetching repository from EGIT_REPO_URI and storing it in
 # specified EGIT_STORE_DIR.
@@ -391,6 +400,7 @@ git-2_fetch() {
 }
 
 # @FUNCTION: git_bootstrap
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function that runs bootstrap command on unpacked source.
 git-2_bootstrap() {
@@ -433,6 +443,7 @@ git-2_bootstrap() {
 }
 
 # @FUNCTION: git-2_migrate_repository
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function migrating between bare and normal checkout repository.
 # This is based on usage of EGIT_SUBMODULES, at least until they
@@ -502,6 +513,7 @@ git-2_migrate_repository() {
 }
 
 # @FUNCTION: git-2_cleanup
+# @INTERNAL
 # @DESCRIPTION:
 # Internal function cleaning up all the global variables
 # that are not required after the unpack has been done.
-- 
1.7.6.1

From daf51437b8f379e8f870753a5f64482767f00d42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 21:28:55 +0200
Subject: [PATCH 09/11] Ensure EGIT_LOCAL_NONBARE doesn't leak in from env.

---
 eclass/git-2.eclass |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index 8bdf108..3db0d15 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -502,6 +502,7 @@ git-2_migrate_repository() {
 		MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
 		EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
 		UPSTREAM_BRANCH="${EGIT_BRANCH}"
+		EGIT_LOCAL_NONBARE=
 	else
 		debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\""
 		MOVE_COMMAND="cp -pPR ."
-- 
1.7.6.1

From 3c2983c653ee583cba1898bdaa8dff7b65aa49ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 16:37:55 +0200
Subject: [PATCH 10/11] Try to migrate git.eclass checkouts to the new eclass.

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=383761
---
 eclass/git-2.eclass |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index 3db0d15..3c8e0c5 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -262,6 +262,18 @@ git-2_prepare_storedir() {
 			clone_dir=${EGIT_REPO_URI##*/}
 		fi
 		EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
+
+		# Try to migrate from git.eclass git-src/
+		if [[ ! -d ${EGIT_DIR} && ${EGIT_STORE_DIR} == */egit-src ]]; then
+			local old_store_dir=${EGIT_STORE_DIR/%egit-src/git-src}
+			local old_location=${old_store_dir}/${EGIT_PROJECT:-${PN}}
+
+			if [[ -d ${old_location} ]]; then
+				elog "${FUNCNAME}: ${CATEGORY}/${PVR} will be cloned from old location."
+				elog "It will be necessary to rebuild the package to fetch updates."
+				EGIT_REPO_URI="${old_location} ${EGIT_REPO_URI}"
+			fi
+		fi
 	fi
 	export EGIT_DIR=${EGIT_DIR}
 	debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
-- 
1.7.6.1

From 821d3a8d1b3173819fc5d7061a47e7e713a9434c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
Date: Tue, 20 Sep 2011 21:36:06 +0200
Subject: [PATCH 11/11] Remove git.eclass old clones if git-2 clone succeeds.

---
 eclass/git-2.eclass |   36 ++++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index 3c8e0c5..fde72d6 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -251,6 +251,22 @@ git-2_prepare_storedir() {
 
 	# allow writing into EGIT_STORE_DIR
 	addwrite "${EGIT_STORE_DIR}"
+
+	# calculate git.eclass store dir for data
+	# We will try to clone the old repository,
+	# and we will remove it if we don't need it anymore.
+	EGIT_OLD_CLONE=
+	if [[ ${EGIT_STORE_DIR} == */egit-src ]]; then
+		local old_store_dir=${EGIT_STORE_DIR/%egit-src/git-src}
+		local old_location=${old_store_dir}/${EGIT_PROJECT:-${PN}}
+
+		if [[ -d ${old_location} ]]; then
+			EGIT_OLD_CLONE=${old_location}
+			# required to remove the old clone
+			addwrite "${old_store_dir}"
+		fi
+	fi
+
 	# calculate the proper store dir for data
 	# If user didn't specify the EGIT_DIR, we check if he did specify
 	# the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
@@ -263,16 +279,10 @@ git-2_prepare_storedir() {
 		fi
 		EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
 
-		# Try to migrate from git.eclass git-src/
-		if [[ ! -d ${EGIT_DIR} && ${EGIT_STORE_DIR} == */egit-src ]]; then
-			local old_store_dir=${EGIT_STORE_DIR/%egit-src/git-src}
-			local old_location=${old_store_dir}/${EGIT_PROJECT:-${PN}}
-
-			if [[ -d ${old_location} ]]; then
-				elog "${FUNCNAME}: ${CATEGORY}/${PVR} will be cloned from old location."
-				elog "It will be necessary to rebuild the package to fetch updates."
-				EGIT_REPO_URI="${old_location} ${EGIT_REPO_URI}"
-			fi
+		if [[ ${EGIT_OLD_CLONE} ]]; then
+			elog "${FUNCNAME}: ${CATEGORY}/${PVR} will be cloned from old location."
+			elog "It will be necessary to rebuild the package to fetch updates."
+			EGIT_REPO_URI="${EGIT_OLD_CLONE} ${EGIT_REPO_URI}"
 		fi
 	fi
 	export EGIT_DIR=${EGIT_DIR}
@@ -317,6 +327,12 @@ git-2_initial_clone() {
 
 	[[ ${EGIT_REPO_URI_SELECTED} ]] \
 		|| die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}"
+
+	# Cleanup after git.eclass
+	if [[ ${EGIT_OLD_CLONE} ]]; then
+		einfo "${FUNCNAME}: removing old clone in ${EGIT_OLD_CLONE}."
+		rm -rf "${EGIT_OLD_CLONE}"
+	fi
 }
 
 # @FUNCTION: git-2_update_repo
-- 
1.7.6.1

Attachment: signature.asc
Description: PGP signature

Reply via email to