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ý <[email protected]>
---
 scripts/makepkg.sh.in | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 1421bec..99af551 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -581,9 +581,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=false
+       if [[ -d "${dir##*/}" ]]; then
+               updating=true
+               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
@@ -591,7 +600,7 @@ extract_git() {
 
        cd_safe "${dir##*/}"
 
-       local ref
+       local ref=origin/HEAD
        if [[ -n $fragment ]]; then
                case ${fragment%%=*} in
                        commit|tag)
@@ -607,8 +616,8 @@ extract_git() {
                esac
        fi
 
-       if [[ -n $ref ]]; then
-               if ! git checkout -b makepkg $ref; then
+       if [[ -n $ref ]] || ((updating)) ; then
+               if ! git checkout --force -B makepkg $ref; then
                        error "$(gettext "Failure while creating working copy 
of %s %s repo")" "${repo}" "git"
                        plain "$(gettext "Aborting...")"
                        exit 1
-- 
1.8.5.1


Reply via email to