| 1 | # Copyright 1999-2006 Gentoo Foundation |
1 | # Copyright 1999-2006 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/git.eclass,v 1.2 2006/12/30 17:17:05 ferdy Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/git.eclass,v 1.5 2007/04/10 11:42:29 vapier Exp $ |
| 4 | |
4 | |
| 5 | ## --------------------------------------------------------------------------- # |
5 | ## --------------------------------------------------------------------------- # |
| 6 | # subversion.eclass author: Akinori Hattori <hattya@gentoo.org> |
6 | # subversion.eclass author: Akinori Hattori <hattya@gentoo.org> |
| 7 | # modified for git by Donnie Berkholz <spyderous@gentoo.org> |
7 | # modified for git by Donnie Berkholz <spyderous@gentoo.org> |
| 8 | # improved by Fernando J. Pereda <ferdy@gentoo.org> |
8 | # improved by Fernando J. Pereda <ferdy@gentoo.org> |
| … | |
… | |
| 45 | # |
45 | # |
| 46 | EGIT_UPDATE_CMD="git fetch -f -u" |
46 | EGIT_UPDATE_CMD="git fetch -f -u" |
| 47 | |
47 | |
| 48 | ## -- EGIT_DIFFSTAT_CMD: Command to get diffstat output |
48 | ## -- EGIT_DIFFSTAT_CMD: Command to get diffstat output |
| 49 | # |
49 | # |
| 50 | EGIT_DIFFSTAT_CMD="PAGER=cat git diff --stat" |
50 | EGIT_DIFFSTAT_CMD="git diff --stat" |
| 51 | |
51 | |
| 52 | |
52 | |
| 53 | ## -- EGIT_OPTIONS: |
53 | ## -- EGIT_OPTIONS: |
| 54 | # |
54 | # |
| 55 | # the options passed to clone and fetch |
55 | # the options passed to clone and fetch |
| … | |
… | |
| 150 | local EGIT_CLONE_DIR |
150 | local EGIT_CLONE_DIR |
| 151 | |
151 | |
| 152 | # EGIT_REPO_URI is empty. |
152 | # EGIT_REPO_URI is empty. |
| 153 | [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty." |
153 | [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty." |
| 154 | |
154 | |
| 155 | # check for the protocol. |
155 | # check for the protocol or pull from a local repo. |
|
|
156 | if [[ -z ${EGIT_REPO_URI%%:*} ]] ; then |
| 156 | case ${EGIT_REPO_URI%%:*} in |
157 | case ${EGIT_REPO_URI%%:*} in |
| 157 | git*|http|https|rsync|ssh) |
158 | git*|http|https|rsync|ssh) |
| 158 | ;; |
159 | ;; |
| 159 | *) |
160 | *) |
| 160 | die "${EGIT}: fetch from "${EGIT_REPO_URI%:*}" is not yet implemented." |
161 | die "${EGIT}: fetch from "${EGIT_REPO_URI%:*}" is not yet implemented." |
| 161 | ;; |
162 | ;; |
| 162 | esac |
163 | esac |
|
|
164 | fi |
| 163 | |
165 | |
| 164 | if [[ ! -d ${EGIT_STORE_DIR} ]] ; then |
166 | if [[ ! -d ${EGIT_STORE_DIR} ]] ; then |
| 165 | debug-print "${FUNCNAME}: initial clone. creating git directory" |
167 | debug-print "${FUNCNAME}: initial clone. creating git directory" |
| 166 | addwrite / |
168 | addwrite / |
| 167 | mkdir -p "${EGIT_STORE_DIR}" \ |
169 | mkdir -p "${EGIT_STORE_DIR}" \ |
| … | |
… | |
| 202 | local oldsha1=$(git rev-parse ${EGIT_BRANCH}) |
204 | local oldsha1=$(git rev-parse ${EGIT_BRANCH}) |
| 203 | |
205 | |
| 204 | ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} origin ${EGIT_BRANCH}:${EGIT_BRANCH} \ |
206 | ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} origin ${EGIT_BRANCH}:${EGIT_BRANCH} \ |
| 205 | || die "${EGIT}: can't update from ${EGIT_REPO_URI}." |
207 | || die "${EGIT}: can't update from ${EGIT_REPO_URI}." |
| 206 | |
208 | |
|
|
209 | # piping through cat is needed to avoid a stupid Git feature |
| 207 | ${EGIT_DIFFSTAT_CMD} ${oldsha1}..${EGIT_BRANCH} |
210 | ${EGIT_DIFFSTAT_CMD} ${oldsha1}..${EGIT_BRANCH} | cat |
| 208 | fi |
211 | fi |
| 209 | |
212 | |
| 210 | einfo " local clone: ${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" |
213 | einfo " local clone: ${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" |
| 211 | |
214 | |
| 212 | if ${EGIT_REPACK} ; then |
215 | if ${EGIT_REPACK} ; then |
| … | |
… | |
| 225 | einfo " committish: ${EGIT_TREE}" |
228 | einfo " committish: ${EGIT_TREE}" |
| 226 | |
229 | |
| 227 | # export to the ${WORKDIR} |
230 | # export to the ${WORKDIR} |
| 228 | mkdir -p "${S}" |
231 | mkdir -p "${S}" |
| 229 | git tar-tree ${EGIT_TREE} | ( cd "${S}" ; tar xf - ) |
232 | git tar-tree ${EGIT_TREE} | ( cd "${S}" ; tar xf - ) |
| 230 | echo |
233 | |
|
|
234 | echo ">>> Unpacked to ${S}" |
| 231 | |
235 | |
| 232 | } |
236 | } |
| 233 | |
237 | |
| 234 | |
238 | |
| 235 | ## -- git_bootstrap() ------------------------------------------------ # |
239 | ## -- git_bootstrap() ------------------------------------------------ # |