utopia-ia/elffuss-braid public
Changesets · Branches · Tags · Compare
| Changeset | 1f36d778ef35c2ec35ce14861f1ccef1126d867b4926f516fa113d85d6c64760 |
|---|---|
| Author | KikoCis <KikoCis@users.noreply.github.com> · 2026-10-16 00:15 +02:00 |
| Committer | KikoCis <KikoCis@users.noreply.github.com> · 2026-10-16 00:15 +02:00 |
| Parents | 7c2ce6e49a3f |
2 files changed
modified crates/cli/tests/workspaces.rs +29 −0
| @@ -1129,3 +1129,32 @@ | ||
| 1129 | 1129 | } |
| 1130 | 1130 | assert!(repo.fsck_is_clean()); |
| 1131 | 1131 | } |
| 1132 | + | |
| 1133 | +#[test] | |
| 1134 | +fn workspaces_made_before_main_existed_land_without_an_update() { | |
| 1135 | + // Both workspaces start on an empty branch, so their first changesets | |
| 1136 | + // have no parent. The second to land is rebased from the empty tree. | |
| 1137 | + let repo = Repo::new(); | |
| 1138 | + let a = repo.workspace("first-a"); | |
| 1139 | + let b = repo.workspace("first-b"); | |
| 1140 | + write(&a, "a.txt", "from a\n"); | |
| 1141 | + write(&b, "b.txt", "from b\n"); | |
| 1142 | + json(&a, &["commit", "-m", "a"]); | |
| 1143 | + json(&b, &["commit", "-m", "b"]); | |
| 1144 | + assert_eq!(json(&a, &["land"])["outcome"], "fast-forward"); | |
| 1145 | + let landed = json(&b, &["land"]); | |
| 1146 | + assert_eq!(landed["outcome"], "rebased"); | |
| 1147 | + assert_eq!(read(&b, "a.txt"), "from a\n"); | |
| 1148 | + | |
| 1149 | + // The same path added on both sides is a conflict, never an overwrite. | |
| 1150 | + let c = repo.workspace("first-c"); | |
| 1151 | + let d = repo.workspace("first-d"); | |
| 1152 | + write(&c, "same.txt", "from c\n"); | |
| 1153 | + write(&d, "same.txt", "from d\n"); | |
| 1154 | + json(&c, &["commit", "-m", "c"]); | |
| 1155 | + json(&d, &["commit", "-m", "d"]); | |
| 1156 | + json(&c, &["land"]); | |
| 1157 | + let conflict = json_status(&d, &["land"], 2); | |
| 1158 | + assert_eq!(conflict["conflicts"][0]["path"], "same.txt"); | |
| 1159 | + assert!(repo.fsck_is_clean()); | |
| 1160 | +} |
modified crates/wc/src/rebase.rs +9 −0
| @@ -92,6 +92,15 @@ | ||
| 92 | 92 | _ => match land(objects, tip, change, committer.clone()) { |
| 93 | 93 | Err(braid_engine::Error::BaseNotOnBranch { .. }) => match (first, tip) { |
| 94 | 94 | (First::Anywhere, Some(onto)) => replay_one(objects, onto, change, committer)?, |
| 95 | + // A first changeset without a parent is based on the | |
| 96 | + // empty tree, where every branch starts: rebase it from | |
| 97 | + // there rather than asking for an update. A path the | |
| 98 | + // branch added too is a conflict, never overwritten. | |
| 99 | + (First::MustBeOnBranch, Some(onto)) | |
| 100 | + if read_changeset(objects, change)?.parents.is_empty() => | |
| 101 | + { | |
| 102 | + replay_one(objects, onto, change, committer)? | |
| 103 | + } | |
| 95 | 104 | _ => { |
| 96 | 105 | return Err(Error::NotOnBranch { |
| 97 | 106 | branch: branch.to_owned(), |