From f6b3c9d8038085a9b8ac2151a0ca3dafd637d3e2 Mon Sep 17 00:00:00 2001 From: Lukáš Jirkovský Date: Mon, 9 Dec 2013 21:31:23 +0100 Subject: makepkg: git: update existing sources in srcdir without removing them first. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ý Signed-off-by: Allan McRae --- 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 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 -- cgit v1.2.3-70-g09d2