The sound distributed version control system

#724 `pijul apply` Causes Destructive Loss of Unrecorded Changes

Opened by stellarpower on October 30, 2022
stellarpower on October 30, 2022

MRE:

# Create a dummy repo and add one change

pijul init

echo "# Bonjour!" > hello.md
set hash (pijul record -am 'Initial record' hello.md | sd 'Hash: ' '')


# Remove this change

pijul unrecord $hash
# Will show no changes (apart from empty starting point)
pijul log

# Now add some new changes. These will be lost below:

echo "# ¡Buenos Días!" > hello.md 

# Apply the old change back over the repo
pijul apply $hash

# And we've silently lost some of our work:
cat hello.md

This is in fish rather than a posix shell, but hopefully you get the idea:

Applying a change to the channel overwrites the files in the repo, even if there are unrecorded changes. This is in contrast to pijul channel switch, which will refuse to change channels if there are unrecorded changes (because these would be overwritten).

Expected Behaviour:

  • if applying a change to the current channel, and thus the working copy
    • for all files that will be overwritten by this change,
      • if there are unrecorded changes in these files, output the filename * do not output the repository and spit out an error message if we found unrecorded changes