Sorry for top-posting in the previous message. See below. On Mon, Dec 9, 2013 at 3:31 PM, Lukáš Jirkovský <l.jirkovsky@gmail.com> 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ý <l.jirkovsky@gmail.com> --- 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
This checkout checks out whatever has been cloned, but the git remote (origin by default) may be pointing to the wrong URL/source array entry, since you simply reuse the same .git/config (since you didn't rm -rf and git clone again). Therefore, this will break any update that changes repository URLs, and require the user or AUR wrapper to manually go in and delete the checked out repository... If saving yourself the step of having to "git clone" again is your only goal, here are two possible ways to solve that problem: 1) Use the $GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable or .git/objects/info/alternates file mechanism, and use an object store that is detached from the git clone, e.g. in some generic directory (e.g. $startdir/gitobjects), and don't delete that directory. That way, git will not re-download the objects (actual data) that it already fetched, only update the refs and fill in the missing objects in the object store you specify. See https://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html for more info...) 2) Make sure to set the git remote each time when updating, using the appropriate "git remote" command. This has the downside that you are replicating "git clone" functionality. Your patches for Mercurial, SVN, etc. have a similar problem...
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" plain "$(gettext "Aborting...")" exit 1 -- 1.8.5.1