balbuf / composer-git-merge-driver

Custom git merge driver to minimize merge conflicts in composer.json and composer.lock files
126 stars 7 forks source link

How to debug merge driver when it fails? #15

Open k0pernikus opened 4 years ago

k0pernikus commented 4 years ago

I'm getting an error on merge:

Auto-merging composer.lock
CONFLICT (content): Merge conflict in composer.lock
Auto-merging composer.json
Automatic merge failed; fix conflicts and then commit the result.

I am a newbie to merge drivers and would like to provide more information to you, yet since it's a private and proprietary project I don't know if I can share the conflicting composer.lock file yet.

Yet is there a way I could generate an error message that may be of use to you?

I would like to manually invoke the merge-driver by feeding it two versions of the composer.lock files and then see an error message.

Could you please pinpoint me on how I could achieve that?

imme-emosol commented 2 years ago

As far as I can tell from git's manual ( https://www.git-scm.com/docs/gitattributes#_defining_a_custom_merge_driver ), you'd need to have several files & could then do a step debug in php-cli.

(
# path to a file with the contents of your "previous" composer.lock ~ %O
ancestorfile=''
# path to a file with the contents of your current composer.lock ~ %A
oursfile=''
# path to a file with the contents of the conflicting composer.lock ~ %B
theirsfile=''
# the conflict marker size, default is 7 ~ %L
cmsize=''
# the path where git would write stuff to (path is used in the script) ~ %P
outfile=''

php composer-git-merge-driver "${ancestorfile}" "${oursfile}" "${theirsfile}" "${cmsize}" "${outfile}"
)