The sound distributed version control system

#376 Change channel after reset

Closed on March 1, 2021
tankf33der on March 1, 2021

FYI, If I reset a file it does not change a channel, otherwise if reset a whole working dir

$ pijul chann
  m1
  m2
* m3
  main
$ pijul reset b --channel m4
$ pijul chann
  m1
  m2
* m3
  m4
  main
$ pijul reset  --channel m4
$ pijul chann
  m1
  m2
  m3
* m4
  main
$
pmeunier added a change on March 1, 2021
KRGJVI7VFJQKJYV5V2V32RFTXEOV7R7CQN6MEC4KV3EM3MKJHUWAC
pmeunier added a change on March 1, 2021
QV66H4YAO5ASPDY72R3FBFMSFE2DXTKU54W4OSNBY5KPLXNIFPIAC
main
pmeunier on March 1, 2021

Well spotted! Since --channel changes the current channel, I don’t think it makes sense to use it for a single file.

I just pushed a patch with conflicting arguments, but then changed my mind and amended it, because I still want to leave the possibility to use --dry-run if the user only wants to see the state of a file in another channel.

pmeunier closed this discussion on March 1, 2021
fogti on March 2, 2021

Is there a way to change a single file to the version of another channel directly? Instead of:

# on channel main
pijul channel switch b
cp -T "$FILE" "/tmp/$(basename "$FILE")"
pijul channel switch main
cp -T "/tmp/$(basename "$FILE")" "$FILE"
rm "/tmp/$(basename "$FILE")"
pmeunier on March 2, 2021

That is precisely the goal of the following command: pijul reset --dry-run --channel b file.

fogti on March 2, 2021

Huh, but it says --dry-run, thus it should only write the content of the file to stdout, not write it, correct?

fogti on March 2, 2021

I’m looking for a equivalent of git checkout STATE -- FILE (sometimes git reset STATE -- FILE works too), but I think reset is the correct subcommand for this, instead of channel switch. I don’t think reset should change the active channel at all (this could be put behind an flag, but I don’t think it should be done at all). pijul channel switch does that, pijul reset imo should not do this.