Hi,

as there are many data type changes, here's an idea on how to simplify the
merges. Git supports custom merge drivers which attracted my attention, so
I've ended up with the following trick:

=== Add to .git/config ===

[merge "7"]
    name = Compatibility merge between PHP5 and PHP7
    driver = ./replace.sh %A %O %B

=== Add to .git/info/attributes ===

*.c merge=7
*.h merge=7
*.re merge=7
*.l mrege=7
*.y merge=7


=== Create replace.sh ==

#/bin/bash

CURRENT="$1"
ANCESTOR="$2"
OTHER="$3"

#
http://git.php.net/?p=php-src.git;a=blob;f=compat/replace.php;hb=refs/heads/str_size_and_int64
php /path/to/replace.php --macros "$ANCESTOR"

exec git merge-file "$CURRENT" "$ANCESTOR" "$OTHER"


The basic idea behind this - do some automatic processing on the fale
which is getting in before merge. Say when merging from PHP5 to PHP7, one
could automatically replace macro names or whatever, we can extend it. For
now I've just added the macro script.

This can solve simple cases yet, for example if something like this comes in:

if(type == IS_LONG)

it'll overwrite it to

if(type == IS_INT)

before merge start, so the automatic merge will go smoothly.

In the case for example like

char *hello = estrdup("hello");

to zend_string *

or

long one = Z_LVAL(z_one);

to

php_int_t one = Z_IVAL(z_one);

the automatic replacement is not that easy to do, so this would fail (even
the macro names were the same, long vs php_int_t or other placeholder name
would fail). But at least we had a mechanism getting rid of the simple
cases, no matter how the naming issues was solved.

Just as side effect, the git attributes will apply to all the branches, so
that should be activated only when merging 5 to 7. I think a tip from
someone more experienced in git might help to solve this or improve this
mechanism.

Regards

Anatol



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to