However, for most cases etckeeper's metadata info is still enough to restore
all modes correctly. Files, which are not in the '.etckeeper' have had mode
either 644 or 755 originally. So, i just need to determine which one was
executable and which one was not. I can do this by looking at executable
bits unaffected by umask. In other words, i should find which (user, group
or other) 'x' bit is not set in umask and check it in the file. If it is
set, then `git` sets it and file was originally 755. Otherwise file was
originally 644.

But, unfortunately, this is not all. Any not remembered in '.etckeeper' file
can be either tracked by vcs and had mode 644 or 755 originally, or
_untracked_ by vcs and have any mode originally and now (its mode remains
the same).  These ignored/untracked files can have arbitrary modes, which
may be accidently considered as "broken 644" or "broken 755" and
overwritten. To avoid this i should obtain list of such files from vcs and
exclude it as well.

Attached script can be used to restore file modes properly.

Also, all modes should be restored properly, if you set umask to 022
before git checkout.

Attachment: restore_etc-2.sh
Description: Bourne shell script

Reply via email to