From b596215c96b86eb3cad6ab0e02950908b938c7d9 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 9 Feb 2024 13:08:53 +0100 Subject: [PATCH] request much less data from git when inspecting a tag 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 --- Changelog | 1 + generic/generic_git.lua | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index c61abcd..53a6808 100644 --- 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 diff --git a/generic/generic_git.lua b/generic/generic_git.lua index d958a04..49522ec 100644 --- a/generic/generic_git.lua +++ b/generic/generic_git.lua @@ -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 -- 2.39.5