]> git.e2factory.org Git - e2factory.git/commitdiff
request much less data from git when inspecting a tag
authorRolf Eike Beer <eb@emlix.com>
Fri, 9 Feb 2024 12:08:53 +0000 (13:08 +0100)
committerRolf Eike Beer <eb@emlix.com>
Tue, 22 Jul 2025 08:27:55 +0000 (10:27 +0200)
When calling "git ls-remote" or "git show-ref" they will output all existing
objects. Especially when working with stable kernel repositories this can be
a large amount of data. This can even cause pipe overflows when the internal
pipe buffer can not accept the >600kB of data that are returned in my case.

When checking a tag tell those commands to output only the matching refs, which
will greatly reduce the data returned and will speed up processing at both ends.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Changelog
generic/generic_git.lua

index c61abcd956f0e95c9d645337c6ce9da687046991..53a6808f744d7ed585b731acac3ed2641c7047e2 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,5 +1,6 @@
 NEXT:
  * fix message when local and remote tags differ
+ * request much less data from git when inspecting a tag
 
 e2factory-2.3.18p1
  * add support for rsync 3.2.4 style path arguments
index d958a0444ea54fdfb5ee7a935533c9165faaff68..49522ec515989db1eee13b654083c3173571aaf3 100644 (file)
@@ -221,9 +221,10 @@ end
 -- @param remote Name of the "remote" repository for listing refs.
 --                      Network connection! Use generic_git.NO_REMOTE for
 --                      local refs (including remotes/...)
+-- @param ref if given request only the matching ref
 -- @return Error object on failure, otherwise nil
 -- @return Table containing tables of "id", "ref" pairs, or false on error.
-function generic_git.list_refs(git_dir, remote)
+function generic_git.list_refs(git_dir, remote, ref)
     assertIsStringN(git_dir)
     assert(remote == generic_git.NO_REMOTE or assertIsStringN(remote))
 
@@ -239,6 +240,9 @@ function generic_git.list_refs(git_dir, remote)
         table.insert(argv, "show-ref")
         table.insert(argv, "--head") -- ls-remote does this by default
     end
+    if ref then
+        table.insert(argv, ref)
+    end
 
     rc, re, out = generic_git.git(argv)
     if not rc then
@@ -279,7 +283,7 @@ function generic_git.lookup_id(git_dir, remote, ref)
     assertIsStringN(ref)
     local rc, re, t
 
-    rc, re, t = generic_git.list_refs(git_dir, remote)
+    rc, re, t = generic_git.list_refs(git_dir, remote, ref)
     if not rc then
         return false, re
     end
@@ -336,7 +340,7 @@ function generic_git.lookup_ref(git_dir, remote, id, filter)
 
     local rc, re, t
 
-    rc, re, t = generic_git.list_refs(git_dir, remote)
+    rc, re, t = generic_git.list_refs(git_dir, remote, nil)
     if not rc then
         return false, re
     end