upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-26 11:35:00 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-26 15:26:15 +0000
commit237ab4ebcdc5bf58f98958db5375d56baf8046a0 (patch)
treed0d2114fbe4b77e2dedcc6191c1622022c8a6695
parent5c305e922e19e4ac65c6a1473be67145a1c73f2b (diff)
fix: correct refspec source in ngit sync to strip refs/heads/ prefix
When syncing, the nostr state stores refs with full names like refs/heads/master and refs/tags/v1.0.0. Git tracking refs strip the refs/heads/ prefix, so the tracking ref lives at refs/remotes/origin/master not refs/remotes/origin/refs/heads/master. The sync code was interpolating the full nostr_ref_name into the source side of the refspec, producing the invalid double-prefixed path. Strip refs/heads/ or refs/tags/ before constructing the tracking ref segment, consistent with how git_remote_nostr/push.rs already handles this.
-rw-r--r--CHANGELOG.md4
-rw-r--r--src/bin/ngit/sub_commands/sync.rs12
2 files changed, 13 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d58e1d..e6a7721 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11 11
12- git server push option passthrough, enabling `-o secret-scanning.skip` for grasp servers 12- git server push option passthrough, enabling `-o secret-scanning.skip` for grasp servers
13 13
14### Fixed
15
16- `ngit sync` using wrong refspec source (`refs/remotes/origin/refs/heads/master` instead of `refs/remotes/origin/master`), causing sync to fail with "src refspec does not match any existing object"
17
14## [2.2.1] - 2026-02-25 18## [2.2.1] - 2026-02-25
15 19
16### Fixed 20### Fixed
diff --git a/src/bin/ngit/sub_commands/sync.rs b/src/bin/ngit/sub_commands/sync.rs
index b377ab4..99cd2d8 100644
--- a/src/bin/ngit/sub_commands/sync.rs
+++ b/src/bin/ngit/sub_commands/sync.rs
@@ -130,6 +130,12 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> {
130 if missing_refs.contains(nostr_ref_name) { 130 if missing_refs.contains(nostr_ref_name) {
131 continue; 131 continue;
132 } 132 }
133 // strip refs/heads/ or refs/tags/ prefix to get the tracking ref segment
134 // e.g. refs/heads/master -> master, refs/tags/v1.0.0 -> v1.0.0
135 let tracking_ref_name = nostr_ref_name
136 .strip_prefix("refs/heads/")
137 .or_else(|| nostr_ref_name.strip_prefix("refs/tags/"))
138 .unwrap_or(nostr_ref_name.as_str());
133 if invalid_nostr_state_ref(nostr_ref_name) { 139 if invalid_nostr_state_ref(nostr_ref_name) {
134 // ensure nostr_state only supports refs/heads and refs/tags/ 140 // ensure nostr_state only supports refs/heads and refs/tags/
135 // and not refs/heads/prs/* 141 // and not refs/heads/prs/*
@@ -155,11 +161,11 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> {
155 // dont try and sync push symbolic refs 161 // dont try and sync push symbolic refs
156 } else if !force_required { 162 } else if !force_required {
157 refspecs.push(format!( 163 refspecs.push(format!(
158 "refs/remotes/{nostr_remote_name}/{nostr_ref_name}:{nostr_ref_name}", 164 "refs/remotes/{nostr_remote_name}/{tracking_ref_name}:{nostr_ref_name}",
159 )); 165 ));
160 } else if *is_grasp_server || args.force { 166 } else if *is_grasp_server || args.force {
161 refspecs.push(format!( 167 refspecs.push(format!(
162 "+refs/remotes/{nostr_remote_name}/{nostr_ref_name}:{nostr_ref_name}", 168 "+refs/remotes/{nostr_remote_name}/{tracking_ref_name}:{nostr_ref_name}",
163 )); 169 ));
164 } else { 170 } else {
165 not_updated.push(nostr_ref_name); 171 not_updated.push(nostr_ref_name);
@@ -167,7 +173,7 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> {
167 } else { 173 } else {
168 // add missing refs 174 // add missing refs
169 refspecs.push(format!( 175 refspecs.push(format!(
170 "refs/remotes/{nostr_remote_name}/{nostr_ref_name}:{nostr_ref_name}", 176 "refs/remotes/{nostr_remote_name}/{tracking_ref_name}:{nostr_ref_name}",
171 )); 177 ));
172 } 178 }
173 } 179 }