composer-git-merge-driver icon indicating copy to clipboard operation
composer-git-merge-driver copied to clipboard

How to debug merge driver when it fails?

Open k0pernikus opened this issue 4 years ago • 1 comments

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?

k0pernikus avatar Aug 04 '20 16:08 k0pernikus

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}"
)

imme-emosol avatar Jun 11 '22 23:06 imme-emosol