]> git.e2factory.org Git - e2factory.git/commitdiff
git: optionally skip workdir checkout
authorTobias Ulmer <tu@emlix.com>
Fri, 3 May 2019 17:20:16 +0000 (19:20 +0200)
committerTobias Ulmer <tu@emlix.com>
Fri, 3 May 2019 17:20:21 +0000 (19:20 +0200)
Skips workdir checkout on git clone, like in older versions of
e2factory.  This may help to speed up fetch-sources of very large repos
and reduces disk space requirements in some scenarios (CI).

It's currently not documented and may go away. For one, configuring it
via the source config is a little awkward.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
plugins/git.lua

index 1454603e6b7384d234405bea526741b751a86dcd..f817b297d835f36866b33ea9f61052946ce3029d 100644 (file)
@@ -72,6 +72,7 @@ function git.git_source:initialize(rawsrc)
         ["working-copy"] = "working-copy",
     }
     self._commitids = {}
+    self._checkout = true
     self._xxxcommitid = false -- XXX: Not yet
 
     rc, re = e2lib.vrfy_dict_exp_keys(rawsrc, "e2source", {
@@ -84,6 +85,7 @@ function git.git_source:initialize(rawsrc)
         "tag",
         "type",
         "working",
+        "checkout", -- XXX: undocumented on purpose
     })
     if not rc then
         error(re)
@@ -124,6 +126,13 @@ function git.git_source:initialize(rawsrc)
     self._branch = rawsrc.branch or ""
     self._location = rawsrc.location
     self._tag = rawsrc.tag
+
+    if rawsrc.checkout then
+        if type(rawsrc.checkout) ~= boolean then
+            error(err.new("checkout' must be a boolean"))
+        end
+        self._checkout = rawsrc.checkout
+    end
 end
 
 function git.git_source:get_server()
@@ -337,6 +346,9 @@ function git.git_source:display()
     if self._xxxcommitid then
         table.insert(d, string.format("commitid   = %s", self._xxxcommitid))
     end
+    if self._checkout ~= true then
+        table.insert(d, string.format("checkout   = %s", tostring(self._checkout)))
+    end
     table.insert(d, string.format("server     = %s", self._server))
     table.insert(d, string.format("location   = %s", self._location))
     table.insert(d, string.format("working    = %s", self:get_working()))
@@ -479,12 +491,17 @@ function git.git_source:fetch_source()
     e2lib.logf(2, "cloning %s:%s [%s]", self:get_server(), self:get_location(),
         self:get_branch())
 
+    local skip_checkout = not self._checkout
     rc, re = generic_git.git_clone_from_server(cache.cache(), self:get_server(),
-        self:get_location(), work_tree, false --[[always checkout]])
+        self:get_location(), work_tree, skip_checkout)
     if not rc then
         return false, e:cat(re)
     end
 
+    if not self._checkout then
+        return true
+    end
+
     rc, re, id = generic_git.lookup_id(git_dir, generic_git.NO_REMOTE,
         refs_heads(self:get_branch()))
     if not rc then