From c596dab80699299a0c42a222e549a02d21640c76 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 28 Apr 2026 17:58:28 +0200 Subject: [PATCH] Improved rngit ref exclusion logic --- RNS/Utilities/rngit/client.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/RNS/Utilities/rngit/client.py b/RNS/Utilities/rngit/client.py index 1852989d..73ae6c85 100644 --- a/RNS/Utilities/rngit/client.py +++ b/RNS/Utilities/rngit/client.py @@ -536,7 +536,23 @@ class ReticulumGitClient(): bundle_path = tmpdir + "/push.bundle" create_cmd = ["git", "bundle", "create", bundle_path, local_ref] - if remote_ref in self.remote_refs: create_cmd.append(f"^{self.remote_refs[remote_ref]}") + + # Exclude all remote ref SHAs that exist locally, so the + # bundle only contains objects the remote doesn't already have + exclude_count = 0 + for sha in self.remote_refs.values(): + try: + # We need to verify Each SHA actually exists locally, since git + # bundle create will fail if a ^ argument references an object + # not present in the local repository. + result = subprocess.run(["git", "cat-file", "-t", sha], capture_output=True, check=False) + if result.returncode == 0: + create_cmd.append(f"^{sha}") + exclude_count += 1 + + except Exception as e: RNS.log(f"Could not verify remote SHA {sha} locally: {e}", RNS.LOG_WARNING) + + RNS.log(f"Excluding {exclude_count}/{len(self.remote_refs)} remote refs for {local_ref}", RNS.LOG_DEBUG) if progress_enabled: create_cmd.insert(3, "--progress")