summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLukáš Jirkovský <l.jirkovsky@gmail.com>2013-12-09 21:31:23 +0100
committerAllan McRae <allan@archlinux.org>2014-11-09 16:09:27 +1000
commitf6b3c9d8038085a9b8ac2151a0ca3dafd637d3e2 (patch)
tree4c8ca3e10a36dab11a6a15b5751b5f10a45177d7 /scripts
parentecf0e37fc5b583c3694e6847e9f38edb8bae413a (diff)
downloadpacman-f6b3c9d8038085a9b8ac2151a0ca3dafd637d3e2.tar.xz
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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/makepkg.sh.in19
1 files changed, 14 insertions, 5 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index ec28bf32..f5e6227d 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -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