Git reerere file template?

Can git be configured rerere

to remember and enforce merge permissions for specific file templates? Ie: only by template pom.xml

.

+3


source to share


1 answer


It's very complicated, but I can think of a solution that involves calling the script right after the merge operation (but before any manual permission).

First, the conflict resolution cache ( .git/rr-cache

) is stored by the blob hash, not the path file . There is nothing to specify in which file the permissions were obtained, so I think a hack in that directory would not be a viable solution.

This quote from maintainer Yunio Hamano also touches on the fact that rerere is a merge, not a per-file:

No "I don't care if there are good permissions that have nothing to do with the current merge, just remove them all" is what "rm -fr.git / rr-cache" means.

... which is of course not useful for you, because selectively deleting files from is .git/rr-cache

not suitable for automation in your use case.

A usage feature could be a subcommand forget

that takes a path. "Forgetting" can only happen in the context of a merge, which makes it fundamentally different than something like .gitignore

you can statically apply.

But perhaps you might have a post-merge hook that calls a script that :

Iterates over conflicting files:



git diff --name-only --diff-filter=U

      

For every file you want to "un-rerere", forget about it:

git rerere forget -- path/to/file

      

... and restore the conflict:

git checkout -m path/to/file

      

Then proceed to merge normally, leaving the retrace permissions for the files you want to remember intact.

List of files in which "reerere remembered" can be checked in the repository (possibly in a file named .reremember

) and requested from the script.

0


source







All Articles