Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Stop the closest remote SHA search at zero distance (#55302)

jifcc1a4ec76373
diff --git a/codex-rs/git-utils/src/info.rs b/codex-rs/git-utils/src/info.rs
index 0d9af38b3a..3465016aa9 100644
--- a/codex-rs/git-utils/src/info.rs
+++ b/codex-rs/git-utils/src/info.rs
@@ -695,6 +695,9 @@ async fn find_closest_sha(cwd: &Path, branches: &[String], remotes: &[String]) -
// Preserve existing behavior: skip branches that are not present on a remote.
continue;
};
+ if distance == 0 {
+ return Some(remote_sha);
+ }
match &closest_sha {
None => closest_sha = Some((remote_sha, distance)),
Some((_, best_distance)) if distance < *best_distance => {