#40 Detect moved files

Opened by cole-h on November 12, 2020
cole-h on November 12, 2020

As it stands now, for a file to show as “moved”, it must be pijul mv’d. Otherwise, by simply running mv src dest, it will show up as “deleted” (src) and “added” (dst). I don’t know if this is antithetical to pijul (using some kind of metric to determine if a file was moved), but it would be nice to have (would shorten diffs where these mvs happen).

pmeunier on November 30, 2020

I think this would be really cool. I just looked at the possibility of using inodes, but this seems a little bit fragile. Git has no notion of files, but this is how Darcs does it. I don’t trust their hypothesis that “it is impossible to get the same inode twice”, I believe this strongly depends on the filesystem.

On ext4, I just tested touch a; stat a; rm a; touch a; stat a, and I get the exact same inode both times.

A cool way to do this for files is to hard-link them somewhere in order to “reserve” the inodes if they’re deleted, but this doesn’t work for directories, since you can’t hard-link directories.

cole-h on November 30, 2020

Definitely FS-dependent, because on ZFS the same test results in two different inodes.

cole-h on November 30, 2020

Just spitballing:

Assuming we do the hardlink-to-reserve trick, maybe for directory detection, just compare the hardlinked file inodes of the directories? And then use some sort of similarity metric? This seems expensive (both computationally and implementation-wise), though.