Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 455048
Collapse All | Expand All

(-)file_not_specified_in_diff (-57 / +31 lines)
Line  Link Here
0
-- git-2.eclass
0
++ git-2.eclass
Lines 32-39 Link Here
32
# @ECLASS-VARIABLE: EGIT_HAS_SUBMODULES
32
# @ECLASS-VARIABLE: EGIT_HAS_SUBMODULES
33
# @DEFAULT_UNSET
33
# @DEFAULT_UNSET
34
# @DESCRIPTION:
34
# @DESCRIPTION:
35
# If non-empty this variable enables support for git submodules in our
35
# If non-empty this variable enables support for git submodules in our clone.
36
# checkout. Also this makes the checkout to be non-bare for now.
37
36
38
# @ECLASS-VARIABLE: EGIT_OPTIONS
37
# @ECLASS-VARIABLE: EGIT_OPTIONS
39
# @DEFAULT_UNSET
38
# @DEFAULT_UNSET
Lines 113-121 Link Here
113
# @ECLASS-VARIABLE: EGIT_NONBARE
112
# @ECLASS-VARIABLE: EGIT_NONBARE
114
# @DEFAULT_UNSET
113
# @DEFAULT_UNSET
115
# @DESCRIPTION:
114
# @DESCRIPTION:
116
# If non-empty this variable specifies that all checkouts will be done using
115
# If non-empty this variable specifies that all clones will be done using
117
# non bare repositories. This is useful if you can't operate with bare
116
# non bare repositories. This is useful if you can't operate with bare clones
118
# checkouts for some reason.
117
# for some reason.
119
118
120
# @ECLASS-VARIABLE: EGIT_NOUNPACK
119
# @ECLASS-VARIABLE: EGIT_NOUNPACK
121
# @DEFAULT_UNSET
120
# @DEFAULT_UNSET
Lines 178-221 Link Here
178
		fi
177
		fi
179
178
180
		debug-print "${FUNCNAME}: working in \"${1}\""
179
		debug-print "${FUNCNAME}: working in \"${1}\""
181
		pushd "${EGIT_DIR}" > /dev/null
180
		pushd "${EGIT_SOURCEDIR}" > /dev/null
182
181
183
		debug-print "${FUNCNAME}: git submodule init"
182
		debug-print "${FUNCNAME}: git submodule init"
184
		git submodule init || die
183
		git --git-dir="${EGIT_DIR}" --work-tree=. \
184
			submodule init || die
185
		debug-print "${FUNCNAME}: git submodule sync"
185
		debug-print "${FUNCNAME}: git submodule sync"
186
		git submodule sync || die
186
		git --git-dir="${EGIT_DIR}" --work-tree=. \
187
			submodule sync || die
187
		debug-print "${FUNCNAME}: git submodule update"
188
		debug-print "${FUNCNAME}: git submodule update"
188
		git submodule update || die
189
		git --git-dir="${EGIT_DIR}" --work-tree=. \
190
			submodule update || die
189
191
190
		popd > /dev/null
192
		popd > /dev/null
191
	fi
193
	fi
192
}
194
}
193
195
194
# @FUNCTION: git-2_branch
195
# @INTERNAL
196
# @DESCRIPTION:
197
# Internal function that changes branch for the repo based on EGIT_COMMIT and
198
# EGIT_BRANCH variables.
199
git-2_branch() {
200
	debug-print-function ${FUNCNAME} "$@"
201
202
	local branchname src
203
204
	debug-print "${FUNCNAME}: working in \"${EGIT_SOURCEDIR}\""
205
	pushd "${EGIT_SOURCEDIR}" > /dev/null
206
207
	local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH}
208
	if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then
209
		branchname=tree-${EGIT_COMMIT}
210
		src=${EGIT_COMMIT}
211
	fi
212
	debug-print "${FUNCNAME}: git checkout -b ${branchname} ${src}"
213
	git checkout -b ${branchname} ${src} \
214
		|| die "${FUNCNAME}: changing the branch failed"
215
216
	popd > /dev/null
