Skip to content

Instantly share code, notes, and snippets.

@tiborvass
Last active August 29, 2015 14:14
Show Gist options
  • Save tiborvass/cdad18312fe571fe1ac0 to your computer and use it in GitHub Desktop.
Save tiborvass/cdad18312fe571fe1ac0 to your computer and use it in GitHub Desktop.
git merge-tree
MacBook-Pro:review tibor$ gl
* 3a48299 (origin/alice, alice) alice fix
| * 8dc2ba1 (origin/bob, bob) bob fix
|/
* af5062b (HEAD, origin/master, master) first commit
MacBook-Pro:review tibor$ ls
test.js
MacBook-Pro:review tibor$ cat test.js
// flat fees and taxes
var customsFee = 5.5;
var immigrationFee = 7;
var federalTransportTax = .025;
function calculateAirfare(baseFare) {
var fare = baseFare;
fare += immigrationFee;
fare *= (1 + federalTransportTax);
return fare;
}
MacBook-Pro:review tibor$ # customsFee is not used, so both bob and alice will fix it without knowing the other is fixing it
MacBook-Pro:review tibor$ git diff master..alice
diff --git a/test.js b/test.js
index cbc9ef2..d3358c8 100644
--- a/test.js
+++ b/test.js
@@ -5,6 +5,7 @@ var federalTransportTax = .025;
function calculateAirfare(baseFare) {
var fare = baseFare;
+ fare += customsFee;
fare += immigrationFee;
fare *= (1 + federalTransportTax);
return fare;
MacBook-Pro:review tibor$ git diff master..bob
diff --git a/test.js b/test.js
index cbc9ef2..d6cbcac 100644
--- a/test.js
+++ b/test.js
@@ -6,6 +6,7 @@ var federalTransportTax = .025;
function calculateAirfare(baseFare) {
var fare = baseFare;
fare += immigrationFee;
+ fare += customsFee;
fare *= (1 + federalTransportTax);
return fare;
}
MacBook-Pro:review tibor$ # they both fixed it, but not on the same line
MacBook-Pro:review tibor$ # let's say alice's fix got merged first
MacBook-Pro:review tibor$ git merge alice
Updating af5062b..3a48299
Fast-forward
test.js | 1 +
1 file changed, 1 insertion(+)
MacBook-Pro:review tibor$ gl
* 3a48299 (HEAD, origin/alice, master, alice) alice fix
| * 8dc2ba1 (origin/bob, bob) bob fix
|/
* af5062b (origin/master) first commit
MacBook-Pro:review tibor$ git diff master..bob
diff --git a/test.js b/test.js
index d3358c8..d6cbcac 100644
--- a/test.js
+++ b/test.js
@@ -5,8 +5,8 @@ var federalTransportTax = .025;
function calculateAirfare(baseFare) {
var fare = baseFare;
- fare += customsFee;
fare += immigrationFee;
+ fare += customsFee;
fare *= (1 + federalTransportTax);
return fare;
}
MacBook-Pro:review tibor$ # this is incorrect, it's not what's going to happen if we merge bob's fix
MacBook-Pro:review tibor$ git diff master...bob
diff --git a/test.js b/test.js
index cbc9ef2..d6cbcac 100644
--- a/test.js
+++ b/test.js
@@ -6,6 +6,7 @@ var federalTransportTax = .025;
function calculateAirfare(baseFare) {
var fare = baseFare;
fare += immigrationFee;
+ fare += customsFee;
fare *= (1 + federalTransportTax);
return fare;
}
MacBook-Pro:review tibor$ # triple dot is even more so incorrect, since we don't see alice's fix
MacBook-Pro:review tibor$ # the only way to see this is to merge in memory and do diff, that's what merge-tree does apparently
MacBook-Pro:review tibor$ git merge-tree $(git merge-base master bob) master bob
changed in both
base 100644 cbc9ef2e2fb0c86c79a7494494072e0c720e8d79 test.js
our 100644 d3358c8350fa76ad69cbe52fabd82b3378c92bac test.js
their 100644 d6cbcac7c826c79ea7629e3077f9266fa909d80e test.js
@@ -7,6 +7,7 @@
var fare = baseFare;
fare += customsFee;
fare += immigrationFee;
+ fare += customsFee;
fare *= (1 + federalTransportTax);
return fare;
}
MacBook-Pro:review tibor$ # there we can see the correct diff, however it is not in the usual git diff format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment