Mercurial: Ignore file permission / mode (chmod) changes

后端 未结 1 622
北恋
北恋 2020-12-06 18:46

Is there a way to ignore file permission / mode (chmod) changes for a Mercurial repository?

I\'m looking for a setting similar to Git\'s:

core.filemo         


        
相关标签:
1条回答
  • 2020-12-06 18:54

    Mercurial only tracks the execute permission on files and not in a user/group/other way, just as a single bit, so depending what you're trying to squelch it's possible you really need to just adjust the umask of the user running hg update'

    If it is the execute bit that's getting you, then I think the only option is to use a pre-commit hook like:

    [hooks]
    pre-commit = find $(hg root) -type f -print0 | xargs -0 chmod a-x
    

    that, removes execute from all files before committing.

    To do the same only on versioned files, use hg locate as pointed out in Ish's comment:

    [hooks]
    pre-commit = hg locate --print0 | xargs -0 chmod a-x
    

    Note, though, that this can fail under certain circumstances. For example during renames (hg rename) both the file before the rename and after the rename will be recorded as versioned using hg locate. Therefore the hook will fail to chmod the old name of the file and the commit will fail as a whole. This can be "fixed" by either disabling the hook temporarily or by calling /bin/true at the end of the hook.

    0 讨论(0)
提交回复
热议问题