I think I found a bug: If the repository URL/source array entry has changed but the directory name has not, the user would have to manually delete the cloned repository, otherwise the git fetch/checkout would be from the incorrect upstream repo.
On Mon, Dec 9, 2013 at 3:31 PM, Lukáš Jirkovský <[email protected]>wrote: > 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 > > >
