* [gentoo-dev] git-2: a bunch of patches to review
@ 2011-09-20 20:32 Michał Górny
2011-09-20 20:46 ` Tomáš Chvátal
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Michał Górny @ 2011-09-20 20:32 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 582 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Replace-variable-eval-s-with-foo.patch --]
[-- Type: text/x-patch, Size: 1966 bytes --]
From fca7c940dea8d30648e33c007a2795ea43109fdf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-Remove-unnecessary-scary-trailing-slash-check-for-EG.patch --]
[-- Type: text/x-patch, Size: 1022 bytes --]
From ec3155c319f19f4eac3ef2ebecfdeeaaafc64b74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: 0003-Drop-n-z-test-operators-they-re-redundant-in.patch --]
[-- Type: text/x-patch, Size: 5654 bytes --]
From 7d3cf70813b3772eb7ee7308192a717f33ff77b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.5: 0004-Replace-redundant-checks-with-explicit-if.fi.patch --]
[-- Type: text/x-patch, Size: 1469 bytes --]
From d55b610a317b0543b0c6172354bf50bc4102a2e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.6: 0005-Drop-redundant-EGIT_LOCAL_NONBARE-setting.patch --]
[-- Type: text/x-patch, Size: 802 bytes --]
From 4809f2f3ac7b4803b2a45b62b4268796b7723b47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.7: 0006-Simplify-bare-non-bare-logic.patch --]
[-- Type: text/x-patch, Size: 2208 bytes --]
From 862292ea161aa1d4c32828001520b2919617aa1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.8: 0007-Move-pushd-popds-around-to-make-code-simpler.patch --]
[-- Type: text/x-patch, Size: 1830 bytes --]
From fe08fdc1610007aae4e4c448299ccfd63620b04a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.9: 0008-Mark-internal-functions-INTERNAL.patch --]
[-- Type: text/x-patch, Size: 3133 bytes --]
From de5d01b4dd19f5388a293a9179f3a16c17435ff1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.10: 0009-Ensure-EGIT_LOCAL_NONBARE-doesn-t-leak-in-from-env.patch --]
[-- Type: text/x-patch, Size: 869 bytes --]
From daf51437b8f379e8f870753a5f64482767f00d42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.11: 0010-Try-to-migrate-git.eclass-checkouts-to-the-new-eclas.patch --]
[-- Type: text/x-patch, Size: 1322 bytes --]
From 3c2983c653ee583cba1898bdaa8dff7b65aa49ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.12: 0011-Remove-git.eclass-old-clones-if-git-2-clone-succeeds.patch --]
[-- Type: text/x-patch, Size: 2600 bytes --]
From 821d3a8d1b3173819fc5d7061a47e7e713a9434c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-20 20:32 [gentoo-dev] git-2: a bunch of patches to review Michał Górny
@ 2011-09-20 20:46 ` Tomáš Chvátal
2011-09-20 21:04 ` Michał Górny
2011-09-21 9:21 ` Michał Górny
2011-09-20 20:48 ` Stratos Psomadakis
2011-09-21 13:21 ` Michał Górny
2 siblings, 2 replies; 14+ messages in thread
From: Tomáš Chvátal @ 2011-09-20 20:46 UTC (permalink / raw
To: gentoo-dev
0001 - i had reason to put local definitions on the top, it is way
more readable to see right away what local vars function has, so
please stick to it.
0004 - Did you ever hear that executing another code in condition is
damn annoying to trace? :)
0007 - I placed it into the conditionals to be clear what is
happening, what if there will be added another if without the push...
0010 - 0011 - I was serious with getting crashes on some packages with
this approach (suprisingly i first really tried to make the eclass
backcompat as much as possible), did you get anyone else to ack this
thing? FWIW it is like fetching new packages, I can agree that
dowloading whole qt or libreoffice can make someone sad, but it is
just few megs compared to the rest of your weekly world update. -> You
are introducing possibility to nicely fail without any simple
resolution why for almost no benefit.
Cheers
Tom
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-20 20:32 [gentoo-dev] git-2: a bunch of patches to review Michał Górny
2011-09-20 20:46 ` Tomáš Chvátal
@ 2011-09-20 20:48 ` Stratos Psomadakis
2011-09-20 21:02 ` Michał Górny
2011-09-21 13:21 ` Michał Górny
2 siblings, 1 reply; 14+ messages in thread
From: Stratos Psomadakis @ 2011-09-20 20:48 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 902 bytes --]
On 09/20/2011 11:32 PM, Michał Górny wrote:
> Hello all,
>
> I've prepared a bunch of patches to git-2.eclass.
Just a suggestion (and maybe a bit off-topic), but I think if you sent
each patch separately, as replies to the original thread (git send-email
can do that), it would make the review of each patch easier (if that's
what you wanted :).
> 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.
--
Stratos Psomadakis
<psomas@gentoo.org>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-20 20:48 ` Stratos Psomadakis
@ 2011-09-20 21:02 ` Michał Górny
0 siblings, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-09-20 21:02 UTC (permalink / raw
To: gentoo-dev; +Cc: psomas
[-- Attachment #1: Type: text/plain, Size: 559 bytes --]
On Tue, 20 Sep 2011 23:48:36 +0300
Stratos Psomadakis <psomas@gentoo.org> wrote:
> On 09/20/2011 11:32 PM, Michał Górny wrote:
> > Hello all,
> >
> > I've prepared a bunch of patches to git-2.eclass.
> Just a suggestion (and maybe a bit off-topic), but I think if you sent
> each patch separately, as replies to the original thread (git
> send-email can do that), it would make the review of each patch
> easier (if that's what you wanted :).
Then I'd get another 3 e-mails saying to do the opposite :P.
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-20 20:46 ` Tomáš Chvátal
@ 2011-09-20 21:04 ` Michał Górny
2011-09-21 9:21 ` Michał Górny
1 sibling, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-09-20 21:04 UTC (permalink / raw
To: gentoo-dev; +Cc: scarabeus
[-- Attachment #1: Type: text/plain, Size: 1009 bytes --]
On Tue, 20 Sep 2011 22:46:10 +0200
Tomáš Chvátal <scarabeus@gentoo.org> wrote:
> 0007 - I placed it into the conditionals to be clear what is
> happening, what if there will be added another if without the push...
Well, that part is not important, I can rollback it. It was mostly for
the repack/prune part.
> 0010 - 0011 - I was serious with getting crashes on some packages with
> this approach (suprisingly i first really tried to make the eclass
> backcompat as much as possible), did you get anyone else to ack this
> thing? FWIW it is like fetching new packages, I can agree that
> dowloading whole qt or libreoffice can make someone sad, but it is
> just few megs compared to the rest of your weekly world update. -> You
> are introducing possibility to nicely fail without any simple
> resolution why for almost no benefit.
Even with 'git clone' approach? Could you point me to a particular test
case or bug describing this thoroughly?
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-20 20:46 ` Tomáš Chvátal
2011-09-20 21:04 ` Michał Górny
@ 2011-09-21 9:21 ` Michał Górny
1 sibling, 0 replies; 14+ messages in thread
From: Michał Górny @ 2011-09-21 9:21 UTC (permalink / raw
To: gentoo-dev; +Cc: scarabeus
[-- Attachment #1.1: Type: text/plain, Size: 455 bytes --]
On Tue, 20 Sep 2011 22:46:10 +0200
Tomáš Chvátal <scarabeus@gentoo.org> wrote:
> 0001 - i had reason to put local definitions on the top, it is way
> more readable to see right away what local vars function has, so
> please stick to it.
> 0007 - I placed it into the conditionals to be clear what is
> happening, what if there will be added another if without the push...
Ok, these two fixed/replaced.
--
Best regards,
Michał Górny
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Replace-variable-eval-s-with-foo.patch --]
[-- Type: text/x-patch, Size: 1917 bytes --]
From ec201cb4379f9aaef3d398fc0d415cb6bc011770 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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, 10 insertions(+), 9 deletions(-)
diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index 0caa3d4..2408178 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -127,7 +127,8 @@ DEPEND="dev-vcs/git"
git-2_init_variables() {
debug-print-function ${FUNCNAME} "$@"
- local x
+ local esc_pn liverepo livebranch livecommit
+ esc_pn=${PN//[-+]/_}
: ${EGIT_SOURCEDIR="${S}"}
@@ -139,19 +140,19 @@ git-2_init_variables() {
: ${EGIT_MASTER:=master}
- eval x="\$${PN//[-+]/_}_LIVE_REPO"
- EGIT_REPO_URI=${x:-${EGIT_REPO_URI}}
+ 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}}}
+ 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}}}
+ 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0007-Move-pushd-popds-within-conditional-to-avoid-needles.patch --]
[-- Type: text/x-patch, Size: 947 bytes --]
From 88a37d65fcb2a4f7e4c40fecb3ab14c7a62c3bc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Tue, 20 Sep 2011 20:53:26 +0200
Subject: [PATCH 07/11] Move pushd/popds within conditional to avoid needless
exec.
---
eclass/git-2.eclass | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index cc2cc95..a94dc7c 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -217,15 +217,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
--
1.7.6.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-20 20:32 [gentoo-dev] git-2: a bunch of patches to review Michał Górny
2011-09-20 20:46 ` Tomáš Chvátal
2011-09-20 20:48 ` Stratos Psomadakis
@ 2011-09-21 13:21 ` Michał Górny
2011-09-22 7:01 ` Ulrich Mueller
2 siblings, 1 reply; 14+ messages in thread
From: Michał Górny @ 2011-09-21 13:21 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 489 bytes --]
Attaching fixed version of the last two patches, and a complete eclass
for convenience.
On Tue, 20 Sep 2011 22:32:52 +0200
Michał Górny <mgorny@gentoo.org> wrote:
> 10 -- tries to migrate git.eclass clones to git-2.eclass (#383761).
Fixed invalid output (PVR -> PF).
> 11 -- removes old git.eclass clones to not waste diskspace.
Fixed reusing old clone over and over again, and made removal triggered
not only on initial clone.
--
Best regards,
Michał Górny
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0010-Try-to-migrate-git.eclass-checkouts-to-the-new-eclas.patch --]
[-- Type: text/x-patch, Size: 1321 bytes --]
From cc027da761e37b184442003bc8d98a0b5b49411a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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 e0a5615..a72e041 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -264,6 +264,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}/${PF} 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0011-Remove-git.eclass-old-clones-if-git-2-clone-succeeds.patch --]
[-- Type: text/x-patch, Size: 2667 bytes --]
From 35014dd3c02fd4e7bc93315e47f1960fdd8b7f2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@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 a72e041..9384531 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -253,6 +253,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.
@@ -265,16 +281,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}/${PF} 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} && ! -d ${EGIT_DIR} ]]; then
+ elog "${FUNCNAME}: ${CATEGORY}/${PF} 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}
@@ -414,6 +424,12 @@ git-2_fetch() {
echo " branch: ${EGIT_BRANCH}"
echo " storage directory: \"${EGIT_DIR}\""
echo " checkout type: ${repo_type}"
+
+ # 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_bootstrap
--
1.7.6.1
[-- Attachment #1.4: git-2.eclass --]
[-- Type: application/octet-stream, Size: 17753 bytes --]
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.14 2011/08/22 04:46:31 vapier Exp $
# @ECLASS: git-2.eclass
# @MAINTAINER:
# Donnie Berkholz <dberkholz@gentoo.org>
# @BLURB: Eclass for fetching and unpacking git repositories.
# @DESCRIPTION:
# Eclass for easing maitenance of live ebuilds using git as remote repository.
# Eclass support working with git submodules and branching.
# This eclass support all EAPIs
EXPORT_FUNCTIONS src_unpack
DEPEND="dev-vcs/git"
# @ECLASS-VARIABLE: EGIT_SOURCEDIR
# @DESCRIPTION:
# This variable specifies destination where the cloned
# data are copied to.
#
# EGIT_SOURCEDIR="${S}"
# @ECLASS-VARIABLE: EGIT_STORE_DIR
# @DESCRIPTION:
# Storage directory for git sources.
#
# EGIT_STORE_DIR="${DISTDIR}/egit-src"
# @ECLASS-VARIABLE: EGIT_HAS_SUBMODULES
# @DEFAULT_UNSET
# @DESCRIPTION:
# If non-empty this variable enables support for git submodules in our
# checkout. Also this makes the checkout to be non-bare for now.
# @ECLASS-VARIABLE: EGIT_OPTIONS
# @DEFAULT_UNSET
# @DESCRIPTION:
# Variable specifying additional options for fetch command.
# @ECLASS-VARIABLE: EGIT_MASTER
# @DESCRIPTION:
# Variable for specifying master branch.
# Usefull when upstream don't have master branch or name it differently.
#
# EGIT_MASTER="master"
# @ECLASS-VARIABLE: EGIT_PROJECT
# @DESCRIPTION:
# Variable specifying name for the folder where we check out the git
# repository. Value of this variable should be unique in the
# EGIT_STORE_DIR as otherwise you would override another repository.
#
# EGIT_PROJECT="${EGIT_REPO_URI##*/}"
# @ECLASS-VARIABLE: EGIT_DIR
# @DESCRIPTION:
# Directory where we want to store the git data.
# This variable should not be overriden.
#
# EGIT_DIR="${EGIT_STORE_DIR}/${EGIT_PROJECT}"
# @ECLASS-VARIABLE: EGIT_REPO_URI
# @REQUIRED
# @DEFAULT_UNSET
# @DESCRIPTION:
# URI for the repository
# e.g. http://foo, git://bar
#
# Support multiple values:
# EGIT_REPO_URI="git://a/b.git http://c/d.git"
# @ECLASS-VARIABLE: EVCS_OFFLINE
# @DEFAULT_UNSET
# @DESCRIPTION:
# If non-empty this variable prevents performance of any online
# operations.
# @ECLASS-VARIABLE: EGIT_BRANCH
# @DESCRIPTION:
# Variable containing branch name we want to check out.
# It can be overriden via env using packagename_LIVE_BRANCH
# variable.
#
# EGIT_BRANCH="${EGIT_MASTER}"
# @ECLASS-VARIABLE: EGIT_COMMIT
# @DESCRIPTION:
# Variable containing commit hash/tag we want to check out.
# It can be overriden via env using packagename_LIVE_COMMIT
# variable.
#
# EGIT_COMMIT="${EGIT_BRANCH}"
# @ECLASS-VARIABLE: EGIT_REPACK
# @DEFAULT_UNSET
# @DESCRIPTION:
# If non-empty this variable specifies that repository will be repacked to
# save space. However this can take a REALLY LONG time with VERY big
# repositories.
# @ECLASS-VARIABLE: EGIT_PRUNE
# @DEFAULT_UNSET
# @DESCRIPTION:
# If non-empty this variable enables pruning all loose objects on each fetch.
# This is useful if upstream rewinds and rebases branches often.
# @ECLASS-VARIABLE: EGIT_NONBARE
# @DEFAULT_UNSET
# @DESCRIPTION:
# If non-empty this variable specifies that all checkouts will be done using
# non bare repositories. This is useful if you can't operate with bare
# checkouts for some reason.
# @ECLASS-VARIABLE: EGIT_NOUNPACK
# @DEFAULT_UNSET
# @DESCRIPTION:
# If non-empty this variable bans unpacking of ${A} content into the srcdir.
# 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
# all the variables before and after inherit.
git-2_init_variables() {
debug-print-function ${FUNCNAME} "$@"
local esc_pn liverepo livebranch livecommit
esc_pn=${PN//[-+]/_}
: ${EGIT_SOURCEDIR="${S}"}
: ${EGIT_STORE_DIR:="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/egit-src"}
: ${EGIT_HAS_SUBMODULES:=}
: ${EGIT_OPTIONS:=}
: ${EGIT_MASTER:=master}
liverepo=${esc_pn}_LIVE_REPO
EGIT_REPO_URI=${!liverepo:-${EGIT_REPO_URI}}
[[ ${EGIT_REPO_URI} ]] || die "EGIT_REPO_URI must have some value"
: ${EVCS_OFFLINE:=}
livebranch=${esc_pn}_LIVE_BRANCH
[[ ${!livebranch} ]] && ewarn "QA: using \"${esc_pn}_LIVE_BRANCH\" variable, you won't get any support"
EGIT_BRANCH=${!livebranch:-${EGIT_BRANCH:-${EGIT_MASTER}}}
livecommit=${esc_pn}_LIVE_COMMIT
[[ ${!livecommit} ]] && ewarn "QA: using \"${esc_pn}_LIVE_COMMIT\" variable, you won't get any support"
EGIT_COMMIT=${!livecommit:-${EGIT_COMMIT:-${EGIT_BRANCH}}}
: ${EGIT_REPACK:=}
: ${EGIT_PRUNE:=}
}
# @FUNCTION: git-2_submodules
# @INTERNAL
# @DESCRIPTION:
# Internal function wrapping the submodule initialisation and update.
git-2_submodules() {
debug-print-function ${FUNCNAME} "$@"
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
fi
debug-print "${FUNCNAME}: working in \"${1}\""
pushd "${EGIT_DIR}" > /dev/null
debug-print "${FUNCNAME}: git submodule init"
git submodule init || die
debug-print "${FUNCNAME}: git submodule sync"
git submodule sync || die
debug-print "${FUNCNAME}: git submodule update"
git submodule update || die
popd > /dev/null
fi
}
# @FUNCTION: git-2_branch
# @INTERNAL
# @DESCRIPTION:
# Internal function that changes branch for the repo based on EGIT_COMMIT and
# EGIT_BRANCH variables.
git-2_branch() {
debug-print-function ${FUNCNAME} "$@"
local branchname src
debug-print "${FUNCNAME}: working in \"${EGIT_SOURCEDIR}\""
pushd "${EGIT_SOURCEDIR}" > /dev/null
local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH}
if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then
branchname=tree-${EGIT_COMMIT}
src=${EGIT_COMMIT}
fi
debug-print "${FUNCNAME}: git checkout -b ${branchname} ${src}"
git checkout -b ${branchname} ${src} \
|| die "${FUNCNAME}: changing the branch failed"
popd > /dev/null
}
# @FUNCTION: git-2_gc
# @INTERNAL
# @DESCRIPTION:
# Internal function running garbage collector on checked out tree.
git-2_gc() {
debug-print-function ${FUNCNAME} "$@"
local args
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
}
# @FUNCTION: git-2_prepare_storedir
# @INTERNAL
# @DESCRIPTION:
# Internal function preparing directory where we are going to store SCM
# repository.
git-2_prepare_storedir() {
debug-print-function ${FUNCNAME} "$@"
local clone_dir
# initial clone, we have to create master git storage directory and play
# nicely with sandbox
if [[ ! -d ${EGIT_STORE_DIR} ]]; then
debug-print "${FUNCNAME}: Creating git main storage directory"
addwrite /
mkdir -p "${EGIT_STORE_DIR}" \
|| die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\""
fi
# 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.
EGIT_REPO_URI=${EGIT_REPO_URI%/}
if [[ ! ${EGIT_DIR} ]]; then
if [[ ${EGIT_PROJECT} ]]; then
clone_dir=${EGIT_PROJECT}
else
clone_dir=${EGIT_REPO_URI##*/}
fi
EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
if [[ ${EGIT_OLD_CLONE} && ! -d ${EGIT_DIR} ]]; then
elog "${FUNCNAME}: ${CATEGORY}/${PF} 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}
debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
}
# @FUNCTION: git-2_move_source
# @INTERNAL
# @DESCRIPTION:
# Internal function moving sources from the EGIT_DIR to EGIT_SOURCEDIR dir.
git-2_move_source() {
debug-print-function ${FUNCNAME} "$@"
debug-print "${FUNCNAME}: ${MOVE_COMMAND} \"${EGIT_DIR}\" \"${EGIT_SOURCEDIR}\""
pushd "${EGIT_DIR}" > /dev/null
mkdir -p "${EGIT_SOURCEDIR}" \
|| die "${FUNCNAME}: failed to create ${EGIT_SOURCEDIR}"
${MOVE_COMMAND} "${EGIT_SOURCEDIR}" \
|| die "${FUNCNAME}: sync to \"${EGIT_SOURCEDIR}\" failed"
popd > /dev/null
}
# @FUNCTION: git-2_initial_clone
# @INTERNAL
# @DESCRIPTION:
# Internal function running initial clone on specified repo_uri.
git-2_initial_clone() {
debug-print-function ${FUNCNAME} "$@"
local repo_uri
EGIT_REPO_URI_SELECTED=""
for repo_uri in ${EGIT_REPO_URI}; do
debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\""
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}"
break
fi
done
[[ ${EGIT_REPO_URI_SELECTED} ]] \
|| die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}"
}
# @FUNCTION: git-2_update_repo
# @INTERNAL
# @DESCRIPTION:
# Internal function running update command on specified repo_uri.
git-2_update_repo() {
debug-print-function ${FUNCNAME} "$@"
local repo_uri
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
debug-print "${FUNCNAME}: git branch -D ${x}"
git branch -D ${x} > /dev/null
done
fi
EGIT_REPO_URI_SELECTED=""
for repo_uri in ${EGIT_REPO_URI}; do
# git urls might change, so reset it
git config remote.origin.url "${repo_uri}"
debug-print "${EGIT_UPDATE_CMD}"
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}"
break
fi
done
[[ ${EGIT_REPO_URI_SELECTED} ]] \
|| die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}"
}
# @FUNCTION: git-2_fetch
# @INTERNAL
# @DESCRIPTION:
# Internal function fetching repository from EGIT_REPO_URI and storing it in
# specified EGIT_STORE_DIR.
git-2_fetch() {
debug-print-function ${FUNCNAME} "$@"
local oldsha cursha repo_type
[[ ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
if [[ ! -d ${EGIT_DIR} ]]; then
git-2_initial_clone
pushd "${EGIT_DIR}" > /dev/null
cursha=$(git rev-parse ${UPSTREAM_BRANCH})
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})
git-2_update_repo
cursha=$(git rev-parse ${UPSTREAM_BRANCH})
# fetch updates
echo "GIT update -->"
echo " repository: ${EGIT_REPO_URI_SELECTED}"
# write out message based on the revisions
if [[ "${oldsha}" != "${cursha}" ]]; then
echo " updating from commit: ${oldsha}"
echo " to commit: ${cursha}"
else
echo " at the commit: ${cursha}"
fi
# print nice statistic of what was changed
git --no-pager diff --stat ${oldsha}..${UPSTREAM_BRANCH}
popd > /dev/null
fi
# export the version the repository is at
export EGIT_VERSION="${cursha}"
# log the repo state
[[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \
&& echo " commit: ${EGIT_COMMIT}"
echo " branch: ${EGIT_BRANCH}"
echo " storage directory: \"${EGIT_DIR}\""
echo " checkout type: ${repo_type}"
# 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_bootstrap
# @INTERNAL
# @DESCRIPTION:
# Internal function that runs bootstrap command on unpacked source.
git-2_bootstrap() {
debug-print-function ${FUNCNAME} "$@"
# @ECLASS-VARIABLE: EGIT_BOOTSTRAP
# @DESCRIPTION:
# Command to be executed after checkout and clone of the specified
# repository.
# 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 [[ ${EGIT_BOOTSTRAP} ]]; then
pushd "${EGIT_SOURCEDIR}" > /dev/null
einfo "Starting bootstrap"
if [[ -f ${EGIT_BOOTSTRAP} ]]; then
# we have file in the repo which we should execute
debug-print "${FUNCNAME}: bootstraping with file \"${EGIT_BOOTSTRAP}\""
if [[ -x ${EGIT_BOOTSTRAP} ]]; then
eval "./${EGIT_BOOTSTRAP}" \
|| die "${FUNCNAME}: bootstrap script failed"
else
eerror "\"${EGIT_BOOTSTRAP}\" is not executable."
eerror "Report upstream, or bug ebuild maintainer to remove bootstrap command."
die "\"${EGIT_BOOTSTRAP}\" is not executable"
fi
else
# we execute some system command
debug-print "${FUNCNAME}: bootstraping with commands \"${EGIT_BOOTSTRAP}\""
eval "${EGIT_BOOTSTRAP}" \
|| die "${FUNCNAME}: bootstrap commands failed"
fi
einfo "Bootstrap finished"
popd > /dev/null
fi
}
# @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
# start to work with bare checkouts sanely.
# This function also set some global variables that differ between
# bare and non-bare checkout.
git-2_migrate_repository() {
debug-print-function ${FUNCNAME} "$@"
local bare returnstate
# first find out if we have submodules
# 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 [[ ${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"
mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare"
export GIT_DIR="${EGIT_DIR}.bare"
git config core.bare true > /dev/null
returnstate=$?
unset GIT_DIR
rm -rf "${EGIT_DIR}"
mv "${EGIT_DIR}.bare" "${EGIT_DIR}"
eend ${returnstate}
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"
git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null
returnstate=$?
rm -rf "${EGIT_DIR}"
mv "${EGIT_DIR}.nonbare" "${EGIT_DIR}"
eend ${returnstate}
fi
fi
if [[ ${returnstate} -ne 0 ]]; then
debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" failed, removing to start from scratch"
# migration failed, remove the EGIT_DIR to play it safe
einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch."
rm -rf "${EGIT_DIR}"
fi
# set various options to work with both targets
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// /\\ }"
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 ."
EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}"
EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}"
UPSTREAM_BRANCH="origin/${EGIT_BRANCH}"
EGIT_LOCAL_NONBARE="true"
fi
}
# @FUNCTION: git-2_cleanup
# @INTERNAL
# @DESCRIPTION:
# Internal function cleaning up all the global variables
# that are not required after the unpack has been done.
git-2_cleanup() {
debug-print-function ${FUNCNAME} "$@"
# Here we can unset only variables that are GLOBAL
# defined by the eclass, BUT NOT subject to change
# by user (like EGIT_PROJECT).
# If ebuild writer polutes his environment it is
# his problem only.
unset EGIT_DIR
unset MOVE_COMMAND
unset EGIT_LOCAL_OPTIONS
unset EGIT_UPDATE_CMD
unset UPSTREAM_BRANCH
unset EGIT_LOCAL_NONBARE
}
# @FUNCTION: git-2_src_unpack
# @DESCRIPTION:
# Default git src_unpack function.
git-2_src_unpack() {
debug-print-function ${FUNCNAME} "$@"
git-2_init_variables
git-2_prepare_storedir
git-2_migrate_repository
git-2_fetch "$@"
git-2_gc
git-2_submodules
git-2_move_source
git-2_branch
git-2_bootstrap
git-2_cleanup
echo ">>> Unpacked to ${EGIT_SOURCEDIR}"
# Users can specify some SRC_URI and we should
# unpack the files too.
if [[ ! ${EGIT_NOUNPACK} ]]; then
if has ${EAPI:-0} 0 1; then
[[ ${A} ]] && unpack ${A}
else
default_src_unpack
fi
fi
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-21 13:21 ` Michał Górny
@ 2011-09-22 7:01 ` Ulrich Mueller
2011-09-22 7:47 ` Fabian Groffen
2011-09-22 8:11 ` Michał Górny
0 siblings, 2 replies; 14+ messages in thread
From: Ulrich Mueller @ 2011-09-22 7:01 UTC (permalink / raw
To: gentoo-dev
> Attaching fixed version of the last two patches, and a complete
> eclass for convenience.
Just a general comment: Is it really necessary to change all
[[ -n ${foo} ]] and [[ -z ${foo} ]] conditionals to the more obscure
[[ ${foo} ]] and [[ ! ${foo} ]]?
The shortest possible form is not always the one that's best readable.
Ulrich
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-22 7:01 ` Ulrich Mueller
@ 2011-09-22 7:47 ` Fabian Groffen
2011-09-22 8:11 ` Michał Górny
1 sibling, 0 replies; 14+ messages in thread
From: Fabian Groffen @ 2011-09-22 7:47 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 508 bytes --]
On 22-09-2011 09:01:17 +0200, Ulrich Mueller wrote:
> > Attaching fixed version of the last two patches, and a complete
> > eclass for convenience.
>
> Just a general comment: Is it really necessary to change all
> [[ -n ${foo} ]] and [[ -z ${foo} ]] conditionals to the more obscure
> [[ ${foo} ]] and [[ ! ${foo} ]]?
>
> The shortest possible form is not always the one that's best readable.
+1
The style used is up to the maintainer.
--
Fabian Groffen
Gentoo on a different level
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-22 7:01 ` Ulrich Mueller
2011-09-22 7:47 ` Fabian Groffen
@ 2011-09-22 8:11 ` Michał Górny
2011-09-22 10:58 ` Jorge Manuel B. S. Vicetto
1 sibling, 1 reply; 14+ messages in thread
From: Michał Górny @ 2011-09-22 8:11 UTC (permalink / raw
To: gentoo-dev; +Cc: ulm
[-- Attachment #1: Type: text/plain, Size: 712 bytes --]
On Thu, 22 Sep 2011 09:01:17 +0200
Ulrich Mueller <ulm@gentoo.org> wrote:
> > Attaching fixed version of the last two patches, and a complete
> > eclass for convenience.
>
> Just a general comment: Is it really necessary to change all
> [[ -n ${foo} ]] and [[ -z ${foo} ]] conditionals to the more obscure
> [[ ${foo} ]] and [[ ! ${foo} ]]?
>
> The shortest possible form is not always the one that's best readable.
The style change was approved by Donnie already.
Also, this one looks better when a particular var is used as a 'bash
boolean', e.g. EVCS_OFFLINE, bare, etc. Then [[ ${EVCS_OFFLINE} ]] is
more explanatory than [[ -n ${EVCS_OFFLINE} ]].
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-22 8:11 ` Michał Górny
@ 2011-09-22 10:58 ` Jorge Manuel B. S. Vicetto
2011-09-22 11:27 ` Michał Górny
0 siblings, 1 reply; 14+ messages in thread
From: Jorge Manuel B. S. Vicetto @ 2011-09-22 10:58 UTC (permalink / raw
To: gentoo-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 22-09-2011 08:11, Michał Górny wrote:
> On Thu, 22 Sep 2011 09:01:17 +0200 Ulrich Mueller <ulm@gentoo.org>
> wrote:
>
>>> Attaching fixed version of the last two patches, and a
>>> complete eclass for convenience.
>>
>> Just a general comment: Is it really necessary to change all [[
>> -n ${foo} ]] and [[ -z ${foo} ]] conditionals to the more
>> obscure [[ ${foo} ]] and [[ ! ${foo} ]]?
>>
>> The shortest possible form is not always the one that's best
>> readable.
>
> The style change was approved by Donnie already.
You mean that Donnie agreed with the style change. It's not up to any
individual developer to "approve" such a change for the entire tree.
- --
Regards,
Jorge Vicetto (jmbsvicetto) - jmbsvicetto at gentoo dot org
Gentoo- forums / Userrel / Devrel / KDE / Elections / RelEng
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJOexTUAAoJEC8ZTXQF1qEPMZ0QALNSTSCLwCKP9hd2BSt7HtP3
BzsJHr9Q+9+DpdwG9eRjbE0AnW1EbhpFmctPAnEszwC7I0NxID8vAsMw4HQS2MA8
wv2HKY14HYhSV9KBhHISn0i3tg8+LPwCpZJUYca4LWM+1o6brW/+MYEyzRBjWnMN
ljVEfK+to94+UvsPZyjvd0jRp3MuGVoATyXEDwHo1pNFC89Fq03J2YSvP6lPYE1V
J/Etw9PM5jJLWE7qQ8BlxHvf4FCWXZbAoOJ1kAFKLUp0v9AJeHssU84ZxZWDU/Rc
NjAiscFDXfhldL/DYlXFtZe24nF2V9aJ8DNFk+639f+L45oky5WNupiyRLMyn9ut
WAJAoPIoyQRccph5eAW2frrk7hUKhjsfS3uCDCB9otncQYpAFLK4X8USzRMEQlNV
QBBODOwccb/9BbwK6WGTywJiamB36dR9YGtdD6h+gULytRP9+WCK2HYGhQOAxumE
y+nVo4o5JAvHJ5W2IpCO611rbpyx/KXLGMu7my2OY06xrSsf1tU1DMEN+T3YtZ0s
s7TQRvbobKYmi4RsbQ/3J6ept5KldLLuhi4B/l/Nst2Di9bMCQ0bCHKcObeKsir+
LOb7zdVMwVAvCK1DvnPgFKMyR5LCfcHvdy1tD6UxwYlNUcm6SNMytb1QET/B0k4n
6Yyi7UQgCXfYWP5KL7TX
=4YOg
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-22 10:58 ` Jorge Manuel B. S. Vicetto
@ 2011-09-22 11:27 ` Michał Górny
2011-09-22 14:41 ` Andreas K. Huettel
0 siblings, 1 reply; 14+ messages in thread
From: Michał Górny @ 2011-09-22 11:27 UTC (permalink / raw
To: gentoo-dev; +Cc: jmbsvicetto
[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]
On Thu, 22 Sep 2011 10:58:28 +0000
"Jorge Manuel B. S. Vicetto" <jmbsvicetto@gentoo.org> wrote:
> On 22-09-2011 08:11, Michał Górny wrote:
> > On Thu, 22 Sep 2011 09:01:17 +0200 Ulrich Mueller <ulm@gentoo.org>
> > wrote:
> >
> >>> Attaching fixed version of the last two patches, and a
> >>> complete eclass for convenience.
> >>
> >> Just a general comment: Is it really necessary to change all [[
> >> -n ${foo} ]] and [[ -z ${foo} ]] conditionals to the more
> >> obscure [[ ${foo} ]] and [[ ! ${foo} ]]?
> >>
> >> The shortest possible form is not always the one that's best
> >> readable.
> >
> > The style change was approved by Donnie already.
>
> You mean that Donnie agreed with the style change. It's not up to any
> individual developer to "approve" such a change for the entire tree.
What kind of 'entire tree'? It is just a single eclass, and its
maintainer approves coding style change. Where do you see a problem
with that?
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-22 11:27 ` Michał Górny
@ 2011-09-22 14:41 ` Andreas K. Huettel
2011-09-22 16:29 ` Donnie Berkholz
0 siblings, 1 reply; 14+ messages in thread
From: Andreas K. Huettel @ 2011-09-22 14:41 UTC (permalink / raw
To: gentoo-dev
Am Donnerstag 22 September 2011, 13:27:47 schrieb Michał Górny:
> > >
> > > The style change was approved by Donnie already.
> >
> > You mean that Donnie agreed with the style change. It's not up to any
> > individual developer to "approve" such a change for the entire tree.
>
> What kind of 'entire tree'? It is just a single eclass, and its
> maintainer approves coding style change. Where do you see a problem
> with that?
>
As Scarabeus wrote 99% of the eclass it's probably not obvious to everyone that Donnie is listed as its maintainer.
--
Andreas K. Huettel
Gentoo Linux developer - kde, sci, arm, tex
dilfridge@gentoo.org
http://www.akhuettel.de/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [gentoo-dev] git-2: a bunch of patches to review
2011-09-22 14:41 ` Andreas K. Huettel
@ 2011-09-22 16:29 ` Donnie Berkholz
0 siblings, 0 replies; 14+ messages in thread
From: Donnie Berkholz @ 2011-09-22 16:29 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 925 bytes --]
On 16:41 Thu 22 Sep , Andreas K. Huettel wrote:
> Am Donnerstag 22 September 2011, 13:27:47 schrieb Michał Górny:
> > > >
> > > > The style change was approved by Donnie already.
> > >
> > > You mean that Donnie agreed with the style change. It's not up to any
> > > individual developer to "approve" such a change for the entire tree.
> >
> > What kind of 'entire tree'? It is just a single eclass, and its
> > maintainer approves coding style change. Where do you see a problem
> > with that?
> >
>
> As Scarabeus wrote 99% of the eclass it's probably not obvious to
> everyone that Donnie is listed as its maintainer.
And as Michał is making many of the changes recently because scarabeus
got busy and the eclass works fine for me already, I figure it's his
prerogative.
--
Thanks,
Donnie
Donnie Berkholz
Council Member / Sr. Developer
Gentoo Linux
Blog: http://dberkholz.com
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-09-22 16:30 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-20 20:32 [gentoo-dev] git-2: a bunch of patches to review Michał Górny
2011-09-20 20:46 ` Tomáš Chvátal
2011-09-20 21:04 ` Michał Górny
2011-09-21 9:21 ` Michał Górny
2011-09-20 20:48 ` Stratos Psomadakis
2011-09-20 21:02 ` Michał Górny
2011-09-21 13:21 ` Michał Górny
2011-09-22 7:01 ` Ulrich Mueller
2011-09-22 7:47 ` Fabian Groffen
2011-09-22 8:11 ` Michał Górny
2011-09-22 10:58 ` Jorge Manuel B. S. Vicetto
2011-09-22 11:27 ` Michał Górny
2011-09-22 14:41 ` Andreas K. Huettel
2011-09-22 16:29 ` Donnie Berkholz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox