Commit Graph

19 Commits (baf8d4630b04b1702713c71b1972dc42984e0867)

Author SHA1 Message Date
Alexander Larsson baf8d4630b git: Explicitly pull all refs when doing full pull
Older versions of git default to only tags when you do --tags instead
of tags + all. So, we force everything with --tags *:*.

Closes: #62
Approved by: alexlarsson
2017-11-06 12:42:36 +00:00
Alexander Larsson 3afbb5a6d2 Fix bundling of git sources specifying a tag object
When pulling the commit we need to also pull the tags so we have them
locally, and then we need to peel the ref when we commit it so that we
don't try to create a ref pointing to a non-commit (tag) object.

Closes: #62
Approved by: alexlarsson
2017-11-06 12:42:36 +00:00
Alexander Larsson c5cd6f50f6 Fix crashes on git errors
We returned FALSE but error was unset, leading to a crash printing
the error message.

Closes: #62
Approved by: alexlarsson
2017-11-06 12:42:36 +00:00
Alexander Larsson 4c0b9ae0e3 git: Use cp -al instead of git clone when checking out git mirror
This fixes older versions of git not supporting clones from shallow
repos.
2017-10-31 11:22:44 +01:00
Alexander Larsson 7d532f5125 git: Disable fsck when doing shallow clones on git < 1.8.3.2
The git 1.8.3.2 release notes say:

 * Cloning with "git clone --depth N" while fetch.fsckobjects (or
   transfer.fsckobjects) is set to true did not tell the cut-off
   points of the shallow history to the process that validates the
   objects and the history received, causing the validation to fail.

So, on versions prior to this, we always disable fsck when you're
pulling shallowly. If you need fsck validation, use a newer git.
2017-10-31 10:22:52 +01:00
Alexander Larsson bf7aeacded git: Don't clone refs that is not under refs/
HEAD gives all sorts of problems
2017-10-31 09:05:59 +01:00
Alexander Larsson a39f727adf git: Never do shallow pulls if we once had a deep one
This seems to break on old versions of git. For example:

$ git --version
git version 1.8.3.1
$ git clone --mirror https://github.com/divVerent/s2tc.git
Cloning into bare repository 's2tc.git'...
remote: Counting objects: 740, done.
remote: Total 740 (delta 0), reused 0 (delta 0), pack-reused 740
Receiving objects: 100% (740/740), 1.47 MiB | 0 bytes/s, done.
Resolving deltas: 100% (493/493), done.
$ cd s2tc.git/
$ git fetch -p --no-recurse-submodules --no-tags --depth=1 -f origin '+HEAD:HEAD'
fatal: git fetch-pack: expected shallow list

Closes: #55
Approved by: alexlarsson
2017-10-30 10:57:35 +00:00
Alexander Larsson 17f659ee71 git: --unshallow if we do a full pull where we were previously shallow
Closes: #55
Approved by: alexlarsson
2017-10-30 10:57:35 +00:00
Alexander Larsson ac6a25c981 Add option to disable shallow clone for git sources
Closes: #55
Approved by: alexlarsson
2017-10-30 10:57:35 +00:00
Alexander Larsson 7e124f0e91 Work around issues with older versions of git
It turns out older versions of git cannot properly check out a commit
if the ref that points to it was not a normal one (branch or tag).
So, we work around this case by detecting it add adding a fake
tag. Also, we change the fake ref we use for commit-only references
to be a regular branch and not a special one for the same reason.

This fixes https://github.com/flatpak/flatpak/issues/1133

Closes: #52
Approved by: alexlarsson
2017-10-27 10:41:20 +00:00
Alexander Larsson 15f3582e40 Fix checkout of shallow repo.
Some manifest (cx.ring.RingGnome) had a git commit id that
was only tip of a non-branch ref (refs/changes/51/8051/8), which
was not cloned by a regular clone, so we need to switch to
a clone --mirror.

Closes: #50
Approved by: alexlarsson
2017-10-19 20:39:08 +00:00
Alexander Larsson be8597f346 git: Try to do shallow mirrors when downloading
When downloading a git repo we try to do a shallow (depth=1) fetch of
only the specified target. This normally works fine for branches and
tags, but if the commit is a raw SHA1 then it fails, because we can
only request refs from the remote.

We handle this by doing an ls-remote and seeing if the specified
target is either a (possilby partial) ref, or a commit id that a
remote ref is pointing at. If it is, we pull that ref only. If not,
then we fall back to a full fetch.

I believe this is the best we can do to fix
 https://github.com/flatpak/flatpak-builder/issues/6

Closes: #47
Approved by: alexlarsson
2017-10-17 10:31:28 +00:00
Alexander Larsson 42da157c47 git: Create fake refs that are not branches when doing shallow mirrors
When doing a shallow clone when bundling git sources we sometimes need
to create a ref in the source repo. This changes the ref used from
refs/heads/flatpak-builder/ref-$REF to refs/flatpak/ref-$REF.
In other words, it uses a custom ref rather than a branch, which has
less chance of conflicting with some existing branch.

Closes: #47
Approved by: alexlarsson
2017-10-17 10:31:28 +00:00
Alexander Larsson 04cf19083e git: Add GSubprocessFlags to git()
Closes: #47
Approved by: alexlarsson
2017-10-17 10:31:28 +00:00
Alexander Larsson 039a24aeb4 utils: Add flags argument to flatpak_spawn
This allows you to e.g. silence STDERR

Closes: #47
Approved by: alexlarsson
2017-10-17 10:31:28 +00:00
Alexander Larsson 6294fafcc4 git: Fix problems bundling git repos on older git versions
It seems we have to specify

git fetch --depth 1 origin $ref:$ref

instead of

git fetch --depth 1 origin $ref

because on older versions of git (1.8.3 at least) this otherwise just
sets FETCH_HEAD, rather than $ref in the fetching repo.
2017-09-26 19:36:09 +02:00
Alexander Larsson 0e5fdaf89a bundle git repos shallowly
There is no need to bundle the entire history in a git repo.
Instead we only bundle shallow versions of all the branches/tags/commit
that we reference.

For directly specified commit ids we can't really shallow-clone those,
so we create fake tags in the mirrored repo.
2017-09-21 16:05:05 +02:00
Alexander Larsson faba587a72 Move common/flatpak-utils.* to src/builder-flatpak-utils.* 2017-08-25 09:36:49 +02:00
Alexander Larsson 5823533bd7 Move builder/ to src/ 2017-08-25 09:30:53 +02:00