1 |
mgorny 14/03/02 11:48:05 |
2 |
|
3 |
Modified: ChangeLog git-r3.eclass |
4 |
Log: |
5 |
Support EGIT_CLONE_TYPE=shallow. |
6 |
|
7 |
Revision Changes Path |
8 |
1.1158 eclass/ChangeLog |
9 |
|
10 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1158&view=markup |
11 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1158&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.1157&r2=1.1158 |
13 |
|
14 |
Index: ChangeLog |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v |
17 |
retrieving revision 1.1157 |
18 |
retrieving revision 1.1158 |
19 |
diff -u -r1.1157 -r1.1158 |
20 |
--- ChangeLog 2 Mar 2014 11:47:41 -0000 1.1157 |
21 |
+++ ChangeLog 2 Mar 2014 11:48:05 -0000 1.1158 |
22 |
@@ -1,6 +1,9 @@ |
23 |
# ChangeLog for eclass directory |
24 |
# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 |
25 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1157 2014/03/02 11:47:41 mgorny Exp $ |
26 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1158 2014/03/02 11:48:05 mgorny Exp $ |
27 |
+ |
28 |
+ 02 Mar 2014; Michał Górny <mgorny@g.o> git-r3.eclass: |
29 |
+ Support EGIT_CLONE_TYPE=shallow. |
30 |
|
31 |
02 Mar 2014; Michał Górny <mgorny@g.o> git-r3.eclass: |
32 |
Support EGIT_CLONE_TYPE=single. |
33 |
|
34 |
|
35 |
|
36 |
1.33 eclass/git-r3.eclass |
37 |
|
38 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?rev=1.33&view=markup |
39 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?rev=1.33&content-type=text/plain |
40 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/git-r3.eclass?r1=1.32&r2=1.33 |
41 |
|
42 |
Index: git-r3.eclass |
43 |
=================================================================== |
44 |
RCS file: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v |
45 |
retrieving revision 1.32 |
46 |
retrieving revision 1.33 |
47 |
diff -u -r1.32 -r1.33 |
48 |
--- git-r3.eclass 2 Mar 2014 11:47:41 -0000 1.32 |
49 |
+++ git-r3.eclass 2 Mar 2014 11:48:05 -0000 1.33 |
50 |
@@ -1,6 +1,6 @@ |
51 |
# Copyright 1999-2014 Gentoo Foundation |
52 |
# Distributed under the terms of the GNU General Public License v2 |
53 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.32 2014/03/02 11:47:41 mgorny Exp $ |
54 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.33 2014/03/02 11:48:05 mgorny Exp $ |
55 |
|
56 |
# @ECLASS: git-r3.eclass |
57 |
# @MAINTAINER: |
58 |
@@ -29,13 +29,13 @@ |
59 |
if [[ ! ${_GIT_R3} ]]; then |
60 |
|
61 |
if [[ ! ${_INHERITED_BY_GIT_2} ]]; then |
62 |
- DEPEND="dev-vcs/git" |
63 |
+ DEPEND=">=dev-vcs/git-1.8.2.1" |
64 |
fi |
65 |
|
66 |
# @ECLASS-VARIABLE: EGIT_CLONE_TYPE |
67 |
# @DESCRIPTION: |
68 |
# Type of clone that should be used against the remote repository. |
69 |
-# This can be either of: 'mirror', 'single'. |
70 |
+# This can be either of: 'mirror', 'single', 'shallow'. |
71 |
# |
72 |
# The 'mirror' type clones all remote branches and tags with complete |
73 |
# history and all notes. EGIT_COMMIT can specify any commit hash. |
74 |
@@ -50,6 +50,12 @@ |
75 |
# in the current branch. No purging of old references is done (if you |
76 |
# often switch branches, you may need to remove stale branches |
77 |
# yourself). This mode is suitable for general use. |
78 |
+# |
79 |
+# The 'shallow' type clones only the newest commit on requested branch |
80 |
+# or tag. EGIT_COMMIT can only specify tags, and since the history is |
81 |
+# unavailable calls like 'git describe' will not reference prior tags. |
82 |
+# No purging of old references is done. This mode is intended mostly for |
83 |
+# embedded systems with limited disk space. |
84 |
: ${EGIT_CLONE_TYPE:=single} |
85 |
|
86 |
# @ECLASS-VARIABLE: EGIT3_STORE_DIR |
87 |
@@ -129,7 +135,7 @@ |
88 |
|
89 |
# check the clone type |
90 |
case "${EGIT_CLONE_TYPE}" in |
91 |
- mirror|single) |
92 |
+ mirror|single|shallow) |
93 |
;; |
94 |
*) |
95 |
die "Invalid EGIT_CLONE_TYPE=${EGIT_CLONE_TYPE}" |
96 |
@@ -249,10 +255,6 @@ |
97 |
fi |
98 |
|
99 |
addwrite "${EGIT3_STORE_DIR}" |
100 |
- if [[ -e ${GIT_DIR}/shallow ]]; then |
101 |
- einfo "${GIT_DIR} was a shallow clone, recreating..." |
102 |
- rm -r "${GIT_DIR}" || die |
103 |
- fi |
104 |
if [[ ! -d ${GIT_DIR} ]]; then |
105 |
mkdir "${GIT_DIR}" || die |
106 |
git init --bare || die |
107 |
@@ -428,7 +430,7 @@ |
108 |
# (we keep it in refs/git-r3 since otherwise --prune interferes) |
109 |
HEAD:refs/git-r3/HEAD |
110 |
) |
111 |
- else # single |
112 |
+ else # single or shallow |
113 |
local fetch_l fetch_r |
114 |
|
115 |
if [[ ${remote_ref} == HEAD ]]; then |
116 |
@@ -468,6 +470,18 @@ |
117 |
) |
118 |
fi |
119 |
|
120 |
+ if [[ ${EGIT_CLONE_TYPE} == shallow ]]; then |
121 |
+ # use '--depth 1' when fetching a new branch |
122 |
+ if [[ ! $(git rev-parse --quiet --verify "${fetch_r}") ]] |
123 |
+ then |
124 |
+ fetch_command+=( --depth 1 ) |
125 |
+ fi |
126 |
+ else # non-shallow mode |
127 |
+ if [[ -f ${GIT_DIR}/shallow ]]; then |
128 |
+ fetch_command+=( --unshallow ) |
129 |
+ fi |
130 |
+ fi |
131 |
+ |
132 |
set -- "${fetch_command[@]}" |
133 |
echo "${@}" >&2 |
134 |
if "${@}"; then |
135 |
@@ -477,7 +491,7 @@ |
136 |
"$(_git-r3_find_head refs/git-r3/HEAD \ |
137 |
< <(git show-ref --heads || die))" \ |
138 |
|| die "Unable to update HEAD" |
139 |
- else # single |
140 |
+ else # single or shallow |
141 |
if [[ ${fetch_l} == HEAD ]]; then |
142 |
# find out what branch we fetched as HEAD |
143 |
local head_branch=$(_git-r3_find_head \ |
144 |
@@ -620,6 +634,10 @@ |
145 |
|
146 |
# (no need to copy HEAD, we will set it via checkout) |
147 |
|
148 |
+ if [[ -f ${orig_repo}/shallow ]]; then |
149 |
+ cp "${orig_repo}"/shallow "${GIT_DIR}"/ || die |
150 |
+ fi |
151 |
+ |
152 |
set -- git checkout --quiet |
153 |
if [[ ${remote_ref} ]]; then |
154 |
set -- "${@}" "${remote_ref#refs/heads/}" |