about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide/josh-sync
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2025-01-08 17:17:03 +0100
committerJakub Beránek <berykubik@gmail.com>2025-01-08 17:52:01 +0100
commitf761e1ac3c82ffe94c2996892a276c4793b86a0b (patch)
tree2b6bda80dc2bd44c03ebf64fea7088cb9bd47dc3 /src/doc/rustc-dev-guide/josh-sync
parent7e2a690889a160bb7bba4d3a0664f37da0185780 (diff)
downloadrust-f761e1ac3c82ffe94c2996892a276c4793b86a0b.tar.gz
rust-f761e1ac3c82ffe94c2996892a276c4793b86a0b.zip
Error if there is nothing to pull
Diffstat (limited to 'src/doc/rustc-dev-guide/josh-sync')
-rw-r--r--src/doc/rustc-dev-guide/josh-sync/src/sync.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/doc/rustc-dev-guide/josh-sync/src/sync.rs b/src/doc/rustc-dev-guide/josh-sync/src/sync.rs
index 1c1757a46f9..eff80b1091d 100644
--- a/src/doc/rustc-dev-guide/josh-sync/src/sync.rs
+++ b/src/doc/rustc-dev-guide/josh-sync/src/sync.rs
@@ -81,12 +81,22 @@ impl GitSync {
         };
         let num_roots_before = num_roots()?;
 
+        let sha = cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
+
         // Merge the fetched commit.
         const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
         cmd!(sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}")
             .run()
             .context("FAILED to merge new commits, something went wrong")?;
 
+        let current_sha = cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
+        if current_sha == sha {
+            cmd!(sh, "git reset --hard HEAD^")
+                .run()
+                .expect("FAILED to clean up after creating the preparation commit");
+            return Err(anyhow::anyhow!("No merge was performed, nothing to pull. Rolled back the preparation commit."));
+        }
+
         // Check that the number of roots did not increase.
         if num_roots()? != num_roots_before {
             bail!("Josh created a new root commit. This is probably not the history you want.");