about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-03-17 15:49:28 +0100
committerRalf Jung <post@ralfj.de>2025-03-17 15:52:36 +0100
commit0ee94562c9e7e2e75a13f06d9820cd191e21a06a (patch)
tree6ef8a976ab8ad2df9b88d9a743225f25ae33af20
parent9c67cecd12d79f1bbc00a74f70e7ef9fff086a5a (diff)
downloadrust-0ee94562c9e7e2e75a13f06d9820cd191e21a06a.tar.gz
rust-0ee94562c9e7e2e75a13f06d9820cd191e21a06a.zip
fix download-llvm logic for subtree sync branches
-rw-r--r--src/build_helper/src/git.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/build_helper/src/git.rs b/src/build_helper/src/git.rs
index 9f778a2fd77..3837a4e41ff 100644
--- a/src/build_helper/src/git.rs
+++ b/src/build_helper/src/git.rs
@@ -140,6 +140,7 @@ pub fn get_closest_merge_commit(
             //    cd \"/checkout\" && \"git\" \"merge-base\" \"origin/master\" \"HEAD\"\nexpected success, got: exit status: 1\n"
             // ```
             // Investigate and resolve this issue instead of skipping it like this.
+            // NOTE (2025-03): this is probably caused by CI using a sparse checkout.
             (channel == "nightly" || !CiEnv::is_rust_lang_managed_ci_job())
         {
             git_upstream_merge_base(config, git_dir).unwrap()
@@ -150,11 +151,18 @@ pub fn get_closest_merge_commit(
         }
     };
 
+    // Now that rust-lang/rust is the only repo using bors, we can search the entire
+    // history for a bors commit, not just "first parents". This is crucial to make
+    // this logic work when the user has currently checked out a subtree sync branch.
+    // At the same time, we use this logic in CI where only a tiny part of the history
+    // is even checked out, making this kind of history search very fragile. It turns
+    // out that by adding `--diff-merges=first-parent`, we get a usable reply
+    // even for sparse checkouts: it will just return the most recent bors commit.
     git.args([
         "rev-list",
         &format!("--author={}", config.git_merge_commit_email),
         "-n1",
-        "--first-parent",
+        "--diff-merges=first-parent",
         &merge_base,
     ]);