سؤال

I'm creating a merge driver. I have defined a .gitattributes file as follows:

filename merge=mergeStrategy

I have created the merge driver in $PROJECT/.git/config as follows:

[merge "mergeStrategy"]
    name = My merge strategy
    driver = scripts/mergeScript.sh

This works fine locally, but I would like to commit this merge driver to the git repository so that the merge strategy is in effect for everyone.

Is there a way I can add this (or other Git configuration options) to the repository itself?

هل كانت مفيدة؟

المحلول

You could simply add and commit (and push) script/mergeScript (along with the .gitattributes file, of course)

That would work as long as:

  • mergeScript is somehow in the $PATH of the user executing the merge driver.
  • mergeScript is executable, chmod +x
  • mergeScript is without extension, to allow you to later change its content (from a bash shell to a Perl script to a C executable to ...) if needed.

(Thank you, MestreLion, for the last two points, as he mentioned them in the comment)

That was the case for you locally, as I suspect that '.' was in your $PATH, but you cannot assume that for everybody.

However, the local config file (.git/config) won't be pushed/cloned (as Alexandr Priymak points out in the comment), so the users still need to replicate the declaration of the custom merge driver.
This is a basic safety measure, in order for you to not push a potential "harmful" script which would then be automatically executed at the next merge.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top