1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

makepkg: git: update existing sources in srcdir without removing them first.

The local changes are discarded when updating. This matches the behaviour
when non-VCS sources are used. It also allows incremental builds.

Signed-off-by: Lukáš Jirkovský <l.jirkovsky@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Lukáš Jirkovský 2013-12-09 21:31:23 +01:00 committed by Allan McRae
parent ecf0e37fc5
commit f6b3c9d803

View File

@ -580,9 +580,18 @@ extract_git() {
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
pushd "$srcdir" &>/dev/null
rm -rf "${dir##*/}"
if ! git clone "$dir"; then
local updating=0
if [[ -d "${dir##*/}" ]]; then
updating=1
cd_safe "${dir##*/}"
if ! git fetch; then
error "$(gettext "Failure while updating working copy of %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
exit 1
fi
cd_safe "$srcdir"
elif ! git clone "$dir"; then
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
exit 1
@ -590,7 +599,7 @@ extract_git() {
cd_safe "${dir##*/}"
local ref
local ref=origin/HEAD
if [[ -n $fragment ]]; then
case ${fragment%%=*} in
commit|tag)
@ -606,8 +615,8 @@ extract_git() {
esac
fi
if [[ -n $ref ]]; then
if ! git checkout -b makepkg $ref; then
if [[ $ref != "origin/HEAD" ]] || (( updating )) ; then
if ! git checkout --force --no-track -B makepkg $ref; then
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
exit 1