Skip to content

Resolve a conflict

When main changes the lines your change edits, af writes the conflict into the file; edit it, and the change can land.

Two changes that edit the same lines conflict when the second is rebased onto the first. As in jj, a conflict is never a stopped command: it is kept in the change as data, written into the file with markers, and the change simply cannot land until you resolve it.

Make a conflict

Start a server and land a file to edit:

$ af-server --dev
...
$ source ~/af-dev/dev/env
$ af workspace add ~/one
Workspace at /home/you/one
Paths: **
main has no landing yet
$ cd ~/one
$ af new -m "Add a greeting"
Working on change kzonnnztlprnoxputktroupnvuovuwwk at commit edb1b8de85160742e41f2528e011ea93f4a63e518460b8259c0adc4d09c9f56d
$ echo "Hello" > greeting.txt
$ af submit
Submitted commit 16875ba21598d73fe5df3a01fcd221e5c7300a0d8e4641d4e48f2fb259bf68c5, 1 edit in its last snapshot
$ af status
Change kzonnnztlprnoxputktroupnvuovuwwk (landed) at commit 16875ba21598d73fe5df3a01fcd221e5c7300a0d8e4641d4e48f2fb259bf68c5

A second workspace takes the greeting and starts warming it up:

$ af workspace add ~/two
Workspace at /home/you/two
Paths: **
At landing 1, 1 file written
$ cd ~/two
$ af new -m "Greet warmly"
Working on change kovymotuxzzqpnkqlqplompvnqnzokup at commit 3ae0797aecbe5f6803c25ea0b3d4309d12a86b4cc67ed48b44bc21370177bc55
$ echo "Hello, friend" > greeting.txt

Meanwhile the first workspace shortens the same line, and lands first:

$ cd ~/one
$ af new -m "Greet briefly"
Working on change qsxxvsrqtxxvyqvyxvpqvuorntltmyqx at commit 74b319e3780dbc26bcfeaf5c425b268b4d640ffec7f41c4c4a7ee55baaabf031
$ echo "Hi" > greeting.txt
$ af submit
Submitted commit 7f94d5788a35e4fbb2bce33497b96aa0dcde36fc22e4fde174a82a2b22dbf1f5, 1 edit in its last snapshot
$ af status
Change qsxxvsrqtxxvyqvyxvpqvuorntltmyqx (landed) at commit 7f94d5788a35e4fbb2bce33497b96aa0dcde36fc22e4fde174a82a2b22dbf1f5
Based on landing 1

See it

Sync the second workspace. Its change is rebased onto the new landing, and both edits of the line meet:

$ cd ~/two
$ af sync
At landing 2: 1 file written, 0 deleted
$ af status
Change kovymotuxzzqpnkqlqplompvnqnzokup (open) at commit f43b1e7805acde7374fb07f55561ecc3e96d49bcc3c5e15b8e0d16505f745ec5
Based on landing 2
Conflicts in:
  greeting.txt
Landing waits for: scan
$ af resolve --list
greeting.txt    2-sided conflict

The file holds both sides, with markers, as jj writes them:

$ cat greeting.txt
<<<<<<< conflict 1 of 1
%%%%%%% diff from: kzonnnzt 16875ba2 "Add a greeting" (parents of rebased revision)
\\\\\\\        to: qsxxvsrq 7f94d578 "Greet briefly" (rebase destination)
-Hello
+Hi
+++++++ kovymotu d12e2ef0 "Greet warmly" (rebased revision)
Hello, friend
>>>>>>> conflict 1 of 1 ends

The %%%%%%% section is what main changed since your change began: from its base, Add a greeting, to main’s latest, Greet briefly, Hello became Hi. The +++++++ section is your side, Hello, friend. Each is named by its change and commit, so you can look at any of them with af show.

Resolve it

Write the file as it should be. The markers go, and with them the conflict:

$ echo "Hi, friend" > greeting.txt
$ af status
Change kovymotuxzzqpnkqlqplompvnqnzokup (open) at commit eccf3cf4ad481e4dbbb465508a7bd07940dcddc98e4c16a17f3e416196d92eed
Based on landing 2
Landing waits for: scan

Then land it as any change:

$ af submit
Submitted commit eccf3cf4ad481e4dbbb465508a7bd07940dcddc98e4c16a17f3e416196d92eed, 0 edits in its last snapshot

Next

Type to search…

↑↓ navigate↵ selectEsc close