This repository has been archived by the owner on Feb 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This scenario is fairly common in the real world. It might be a stretch to expect VCS tools to handle it correctly but it's not impossible.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More tests => 2; | ||
use Test::Merges; | ||
|
||
# Add an end-of-line comment and change the same line | ||
# | ||
# Developers sometimes add comments to a block of code when they | ||
# encounter it for the first time. It's a good opportunity to | ||
# document subtle assumptions. When this is done with end of line | ||
# comments, conflicts can result. | ||
# | ||
# A good VCS should notice that an end of line comment is independent | ||
# of changes earlier on the line. This might require knowing a language's | ||
# semantics to get it right. | ||
|
||
# build expected output | ||
file 'greet.c', <<'END'; | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
int main () { | ||
printf("hi\n"); | ||
printf("bye\n"); | ||
exit(0); | ||
} | ||
END | ||
|
||
file 'run', <<'END'; | ||
#!/bin/sh | ||
gcc -o greet greet.c && \ | ||
./greet | ||
END | ||
chmod 0755, 'run'; | ||
|
||
# expected output after all merges are done | ||
file 'expected.txt', <<'END'; | ||
hello | ||
bye | ||
END | ||
|
||
# build a common starting point | ||
add 'greet.c', 'run', 'expected.txt'; | ||
commit 'intial state'; | ||
|
||
branch 'a', sub { | ||
file 'greet.c', <<'END'; | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
int main () { | ||
printf("hi\n"); // greet the user | ||
printf("bye\n"); | ||
exit(0); | ||
} | ||
END | ||
commit 'add eol comment'; | ||
}; | ||
|
||
branch 'b', sub { | ||
sed 's/hi/hello/', 'greet.c'; | ||
commit 'longer greeting'; | ||
}; | ||
|
||
merge_ok 'a', 'b'; |