git merge failed to detect conflict
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
I have just steped into a boarder case, where git merge fails to detect a merge conflict:
The commit A in the remote branch was the following:
LoWPAN.c +0 -0
- --- a/LoWPAN.c
+++ b/LoWPAN.c
@@ -431,12 +431,16 @@ int main (int argc, char **argv)
}
printf("\n");
#endif
- - // forward into kernel/tap device
- - retval=lowpan_writeout(&rx_packet,tap_fd);
- - if(retval<0) {- - ERROR_OUTPUT("Failed to forward datagram into tap device: %s",
- - strerror(errno));
- - break; // leave the while loop
+ // ensure that we haven't got our own multicast
+ if((rx_packet.source.pan_id != own_802154_addr.pan_id)
+ || (rx_packet.source.short_addr != own_802154_addr.short_addr)) {
+ // forward into kernel/tap device
+ retval=lowpan_writeout(&rx_packet,tap_fd);
+ if(retval<0) {+ ERROR_OUTPUT("Failed to forward datagram into tap device: %s",
+ strerror(errno));
+ break; // leave the while loop
+ }
}
}}
The commit B in the local branch was:
LoWPAN.c +0 -0
- --- a/LoWPAN.c
+++ b/LoWPAN.c
@@ -438,6 +438,8 @@ int main (int argc, char **argv)
strerror(errno));
break; // leave the while loop
}
+ DEBUG_OUTPUT("Successfully forwarded %d bytes into the tap device",
+ retval);
}}
The resulting merge commit AB is:
LoWPAN.c +0 -0
- --- 1/LoWPAN.c
- --- 2/LoWPAN.c
+++ b/LoWPAN.c
@@@ -431,15 -431,17 +431,19 @@@ int main (int argc, char **argv
}
printf("\n");
#endif
- - // forward into kernel/tap device
- - retval=lowpan_writeout(&rx_packet,tap_fd);
- - if(retval<0) {
- - ERROR_OUTPUT("Failed to forward datagram into tap device: %s",- - strerror(errno));
- - break; // leave the while loop
+ // ensure that we haven't got our own multicast
+ if((rx_packet.source.pan_id != own_802154_addr.pan_id)
+ || (rx_packet.source.short_addr != own_802154_addr.short_addr)) {
+ // forward into kernel/tap device
+ retval=lowpan_writeout(&rx_packet,tap_fd);
+ if(retval<0) {+ ERROR_OUTPUT("Failed to forward datagram into tap device: %s",
+ strerror(errno));
+ break; // leave the while loop
+ }
}
+ DEBUG_OUTPUT("Successfully forwarded %d bytes into the tap device",
+ retval);
}
}If you just look at the diff output, it is difficult to see the problem. But if you look at the corresponding code sections, than you see that diff has splitted the conflictiong section into two none conflicting sections.
Code A:
434 // ensure that we haven't got our own multicast
435 if((rx_packet.source.pan_id != own_802154_addr.pan_id)
436 || (rx_packet.source.short_addr !=
own_802154_addr.short_addr)) {
437 // forward into kernel/tap device
438 retval=lowpan_writeout(&rx_packet,tap_fd);
439 if(retval<0) { 440 ERROR_OUTPUT("Failed to forward datagram into tap device:
%s",
441 strerror(errno));
442 break; // leave the while loop
443 }
444 }
Code B:
434 // forward into kernel/tap device
435 retval=lowpan_writeout(&rx_packet,tap_fd);
436 if(retval<0) { 437 ERROR_OUTPUT("Failed to forward datagram into tap device: %s",
438 strerror(errno));
439 break; // leave the while loop
440 }
441 DEBUG_OUTPUT("Successfully forwarded %d bytes into the tap
device",
442 retval);
443 }
Code AB:
434 // ensure that we haven't got our own multicast
435 if((rx_packet.source.pan_id != own_802154_addr.pan_id)
436 || (rx_packet.source.short_addr !=
own_802154_addr.short_addr)) {
437 // forward into kernel/tap device
438 retval=lowpan_writeout(&rx_packet,tap_fd);
439 if(retval<0) { 440 ERROR_OUTPUT("Failed to forward datagram into tap device:
%s",
441 strerror(errno));
442 break; // leave the while loop
443 }
444 }
445 DEBUG_OUTPUT("Successfully forwarded %d bytes into the tap
device",
446 retval);
447 }
Obviously git/diff has failed to detect that human intervention is required here. One _workaround_ would be, to demand in the coding style, that closing braces get unique comments.
But what would be the solution of this problem?
Greetings
Juergen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFN/hr95JgLPmj5988RAvEZAJ0R23PMc5xXfbKPCYnw3s8FGkqBqACgtpgV 96GejSM+XaPgg9p4XMpuF/k=
=zjX3
-----END PGP SIGNATURE-----