The sound distributed version control system

#814 `reset` fails if file has been removed

Opened by stellarpower on June 30, 2023
stellarpower on June 30, 2023

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
[🍍] user@Host ~> nd /tmp/pijul
[🍍] user@Host /t/pijul> pijul init
Repository created at /tmp/pijul
[🍍] user@Host /t/pijul> echo > SomeFile.txt
[🍍] user@Host /t/pijul> pijul record -m 'foo'  SomeFile.txt
[🍍] user@Host /t/pijul> rm SomeFile.txt 
[🍍] user@Host /t/pijul> pijul reset SomeFile.txt
Error: No such file or directory (os error 2)
Outputting repository ←                                                                                                                                                                                                                     
[1][🍍] user@Host /t/pijul> ls -lah
total 36K
drwxrwxr-x  3 user    user 4.0K Jul  1 02:35 .
drwxrwxrwt 28 root    root  20K Jul  1 02:34 ..
-rw-rw-r--  1 user    user   15 Jul  1 02:34 .ignore
drwxrwxr-x  5 user    user 4.0K Jul  1 02:34 .pijul
[🍍] user@Host /t/pijul> pijul --version
pijul 1.0.0-beta.5

Is this as expected? I would assume that if I remove the file, it would be output - i.e. the argument to reset relates to what is in the repository, more than what is in my working directory. I had to touch it in order to reset.

Similarly I tried to pijul mv and got a message that the file was missing - the reason is that it had changed, and pijul was showing it both as untracked and deleted.

tankf33der on June 30, 2023

pijul reset <FILE> resetting modified file.

pijul reset resetting working dir and deleted files will appear.

This is expected in my world.


stellarpower on July 1, 2023

Doesn’t deletion count as a form of modification to a file?

For me, I would expect reset on a specific path to behave the same as reset on the whole working dir, except it constrains the items it resets. It’s potentially confusing to have two different sets of behaviour I need to remember - a bit like the trailing slash on rsync. And if I reset a file, I’m saying I want it to go back to how it is in the repository, irrespective of what sort of changes I have made to it. That could be content, it could be permissions/ownership, it could be that it’s not longer present.

stellarpower on July 9, 2023

It also looks to be that resetting a file that isn’t in the repository doesn’t produce an error:

[🍍] user@Host /t/pijul> touch   somefile.txt # Not tracked
[🍍] user@Host /t/pijul> date  > SomeFile.txt
[🍍] user@Host /t/pijul> pijul record -m 'date'  SomeFile.txt
[🍍] user@Host /t/pijul> pijul reset somefile.txt # oops

Outputting repository β†–                                                                                    
Reset given paths to last recorded change
[🍍] user@Host /t/pijul>