/[gentoo-x86]/eclass/git-2.eclass
Gentoo

Diff of /eclass/git-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.13 Revision 1.26
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 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-2.eclass,v 1.13 2011/07/30 15:10:34 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/git-2.eclass,v 1.26 2011/09/23 14:10:47 mgorny Exp $
4 4
5# @ECLASS: git-2.eclass 5# @ECLASS: git-2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Donnie Berkholz <dberkholz@gentoo.org> 7# Donnie Berkholz <dberkholz@gentoo.org>
8# Michał Górny <mgorny@gentoo.org>
8# @BLURB: Eclass for fetching and unpacking git repositories. 9# @BLURB: Eclass for fetching and unpacking git repositories.
9# @DESCRIPTION: 10# @DESCRIPTION:
10# Eclass for easing maitenance of live ebuilds using git as remote repository. 11# Eclass for easing maitenance of live ebuilds using git as remote repository.
11# Eclass support working with git submodules and branching. 12# Eclass support working with git submodules and branching.
12 13
118# @DESCRIPTION: 119# @DESCRIPTION:
119# If non-empty this variable bans unpacking of ${A} content into the srcdir. 120# If non-empty this variable bans unpacking of ${A} content into the srcdir.
120# Default behaviour is to unpack ${A} content. 121# Default behaviour is to unpack ${A} content.
121 122
122# @FUNCTION: git-2_init_variables 123# @FUNCTION: git-2_init_variables
124# @INTERNAL
123# @DESCRIPTION: 125# @DESCRIPTION:
124# Internal function initializing all git variables. 126# Internal function initializing all git variables.
125# We define it in function scope so user can define 127# We define it in function scope so user can define
126# all the variables before and after inherit. 128# all the variables before and after inherit.
127git-2_init_variables() { 129git-2_init_variables() {
128 debug-print-function ${FUNCNAME} "$@" 130 debug-print-function ${FUNCNAME} "$@"
129 131
130 local x 132 local esc_pn liverepo livebranch livecommit
133 esc_pn=${PN//[-+]/_}
131 134
132 : ${EGIT_SOURCEDIR="${S}"} 135 : ${EGIT_SOURCEDIR="${S}"}
133 136
134 : ${EGIT_STORE_DIR:="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/egit-src"} 137 : ${EGIT_STORE_DIR:="${PORTAGE_ACTUAL_DISTDIR-${DISTDIR}}/egit-src"}
135 138
137 140
138 : ${EGIT_OPTIONS:=} 141 : ${EGIT_OPTIONS:=}
139 142
140 : ${EGIT_MASTER:=master} 143 : ${EGIT_MASTER:=master}
141 144
142 eval x="\$${PN//[-+]/_}_LIVE_REPO" 145 liverepo=${esc_pn}_LIVE_REPO
143 EGIT_REPO_URI=${x:-${EGIT_REPO_URI}} 146 EGIT_REPO_URI=${!liverepo:-${EGIT_REPO_URI}}
144 [[ -z ${EGIT_REPO_URI} ]] && die "EGIT_REPO_URI must have some value" 147 [[ ${EGIT_REPO_URI} ]] || die "EGIT_REPO_URI must have some value"
145 148
146 : ${EVCS_OFFLINE:=} 149 : ${EVCS_OFFLINE:=}
147 150
148 eval x="\$${PN//[-+]/_}_LIVE_BRANCH" 151 livebranch=${esc_pn}_LIVE_BRANCH
149 [[ -n ${x} ]] && ewarn "QA: using \"${PN//[-+]/_}_LIVE_BRANCH\" variable, you won't get any support" 152 [[ ${!livebranch} ]] && ewarn "QA: using \"${esc_pn}_LIVE_BRANCH\" variable, you won't get any support"
150 EGIT_BRANCH=${x:-${EGIT_BRANCH:-${EGIT_MASTER}}} 153 EGIT_BRANCH=${!livebranch:-${EGIT_BRANCH:-${EGIT_MASTER}}}
151 154
152 eval x="\$${PN//[-+]/_}_LIVE_COMMIT" 155 livecommit=${esc_pn}_LIVE_COMMIT
153 [[ -n ${x} ]] && ewarn "QA: using \"${PN//[-+]/_}_LIVE_COMMIT\" variable, you won't get any support" 156 [[ ${!livecommit} ]] && ewarn "QA: using \"${esc_pn}_LIVE_COMMIT\" variable, you won't get any support"
154 EGIT_COMMIT=${x:-${EGIT_COMMIT:-${EGIT_BRANCH}}} 157 EGIT_COMMIT=${!livecommit:-${EGIT_COMMIT:-${EGIT_BRANCH}}}
155 158
156 : ${EGIT_REPACK:=} 159 : ${EGIT_REPACK:=}
157 160
158 : ${EGIT_PRUNE:=} 161 : ${EGIT_PRUNE:=}
159} 162}
160 163
161# @FUNCTION: git-2_submodules 164# @FUNCTION: git-2_submodules
165# @INTERNAL
162# @DESCRIPTION: 166# @DESCRIPTION:
163# Internal function wrapping the submodule initialisation and update. 167# Internal function wrapping the submodule initialisation and update.
164git-2_submodules() { 168git-2_submodules() {
165 debug-print-function ${FUNCNAME} "$@" 169 debug-print-function ${FUNCNAME} "$@"
166 if [[ -n ${EGIT_HAS_SUBMODULES} ]]; then 170 if [[ ${EGIT_HAS_SUBMODULES} ]]; then
167 if [[ -n ${EVCS_OFFLINE} ]]; then 171 if [[ ${EVCS_OFFLINE} ]]; then
168 # for submodules operations we need to be online 172 # for submodules operations we need to be online
169 debug-print "${FUNCNAME}: not updating submodules in offline mode" 173 debug-print "${FUNCNAME}: not updating submodules in offline mode"
170 return 1 174 return 1
171 fi 175 fi
172 176
183 popd > /dev/null 187 popd > /dev/null
184 fi 188 fi
185} 189}
186 190
187# @FUNCTION: git-2_branch 191# @FUNCTION: git-2_branch
192# @INTERNAL
188# @DESCRIPTION: 193# @DESCRIPTION:
189# Internal function that changes branch for the repo based on EGIT_COMMIT and 194# Internal function that changes branch for the repo based on EGIT_COMMIT and
190# EGIT_BRANCH variables. 195# EGIT_BRANCH variables.
191git-2_branch() { 196git-2_branch() {
192 debug-print-function ${FUNCNAME} "$@" 197 debug-print-function ${FUNCNAME} "$@"
207 212
208 popd > /dev/null 213 popd > /dev/null
209} 214}
210 215
211# @FUNCTION: git-2_gc 216# @FUNCTION: git-2_gc
217# @INTERNAL
212# @DESCRIPTION: 218# @DESCRIPTION:
213# Internal function running garbage collector on checked out tree. 219# Internal function running garbage collector on checked out tree.
214git-2_gc() { 220git-2_gc() {
215 debug-print-function ${FUNCNAME} "$@" 221 debug-print-function ${FUNCNAME} "$@"
216 222
217 local args 223 local args
218 224
225 if [[ ${EGIT_REPACK} || ${EGIT_PRUNE} ]]; then
219 pushd "${EGIT_DIR}" > /dev/null 226 pushd "${EGIT_DIR}" > /dev/null
220 if [[ -n ${EGIT_REPACK} || -n ${EGIT_PRUNE} ]]; then
221 ebegin "Garbage collecting the repository" 227 ebegin "Garbage collecting the repository"
222 [[ -n ${EGIT_PRUNE} ]] && args='--prune' 228 [[ ${EGIT_PRUNE} ]] && args='--prune'
223 debug-print "${FUNCNAME}: git gc ${args}" 229 debug-print "${FUNCNAME}: git gc ${args}"
224 git gc ${args} 230 git gc ${args}
225 eend $? 231 eend $?
226 fi
227 popd > /dev/null 232 popd > /dev/null
233 fi
228} 234}
229 235
230# @FUNCTION: git-2_prepare_storedir 236# @FUNCTION: git-2_prepare_storedir
237# @INTERNAL
231# @DESCRIPTION: 238# @DESCRIPTION:
232# Internal function preparing directory where we are going to store SCM 239# Internal function preparing directory where we are going to store SCM
233# repository. 240# repository.
234git-2_prepare_storedir() { 241git-2_prepare_storedir() {
235 debug-print-function ${FUNCNAME} "$@" 242 debug-print-function ${FUNCNAME} "$@"
245 || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\"" 252 || die "${FUNCNAME}: can't mkdir \"${EGIT_STORE_DIR}\""
246 fi 253 fi
247 254
248 # allow writing into EGIT_STORE_DIR 255 # allow writing into EGIT_STORE_DIR
249 addwrite "${EGIT_STORE_DIR}" 256 addwrite "${EGIT_STORE_DIR}"
257
258 # calculate git.eclass store dir for data
259 # We will try to clone the old repository,
260 # and we will remove it if we don't need it anymore.
261 EGIT_OLD_CLONE=
262 if [[ ${EGIT_STORE_DIR} == */egit-src ]]; then
263 local old_store_dir=${EGIT_STORE_DIR/%egit-src/git-src}
264 local old_location=${old_store_dir}/${EGIT_PROJECT:-${PN}}
265
266 if [[ -d ${old_location} ]]; then
267 EGIT_OLD_CLONE=${old_location}
268 # required to remove the old clone
269 addwrite "${old_store_dir}"
270 fi
271 fi
272
250 # calculate the proper store dir for data 273 # calculate the proper store dir for data
251 # If user didn't specify the EGIT_DIR, we check if he did specify 274 # If user didn't specify the EGIT_DIR, we check if he did specify
252 # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI. 275 # the EGIT_PROJECT or get the folder name from EGIT_REPO_URI.
253 [[ -z ${EGIT_REPO_URI##*/} ]] && EGIT_REPO_URI="${EGIT_REPO_URI%/}" 276 EGIT_REPO_URI=${EGIT_REPO_URI%/}
254 if [[ -z ${EGIT_DIR} ]]; then 277 if [[ ! ${EGIT_DIR} ]]; then
255 if [[ -n ${EGIT_PROJECT} ]]; then 278 if [[ ${EGIT_PROJECT} ]]; then
256 clone_dir=${EGIT_PROJECT} 279 clone_dir=${EGIT_PROJECT}
257 else 280 else
258 clone_dir=${EGIT_REPO_URI##*/} 281 clone_dir=${EGIT_REPO_URI##*/}
259 fi 282 fi
260 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir} 283 EGIT_DIR=${EGIT_STORE_DIR}/${clone_dir}
284
285 if [[ ${EGIT_OLD_CLONE} && ! -d ${EGIT_DIR} ]]; then
286 elog "${FUNCNAME}: ${CATEGORY}/${PF} will be cloned from old location."
287 elog "It will be necessary to rebuild the package to fetch updates."
288 EGIT_REPO_URI="${EGIT_OLD_CLONE} ${EGIT_REPO_URI}"
289 fi
261 fi 290 fi
262 export EGIT_DIR=${EGIT_DIR} 291 export EGIT_DIR=${EGIT_DIR}
263 debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"." 292 debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
264} 293}
265 294
266# @FUNCTION: git-2_move_source 295# @FUNCTION: git-2_move_source
296# @INTERNAL
267# @DESCRIPTION: 297# @DESCRIPTION:
268# Internal function moving sources from the EGIT_DIR to EGIT_SOURCEDIR dir. 298# Internal function moving sources from the EGIT_DIR to EGIT_SOURCEDIR dir.
269git-2_move_source() { 299git-2_move_source() {
270 debug-print-function ${FUNCNAME} "$@" 300 debug-print-function ${FUNCNAME} "$@"
271 301
277 || die "${FUNCNAME}: sync to \"${EGIT_SOURCEDIR}\" failed" 307 || die "${FUNCNAME}: sync to \"${EGIT_SOURCEDIR}\" failed"
278 popd > /dev/null 308 popd > /dev/null
279} 309}
280 310
281# @FUNCTION: git-2_initial_clone 311# @FUNCTION: git-2_initial_clone
312# @INTERNAL
282# @DESCRIPTION: 313# @DESCRIPTION:
283# Internal function running initial clone on specified repo_uri. 314# Internal function running initial clone on specified repo_uri.
284git-2_initial_clone() { 315git-2_initial_clone() {
285 debug-print-function ${FUNCNAME} "$@" 316 debug-print-function ${FUNCNAME} "$@"
286 317
287 local repo_uri 318 local repo_uri
288 319
289 EGIT_REPO_URI_SELECTED="" 320 EGIT_REPO_URI_SELECTED=""
290 for repo_uri in ${EGIT_REPO_URI}; do 321 for repo_uri in ${EGIT_REPO_URI}; do
291 debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\"" 322 debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\""
292 git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}" 323 if git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}"; then
293 if [[ $? -eq 0 ]]; then
294 # global variable containing the repo_name we will be using 324 # global variable containing the repo_name we will be using
295 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\"" 325 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
296 EGIT_REPO_URI_SELECTED="${repo_uri}" 326 EGIT_REPO_URI_SELECTED="${repo_uri}"
297 break 327 break
298 fi 328 fi
299 done 329 done
300 330
301 if [[ -z ${EGIT_REPO_URI_SELECTED} ]]; then 331 [[ ${EGIT_REPO_URI_SELECTED} ]] \
302 die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}" 332 || die "${FUNCNAME}: can't fetch from ${EGIT_REPO_URI}"
303 fi
304} 333}
305 334
306# @FUNCTION: git-2_update_repo 335# @FUNCTION: git-2_update_repo
336# @INTERNAL
307# @DESCRIPTION: 337# @DESCRIPTION:
308# Internal function running update command on specified repo_uri. 338# Internal function running update command on specified repo_uri.
309git-2_update_repo() { 339git-2_update_repo() {
310 debug-print-function ${FUNCNAME} "$@" 340 debug-print-function ${FUNCNAME} "$@"
311 341
312 local repo_uri 342 local repo_uri
313 343
314 if [[ -n ${EGIT_LOCAL_NONBARE} ]]; then 344 if [[ ${EGIT_LOCAL_NONBARE} ]]; then
315 # checkout master branch and drop all other local branches 345 # checkout master branch and drop all other local branches
316 git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}" 346 git checkout ${EGIT_MASTER} || die "${FUNCNAME}: can't checkout master branch ${EGIT_MASTER}"
317 for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do 347 for x in $(git branch | grep -v "* ${EGIT_MASTER}" | tr '\n' ' '); do
318 debug-print "${FUNCNAME}: git branch -D ${x}" 348 debug-print "${FUNCNAME}: git branch -D ${x}"
319 git branch -D ${x} > /dev/null 349 git branch -D ${x} > /dev/null
324 for repo_uri in ${EGIT_REPO_URI}; do 354 for repo_uri in ${EGIT_REPO_URI}; do
325 # git urls might change, so reset it 355 # git urls might change, so reset it
326 git config remote.origin.url "${repo_uri}" 356 git config remote.origin.url "${repo_uri}"
327 357
328 debug-print "${EGIT_UPDATE_CMD}" 358 debug-print "${EGIT_UPDATE_CMD}"
329 ${EGIT_UPDATE_CMD} > /dev/null 359 if ${EGIT_UPDATE_CMD} > /dev/null; then
330 if [[ $? -eq 0 ]]; then
331 # global variable containing the repo_name we will be using 360 # global variable containing the repo_name we will be using
332 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\"" 361 debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
333 EGIT_REPO_URI_SELECTED="${repo_uri}" 362 EGIT_REPO_URI_SELECTED="${repo_uri}"
334 break 363 break
335 fi 364 fi
336 done 365 done
337 366
338 if [[ -z ${EGIT_REPO_URI_SELECTED} ]]; then 367 [[ ${EGIT_REPO_URI_SELECTED} ]] \
339 die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}" 368 || die "${FUNCNAME}: can't update from ${EGIT_REPO_URI}"
340 fi
341} 369}
342 370
343# @FUNCTION: git-2_fetch 371# @FUNCTION: git-2_fetch
372# @INTERNAL
344# @DESCRIPTION: 373# @DESCRIPTION:
345# Internal function fetching repository from EGIT_REPO_URI and storing it in 374# Internal function fetching repository from EGIT_REPO_URI and storing it in
346# specified EGIT_STORE_DIR. 375# specified EGIT_STORE_DIR.
347git-2_fetch() { 376git-2_fetch() {
348 debug-print-function ${FUNCNAME} "$@" 377 debug-print-function ${FUNCNAME} "$@"
349 378
350 local oldsha cursha repo_type 379 local oldsha cursha repo_type
351 380
352 [[ -n ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository" 381 [[ ${EGIT_LOCAL_NONBARE} ]] && repo_type="non-bare repository" || repo_type="bare repository"
353 382
354 if [[ ! -d ${EGIT_DIR} ]]; then 383 if [[ ! -d ${EGIT_DIR} ]]; then
355 git-2_initial_clone 384 git-2_initial_clone
356 pushd "${EGIT_DIR}" > /dev/null 385 pushd "${EGIT_DIR}" > /dev/null
357 cursha=$(git rev-parse ${UPSTREAM_BRANCH}) 386 cursha=$(git rev-parse ${UPSTREAM_BRANCH})
358 echo "GIT NEW clone -->" 387 echo "GIT NEW clone -->"
359 echo " repository: ${EGIT_REPO_URI_SELECTED}" 388 echo " repository: ${EGIT_REPO_URI_SELECTED}"
360 echo " at the commit: ${cursha}" 389 echo " at the commit: ${cursha}"
361 390
362 popd > /dev/null 391 popd > /dev/null
363 elif [[ -n ${EVCS_OFFLINE} ]]; then 392 elif [[ ${EVCS_OFFLINE} ]]; then
364 pushd "${EGIT_DIR}" > /dev/null 393 pushd "${EGIT_DIR}" > /dev/null
365 cursha=$(git rev-parse ${UPSTREAM_BRANCH}) 394 cursha=$(git rev-parse ${UPSTREAM_BRANCH})
366 echo "GIT offline update -->" 395 echo "GIT offline update -->"
367 echo " repository: $(git config remote.origin.url)" 396 echo " repository: $(git config remote.origin.url)"
368 echo " at the commit: ${cursha}" 397 echo " at the commit: ${cursha}"
394 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \ 423 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] \
395 && echo " commit: ${EGIT_COMMIT}" 424 && echo " commit: ${EGIT_COMMIT}"
396 echo " branch: ${EGIT_BRANCH}" 425 echo " branch: ${EGIT_BRANCH}"
397 echo " storage directory: \"${EGIT_DIR}\"" 426 echo " storage directory: \"${EGIT_DIR}\""
398 echo " checkout type: ${repo_type}" 427 echo " checkout type: ${repo_type}"
428
429 # Cleanup after git.eclass
430 if [[ ${EGIT_OLD_CLONE} ]]; then
431 einfo "${FUNCNAME}: removing old clone in ${EGIT_OLD_CLONE}."
432 rm -rf "${EGIT_OLD_CLONE}"
433 fi
399} 434}
400 435
401# @FUNCTION: git_bootstrap 436# @FUNCTION: git_bootstrap
437# @INTERNAL
402# @DESCRIPTION: 438# @DESCRIPTION:
403# Internal function that runs bootstrap command on unpacked source. 439# Internal function that runs bootstrap command on unpacked source.
404git-2_bootstrap() { 440git-2_bootstrap() {
405 debug-print-function ${FUNCNAME} "$@" 441 debug-print-function ${FUNCNAME} "$@"
406 442
407 # @ECLASS_VARIABLE: EGIT_BOOTSTRAP 443 # @ECLASS-VARIABLE: EGIT_BOOTSTRAP
408 # @DESCRIPTION: 444 # @DESCRIPTION:
409 # Command to be executed after checkout and clone of the specified 445 # Command to be executed after checkout and clone of the specified
410 # repository. 446 # repository.
411 # enviroment the package will fail if there is no update, thus in 447 # enviroment the package will fail if there is no update, thus in
412 # combination with --keep-going it would lead in not-updating 448 # combination with --keep-going it would lead in not-updating
413 # pakcages that are up-to-date. 449 # pakcages that are up-to-date.
414 if [[ -n ${EGIT_BOOTSTRAP} ]]; then 450 if [[ ${EGIT_BOOTSTRAP} ]]; then
415 pushd "${EGIT_SOURCEDIR}" > /dev/null 451 pushd "${EGIT_SOURCEDIR}" > /dev/null
416 einfo "Starting bootstrap" 452 einfo "Starting bootstrap"
417 453
418 if [[ -f ${EGIT_BOOTSTRAP} ]]; then 454 if [[ -f ${EGIT_BOOTSTRAP} ]]; then
419 # we have file in the repo which we should execute 455 # we have file in the repo which we should execute
439 popd > /dev/null 475 popd > /dev/null
440 fi 476 fi
441} 477}
442 478
443# @FUNCTION: git-2_migrate_repository 479# @FUNCTION: git-2_migrate_repository
480# @INTERNAL
444# @DESCRIPTION: 481# @DESCRIPTION:
445# Internal function migrating between bare and normal checkout repository. 482# Internal function migrating between bare and normal checkout repository.
446# This is based on usage of EGIT_SUBMODULES, at least until they 483# This is based on usage of EGIT_SUBMODULES, at least until they
447# start to work with bare checkouts sanely. 484# start to work with bare checkouts sanely.
448# This function also set some global variables that differ between 485# This function also set some global variables that differ between
449# bare and non-bare checkout. 486# bare and non-bare checkout.
450git-2_migrate_repository() { 487git-2_migrate_repository() {
451 debug-print-function ${FUNCNAME} "$@" 488 debug-print-function ${FUNCNAME} "$@"
452 489
453 local target returnstate 490 local bare returnstate
454 491
455 # first find out if we have submodules 492 # first find out if we have submodules
493 # or user explicitly wants us to use non-bare clones
456 if [[ -z ${EGIT_HAS_SUBMODULES} ]]; then 494 if ! [[ ${EGIT_HAS_SUBMODULES} || ${EGIT_NONBARE} ]]; then
457 target="bare" 495 bare=1
458 else
459 target="full"
460 fi
461 # check if user didn't specify that we want non-bare repo
462 if [[ -n ${EGIT_NONBARE} ]]; then
463 target="full"
464 EGIT_LOCAL_NONBARE="true"
465 fi 496 fi
466 497
467 # test if we already have some repo and if so find out if we have 498 # test if we already have some repo and if so find out if we have
468 # to migrate the data 499 # to migrate the data
469 if [[ -d ${EGIT_DIR} ]]; then 500 if [[ -d ${EGIT_DIR} ]]; then
470 if [[ ${target} == bare && -d ${EGIT_DIR}/.git ]]; then 501 if [[ ${bare} && -d ${EGIT_DIR}/.git ]]; then
471 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy" 502 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to bare copy"
472 503
473 ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy" 504 ebegin "Converting \"${EGIT_DIR}\" from non-bare to bare copy"
474 mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare" 505 mv "${EGIT_DIR}/.git" "${EGIT_DIR}.bare"
475 export GIT_DIR="${EGIT_DIR}.bare" 506 export GIT_DIR="${EGIT_DIR}.bare"
477 returnstate=$? 508 returnstate=$?
478 unset GIT_DIR 509 unset GIT_DIR
479 rm -rf "${EGIT_DIR}" 510 rm -rf "${EGIT_DIR}"
480 mv "${EGIT_DIR}.bare" "${EGIT_DIR}" 511 mv "${EGIT_DIR}.bare" "${EGIT_DIR}"
481 eend ${returnstate} 512 eend ${returnstate}
482 fi
483 if [[ ${target} == full && ! -d ${EGIT_DIR}/.git ]]; then 513 elif [[ ! ${bare} && ! -d ${EGIT_DIR}/.git ]]; then
484 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy" 514 debug-print "${FUNCNAME}: converting \"${EGIT_DIR}\" to non-bare copy"
485 515
486 ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy" 516 ebegin "Converting \"${EGIT_DIR}\" from bare to non-bare copy"
487 git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null 517 git clone -l "${EGIT_DIR}" "${EGIT_DIR}.nonbare" > /dev/null
488 returnstate=$? 518 returnstate=$?
498 einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch." 528 einfo "Migration failed, removing \"${EGIT_DIR}\" to start from scratch."
499 rm -rf "${EGIT_DIR}" 529 rm -rf "${EGIT_DIR}"
500 fi 530 fi
501 531
502 # set various options to work with both targets 532 # set various options to work with both targets
503 if [[ ${target} == bare ]]; then 533 if [[ ${bare} ]]; then
504 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\"" 534 debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
505 EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare" 535 EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
506 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }" 536 MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
507 EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}" 537 EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
508 UPSTREAM_BRANCH="${EGIT_BRANCH}" 538 UPSTREAM_BRANCH="${EGIT_BRANCH}"
539 EGIT_LOCAL_NONBARE=
509 else 540 else
510 debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\"" 541 debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\""
511 MOVE_COMMAND="cp -pPR ." 542 MOVE_COMMAND="cp -pPR ."
512 EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}" 543 EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}"
513 EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}" 544 EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}"
515 EGIT_LOCAL_NONBARE="true" 546 EGIT_LOCAL_NONBARE="true"
516 fi 547 fi
517} 548}
518 549
519# @FUNCTION: git-2_cleanup 550# @FUNCTION: git-2_cleanup
551# @INTERNAL
520# @DESCRIPTION: 552# @DESCRIPTION:
521# Internal function cleaning up all the global variables 553# Internal function cleaning up all the global variables
522# that are not required after the unpack has been done. 554# that are not required after the unpack has been done.
523git-2_cleanup() { 555git-2_cleanup() {
524 debug-print-function ${FUNCNAME} "$@" 556 debug-print-function ${FUNCNAME} "$@"
554 git-2_cleanup 586 git-2_cleanup
555 echo ">>> Unpacked to ${EGIT_SOURCEDIR}" 587 echo ">>> Unpacked to ${EGIT_SOURCEDIR}"
556 588
557 # Users can specify some SRC_URI and we should 589 # Users can specify some SRC_URI and we should
558 # unpack the files too. 590 # unpack the files too.
559 if [[ -z ${EGIT_NOUNPACK} ]]; then 591 if [[ ! ${EGIT_NOUNPACK} ]]; then
560 if has ${EAPI:-0} 0 1; then 592 if has ${EAPI:-0} 0 1; then
561 [[ -n ${A} ]] && unpack ${A} 593 [[ ${A} ]] && unpack ${A}
562 else 594 else
563 default_src_unpack 595 default_src_unpack
564 fi 596 fi
565 fi 597 fi
566} 598}

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.20