217
}
218
219
# @FUNCTION: git-2_gc
196
# @FUNCTION: git-2_gc
220
# @INTERNAL
197
# @INTERNAL
221
# @DESCRIPTION:
198
# @DESCRIPTION:
Lines 296-315 Link Here
296
	debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
273
	debug-print "${FUNCNAME}: Storing the repo into \"${EGIT_DIR}\"."
297
}
274
}
298
275
299
# @FUNCTION: git-2_move_source
276
# @FUNCTION: git-2_checkout
300
# @INTERNAL
277
# @INTERNAL
301
# @DESCRIPTION:
278
# @DESCRIPTION:
302
# Internal function moving sources from the EGIT_DIR to EGIT_SOURCEDIR dir.
279
# Internal function checking out sources from the EGIT_DIR to EGIT_SOURCEDIR.
303
git-2_move_source() {
280
git-2_checkout() {
304
	debug-print-function ${FUNCNAME} "$@"
281
	debug-print-function ${FUNCNAME} "$@"
305
282
306
	debug-print "${FUNCNAME}: ${MOVE_COMMAND} \"${EGIT_DIR}\" \"${EGIT_SOURCEDIR}\""
283
	if ! [[ ${EGIT_LOCAL_NONBARE} ]]; then
307
	pushd "${EGIT_DIR}" > /dev/null
284
		mkdir -p "${EGIT_SOURCEDIR}" \
308
	mkdir -p "${EGIT_SOURCEDIR}" \
285
			|| die "${FUNCNAME}: failed to create ${EGIT_SOURCEDIR}"
309
		|| die "${FUNCNAME}: failed to create ${EGIT_SOURCEDIR}"
286
		git --git-dir="${EGIT_DIR}" --work-tree="${EGIT_SOURCEDIR}" \
310
	${MOVE_COMMAND} "${EGIT_SOURCEDIR}" \
287
		checkout -f "${EGIT_COMMIT}" \
311
		|| die "${FUNCNAME}: sync to \"${EGIT_SOURCEDIR}\" failed"
288
			|| die "${FUNCNAME}: checkout to \"${EGIT_SOURCEDIR}\" failed"
312
	popd > /dev/null
289
	else
290
		cp -pPR "${EGIT_DIR}" "${EGIT_SOURCEDIR}" \
291
			|| die "${FUNCNAME}: copy to \"${EGIT_SOURCEDIR}\" failed"
292
	fi
313
}
293
}
314
294
315
# @FUNCTION: git-2_initial_clone
295
# @FUNCTION: git-2_initial_clone
Lines 428-434 Link Here
428
		&& echo "   commit:                   ${EGIT_COMMIT}"
408
		&& echo "   commit:                   ${EGIT_COMMIT}"
429
	echo "   branch:                   ${EGIT_BRANCH}"
409
	echo "   branch:                   ${EGIT_BRANCH}"
430
	echo "   storage directory:        \"${EGIT_DIR}\""
410
	echo "   storage directory:        \"${EGIT_DIR}\""
431
	echo "   checkout type:            ${repo_type}"
411
	echo "   clone type:               ${repo_type}"
432
412
433
	# Cleanup after git.eclass
413
	# Cleanup after git.eclass
434
	if [[ ${EGIT_OLD_CLONE} ]]; then
414
	if [[ ${EGIT_OLD_CLONE} ]]; then
Lines 446-452 Link Here
446
426
447
	# @ECLASS-VARIABLE: EGIT_BOOTSTRAP
427
	# @ECLASS-VARIABLE: EGIT_BOOTSTRAP
448
	# @DESCRIPTION:
428
	# @DESCRIPTION:
449
	# Command to be executed after checkout and clone of the specified
429
	# Command to be executed after clone and checkout of the specified
450
	# repository.
430
	# repository.
451
	# enviroment the package will fail if there is no update, thus in
431
	# enviroment the package will fail if there is no update, thus in
452
	# combination with --keep-going it would lead in not-updating
432
	# combination with --keep-going it would lead in not-updating
