Re: [pacman-dev] [PATCH 4/4] makepkg: git: update existing sources in srcdir without removing them first.
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ý <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 error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git" plain "$(gettext "Aborting...")" exit 1 -- 1.8.5.1
On Mon, Dec 9, 2013 at 9:37 PM, Ido Rosen <ido@kernel.org> wrote:
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.
In theory this is a problem, but in practice it would fail in the current code in download_git before reaching this, because it has the same problem. Another question is how likely is that someone would try to pull an unrelated repository. I guess it must be quite unlikely, as noone have reported this as a bug.
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...
There's no need to change remote, because for the clone in $srcdir the default remote is our clone in $SRCDEST. The same goes for the mercurial.
If saving yourself the step of having to "git clone" again is your only goal, here are two possible ways to solve that problem:
The main point is to allow incremental builds as in FS#35050
participants (2)
-
Ido Rosen
-
Lukas Jirkovsky