A puzzle: reset --hard and hard links

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

It seems `git reset --hard` recreates files that have external hard
links. Is this intended?

The example below highlights the behavior. I have an unchanged Git
repository. When I create an (outside) hard link to a file in the
repository, then `git reset --hard` re-creates the file with a new
modification time and inode. This occurs on Debian 11 with Git 2.30.2
but not on Debian 10 with Git 2.20.1

> git init
Initialized empty Git repository in .../git-test/.git/
> echo "test" > file.txt
> git add file.txt
> git commit -m "Import"
[main (root-commit) f73709f] Import
 1 file changed, 1 insertion(+)
 create mode 100644 file.txt
> stat -c '%y' file.txt
2022-01-19 18:43:52.147781748 +0100
> ls -i file.txt
74458979 file.txt
> ln file.txt ../file.txt
> git reset --hard
HEAD is now at f73709f Import
> stat -c '%y' file.txt
2022-01-19 18:44:47.013167127 +0100
> ls -i file.txt
74458995 file.txt

Can this behavior be avoided?

Best,
Michael



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux