3 ms·
Happy to see something being developed for merge drivers, they are a underrated Git feature that could save a lot since the standard three-way merge of file con
by lucasoshiro 2y ago
Happy to see something being developed for merge drivers, they are a underrated Git feature that could save a lot since the standard three-way merge of file contents is not aware of the language and can create some problems. For example, if you have this valid Python code:
x = input()
if x == 'x':
print('foo')
print('bar')
If you delete the first print in a branch, delete the other print in another branch, then merge the two branches, you'll have this:
x = input()
if x == 'x':
Both branches delete a portion of the code inside the if block, leaving it only with a whitespace. In Python it is not a valid code, as they empty scopes need to be declared with pass.
I installed Mergiraf to see if it can solve this situation, but sadly, it doesn't support Python...
- wetneb 2y agoI tried your example but git does create a conflict in my case - but maybe I misunderstood the scenario. Python support can likely be done (I would be thrilled if someone made a PR for it), but I don't know if there is a lot of potential for solving conflicts there: imports can have side effects, function arguments are complicated with the mixture of positional and keyword arguments, decorators are effectful… it seems to me that there is a lot of sensitivity to order in many places.
- masklinn 2y agoFWIW your examples are very unclear as they use text formatting, you need to indent lines by 4 spaces (with an empty line before and after) for a code block e.g. if a == b: print("x") versus if a == b: print("x")
- chrismorgan 2y agoThe minimum required is actually only two spaces.
- deleted 2y ago[deleted]