Pijul

Pijul add of a directory says it's a file

I decided to play around with Pijul this evening and was going through the getting started document.

So I created a new Rust project called pijul-test and moved onto adding the files. But something caught me by surprise. When I ran this action:

pijul add Cargo.toml src/

It added src as a file as you can see below:

λ ~/Developer/pijul-test/ pijul status            
On branch master

Changes not yet recorded:
  (use "pijul record ..." to record a new patch)

        new file:  Cargo.toml
        new file:  src

Untracked files:
  (use "pijul add <file>..." to track them)

        src/main.rs

I usually do do git add directory to add everything under directory and I thought it would be the same with Pijul. So now I’m curious.

  1. Why did Pijul assume it was a file?
  2. Why didn’t Pijul check that indeed was a file?
  3. How is src represented in the patch now that I recorded it?

Looking forward to getting some answers :grin: and looking forward, even more, to playing around with Pijul and learning about it :heart_eyes:

Hi! Welcome. I believe this is just a minor terminology error in the patch command, your directory was almost certainly recorded as a directory.
If you want to add an entire directory recursively, pijul add --recursive can do that.

Thanks for the reply and the welcome :blush:

your directory was almost certainly recorded as a directory.

Cool, that’s good to know! Would it be worth me digging into the implementation a bit and seeing if I can change the message to say that Pijul is adding a directory? :thinking:

If you want to add an entire directory recursively, pijul add --recursive can do that.

Good to know! I still need to browse through the rest of the docs :slight_smile:

This is actually a good first bug! I’m not particularly happy about how libpijul is organised (I’m currently rewriting it from scratch), but if you look at libpijul/src/backend/file_header.rs, you’ll see the type FileMetadata defined, just before a constant DIR_BIT is defined.

Actually, in Pijul, file names are stored prefixed by a 16 bit integer indicating (1) permissions, on the 9 least-significant bits, and (2) whether it’s a file or a directory, on the 10th LSB.

So, if you look at the patch command in pijul/src/commands/patch.rs, there’s a number of calls to the get_file_names method that seem to return a tuple, but the first component is ignored. I believe that first component is the 16-bit “permissions” info (I might be wrong).

I did some digging around and grepped for text. I came up with a patch here https://nest.pijul.com/pijul_org/pijul/discussions/437. Hopefully it’s a good starting point :pray: