Locking binary files using git version control system

前端 未结 17 1932
既然无缘
既然无缘 2020-11-28 03:54

For one and a half years, I have been keeping my eyes on the git community in hopes of making the switch away from SVN. One particular issue holding me back is the inabilit

17条回答
  •  悲&欢浪女
    2020-11-28 04:49

    I agree that locking binary files is a necessary feature for some environments. I just had a thought about how to implement this, though:

    • Have a way of marking a file as "needs-lock" (like the "svn:needs-lock" property).
    • On checkout, git would mark such a file as read-only.
    • A new command git-lock would contact a central lock server running somewhere to ask permission to lock.
    • If the lock server grants permission, mark the file read-write.
    • git-add would inform the lock server of the content hash of the locked file.
    • The lock server would watch for that content hash to appear in a commit on the master repository.
    • When the hash appears, release the lock.

    This is very much a half-baked idea and there are potential holes everywhere. It also goes against the spirit of git, yet it can certainly be useful in some contexts.

    Within a particular organisation, this sort of thing could perhaps be built using a suitable combination of script wrappers and commit hooks.

提交回复
热议问题