* [gentoo-dev] [PATCH] git-r3.eclass: Support checking out specific subdirectories
@ 2017-11-17 23:24 Michał Górny
2017-11-28 9:15 ` Michał Górny
0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2017-11-17 23:24 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Support limiting the git checkout to specific subdirectories of the git
tree, using 'git checkout ... -- <paths>...' The main use case for this
is doing partial checkouts of very large repositories where only a small
subset of files is necessary. Doing partial checkouts can save both
time and disk space which can be important in large intertwined
projects such as LLVM+Clang.
---
eclass/git-r3.eclass | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
index c9d2731a64fe..caf4e8d003e0 100644
--- a/eclass/git-r3.eclass
+++ b/eclass/git-r3.eclass
@@ -803,7 +803,7 @@ git-r3_fetch() {
}
# @FUNCTION: git-r3_checkout
-# @USAGE: [<repo-uri> [<checkout-path> [<local-id>]]]
+# @USAGE: [<repo-uri> [<checkout-path> [<local-id> [<checkout-paths>...]]]]
# @DESCRIPTION:
# Check the previously fetched tree to the working copy.
#
@@ -819,6 +819,12 @@ git-r3_fetch() {
# <local-id> needs to specify the local identifier that was used
# for respective git-r3_fetch.
#
+# If <checkout-paths> are specified, then the specified paths are passed
+# to 'git checkout' to effect a partial checkout. Please note that such
+# checkout will not cause the repository to switch branches,
+# and submodules will be skipped at the moment. The submodules matching
+# those paths might be checked out in a future version of the eclass.
+#
# The checkout operation will write to the working copy, and export
# the repository state into the environment. If the repository contains
# submodules, they will be checked out recursively.
@@ -836,6 +842,7 @@ git-r3_checkout() {
local out_dir=${2:-${EGIT_CHECKOUT_DIR:-${WORKDIR}/${P}}}
local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}}
+ local checkout_paths=( "${@:4}" )
local -x GIT_DIR
_git-r3_set_gitdir "${repos[0]}"
@@ -883,6 +890,9 @@ git-r3_checkout() {
else
set -- "${@}" "${new_commit_id}"
fi
+ if [[ ${checkout_paths[@]} ]]; then
+ set -- "${@}" -- "${checkout_paths[@]}"
+ fi
echo "${@}" >&2
"${@}" || die "git checkout ${remote_ref:-${new_commit_id}} failed"
}
@@ -905,8 +915,12 @@ git-r3_checkout() {
echo " updating from commit: ${old_commit_id}"
echo " to commit: ${new_commit_id}"
- git --no-pager diff --stat \
+ set -- git --no-pager diff --stat \
${old_commit_id}..${new_commit_id}
+ if [[ ${checkout_paths[@]} ]]; then
+ set -- "${@}" -- "${checkout_paths[@]}"
+ fi
+ "${@}"
else
echo " at the commit: ${new_commit_id}"
fi
@@ -914,7 +928,7 @@ git-r3_checkout() {
git update-ref --no-deref refs/git-r3/"${local_id}"/{__old__,__main__} || die
# recursively checkout submodules
- if [[ -f ${out_dir}/.gitmodules ]]; then
+ if [[ -f ${out_dir}/.gitmodules && ! ${checkout_paths} ]]; then
local submodules
_git-r3_set_submodules \
"$(<"${out_dir}"/.gitmodules)"
--
2.15.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Support checking out specific subdirectories
2017-11-17 23:24 [gentoo-dev] [PATCH] git-r3.eclass: Support checking out specific subdirectories Michał Górny
@ 2017-11-28 9:15 ` Michał Górny
0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2017-11-28 9:15 UTC (permalink / raw
To: gentoo-dev
W dniu sob, 18.11.2017 o godzinie 00∶24 +0100, użytkownik Michał Górny
napisał:
> Support limiting the git checkout to specific subdirectories of the git
> tree, using 'git checkout ... -- <paths>...' The main use case for this
> is doing partial checkouts of very large repositories where only a small
> subset of files is necessary. Doing partial checkouts can save both
> time and disk space which can be important in large intertwined
> projects such as LLVM+Clang.
>
Merged now.
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-28 9:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-17 23:24 [gentoo-dev] [PATCH] git-r3.eclass: Support checking out specific subdirectories Michał Górny
2017-11-28 9:15 ` Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox