From a7b0f9924ea137bc50afcd85b8d939ad15385394 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 26 Apr 2026 01:18:31 +0200 Subject: [PATCH] Track local ref SHAs on pull for incremental bundle generation on remote --- RNS/Utilities/rngit/client.py | 16 +++++++++++++++- RNS/Utilities/rngit/server.py | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/RNS/Utilities/rngit/client.py b/RNS/Utilities/rngit/client.py index 28220fe..b807b29 100644 --- a/RNS/Utilities/rngit/client.py +++ b/RNS/Utilities/rngit/client.py @@ -433,7 +433,21 @@ class ReticulumGitClient(): batch = fetch_queue[:ref_batch_size] fetch_queue = fetch_queue[ref_batch_size:] - refs_list = [{"sha": sha, "ref": ref} for sha, ref in batch] + refs_list = [] + for sha, ref in batch: + ref_entry = {"sha": sha, "ref": ref} + try: + # Attempt to get local ref SHA for incremental bundle generation on remote + result = subprocess.run(["git", "rev-parse", ref], capture_output=True, text=True, check=False) + if result.returncode == 0: + local_sha = result.stdout.strip() + if local_sha != sha: ref_entry["have"] = local_sha + + except Exception as e: + RNS.log(f"Could not resolve local SHA for {ref} during fetch enumeration, getting full history for this ref: {e}", RNS.LOG_WARNING) + + refs_list.append(ref_entry) + ref_names = [ref for _, ref in batch] RNS.log(f"Fetching batch of {len(refs_list)} refs: {ref_names}", RNS.LOG_DEBUG) diff --git a/RNS/Utilities/rngit/server.py b/RNS/Utilities/rngit/server.py index 3a41060..88b91cf 100644 --- a/RNS/Utilities/rngit/server.py +++ b/RNS/Utilities/rngit/server.py @@ -520,7 +520,12 @@ class ReticulumGitNode(): RNS.log(f"Created {tmp_path} for {link}", RNS.LOG_DEBUG) bundle_path = os.path.join(tmp_path, "fetch.bundle") - execv = ["git", "bundle", "create", "--no-progress", bundle_path] + ref_names + execv = ["git", "bundle", "create", "--no-progress", bundle_path] + + for r in refs: + execv.append(r["ref"]) + if "have" in r and r["have"]: execv.append(f"^{r['have']}") + result = subprocess.run(execv, cwd=repository_path, capture_output=True, check=False) if result.returncode != 0: return self.RES_REMOTE_FAIL.to_bytes(1, "big") + result.stderr