Resolve a conflict

Resolve a conflict

When two keyholders change the same lines of a file, loot doesn’t pick a side. It records a conflict and waits for you to supply the content.

What merges by itself

Every pull, merge and converge classifies each path. Edits to separate lines of one file merge. A deletion wins over a side that left the file alone and conflicts with a side that edited it. Any overlapping hunk makes the whole file a conflict, and loot never writes <<<<<<< markers into it.

Printed asMeaning
convergedThe sides agree, the path is new on their side, or a deletion met an untouched side.
mergedOne side’s edit is the whole answer, or loot combined edits to separate lines.
conflict (needs resolution)Both sides changed the same lines, or one deleted what the other edited.
relayed (sealed — you lack the key)A side is sealed to you, so you carry its ciphertext and a keyholder does any merge.

How a conflict shows up

$ loot pull
pulled from http://127.0.0.1:47821 as bob:
  app.conf                 conflict (needs resolution)
converged onto one line:
  app.conf                         internal
surfaced 9d4c8ea4 as bob

The pull exits 2, which means it did its work and stopped on a conflict. Your side stays on disk and in the merge change, and loot status counts the open conflicts. Ask loot conflicts, which takes --porcelain and --json for scripts:

$ loot conflicts
conflict at app.conf
  base:   874432f2
  ours:   8bb2bcd6
  theirs: 3f6a20ac
conflict at notes.txt
  base:   470687be
  ours:   (deleted)
  theirs: 57f4c60e

A side that deleted the path shows as (deleted). Under --json each row carries base, ours and theirs, with null for a deleted side.

loot diff --conflict app.conf prints all three sides, decrypted where you hold the key.

Answer it

Write the content you want to a file, then hand it to loot resolve. It records and signs a resolution change.

$ loot resolve app.conf ../merged.conf
resolved app.conf (new oid: d49cb294)
recorded as "port 7070 (conflict resolution: app.conf)"
all conflicts resolved

Or let a three-way tool write it. --tool takes vimdiff, code, idea, kaleidoscope or a shell command using $BASE, $LOCAL, $REMOTE and $MERGED. If the tool exits non-zero or writes nothing, the conflict stays open.

loot resolve --tool vimdiff app.conf
loot resolve --tool 'cp $REMOTE $MERGED' app.conf   # take their side

When the answer is that the path should be gone, as it often is when a (deleted) side meets an edit, resolve it as deleted. The resolution drops the path and the file leaves the disk. A tool that exits 0 after removing $MERGED answers the same way. A conflict with no base can’t be resolved as deleted, since no side deleted it.

$ loot resolve notes.txt --delete
resolved notes.txt as deleted
recorded as "tidy notes (conflict resolution: notes.txt)"

Verbs that stop

Verbs that take --abort and --continue, such as merge, cherry-pick and revert, record a stop at a conflict, and loot status names it. Resolve each path, then run the verb again with --continue, or with --abort to put the view and working tree back where they were.

Traps

  • loot push refuses while conflicts are open, because the merge change records your side of each conflicted path as if it were the answer. Resolve first, or pass --allow-conflicts to push anyway.