Lines 483-493 Link Here
483
# @FUNCTION: git-2_migrate_repository
463
# @FUNCTION: git-2_migrate_repository
484
# @INTERNAL
464
# @INTERNAL
485
# @DESCRIPTION:
465
# @DESCRIPTION:
486
# Internal function migrating between bare and normal checkout repository.
466
# Internal function migrating between bare and nonbare clone repository.
487
# This is based on usage of EGIT_SUBMODULES, at least until they
488
# start to work with bare checkouts sanely.
489
# This function also set some global variables that differ between
467
# This function also set some global variables that differ between
490
# bare and non-bare checkout.
468
# bare and non-bare clone.
491
git-2_migrate_repository() {
469
git-2_migrate_repository() {
492
	debug-print-function ${FUNCNAME} "$@"
470
	debug-print-function ${FUNCNAME} "$@"
493
471
Lines 495-501 Link Here
495
473
496
	# first find out if we have submodules
474
	# first find out if we have submodules
497
	# or user explicitly wants us to use non-bare clones
475
	# or user explicitly wants us to use non-bare clones
498
	if ! [[ ${EGIT_HAS_SUBMODULES} || ${EGIT_NONBARE} ]]; then
476
	if ! [[ ${EGIT_NONBARE} ]]; then
499
		bare=1
477
		bare=1
500
	fi
478
	fi
501
479
Lines 537-549 Link Here
537
	if [[ ${bare} ]]; then
515
	if [[ ${bare} ]]; then
538
		debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
516
		debug-print "${FUNCNAME}: working in bare repository for \"${EGIT_DIR}\""
539
		EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
517
		EGIT_LOCAL_OPTIONS+="${EGIT_OPTIONS} --bare"
540
		MOVE_COMMAND="git clone -l -s -n ${EGIT_DIR// /\\ }"
541
		EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
518
		EGIT_UPDATE_CMD="git fetch -t -f -u origin ${EGIT_BRANCH}:${EGIT_BRANCH}"
542
		UPSTREAM_BRANCH="${EGIT_BRANCH}"
519
		UPSTREAM_BRANCH="${EGIT_BRANCH}"
543
		EGIT_LOCAL_NONBARE=
520
		EGIT_LOCAL_NONBARE=
544
	else
521
	else
545
		debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\""
522
		debug-print "${FUNCNAME}: working in bare repository for non-bare \"${EGIT_DIR}\""
546
		MOVE_COMMAND="cp -pPR ."
547
		EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}"
523
		EGIT_LOCAL_OPTIONS="${EGIT_OPTIONS}"
548
		EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}"
524
		EGIT_UPDATE_CMD="git pull -f -u ${EGIT_OPTIONS}"
549
		UPSTREAM_BRANCH="origin/${EGIT_BRANCH}"
525
		UPSTREAM_BRANCH="origin/${EGIT_BRANCH}"
Lines 565-571 Link Here
565
	# If ebuild writer polutes his environment it is
541
	# If ebuild writer polutes his environment it is
566
	# his problem only.
542
	# his problem only.
567
	unset EGIT_DIR
543
	unset EGIT_DIR
568
	unset MOVE_COMMAND
569
	unset EGIT_LOCAL_OPTIONS
544
	unset EGIT_LOCAL_OPTIONS
570
	unset EGIT_UPDATE_CMD
545
	unset EGIT_UPDATE_CMD
571
	unset UPSTREAM_BRANCH
546
	unset UPSTREAM_BRANCH
Lines 583-591 Link Here
583
	git-2_migrate_repository
558
	git-2_migrate_repository
584
	git-2_fetch "$@"
559
	git-2_fetch "$@"
585
	git-2_gc
560
	git-2_gc
561
	git-2_checkout
586
	git-2_submodules
562
	git-2_submodules
587
	git-2_move_source
588
	git-2_branch
589
	git-2_bootstrap
563
	git-2_bootstrap
590
	git-2_cleanup
564
	git-2_cleanup
591
	echo ">>> Unpacked to ${EGIT_SOURCEDIR}"
565
	echo ">>> Unpacked to ${EGIT_SOURCEDIR}"

Return to bug 455048