summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-07-20 07:34:56 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-07-21 09:00:37 (GMT)
commitf66b8a68f21d7dba6b80ba213315974476001b93 (patch)
tree216389df848c5c75b8a8863f8a78d92577d6637e /lib
parent60f7352fe1ae3d42ca7bd7611b6b787ff70cd813 (diff)
downloadgit-f66b8a68f21d7dba6b80ba213315974476001b93.zip
git-f66b8a68f21d7dba6b80ba213315974476001b93.tar.gz
git-f66b8a68f21d7dba6b80ba213315974476001b93.tar.bz2
git-gui: Factor out common fast-forward merge case
In both the ff and reset merge_types supported by checkout_op the result is the same if the merge base of our target commit and the existing commit is the existing commit: its a fast-forward as the existing commit is fully contained in the target commit. This minor cleanup in logic will make it easier to implement a new kind of merge_type that actually merges the two trees with a real merge strategy, such as git-merge-recursive. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/checkout_op.tcl46
1 files changed, 21 insertions, 25 deletions
diff --git a/lib/checkout_op.tcl b/lib/checkout_op.tcl
index 262dc96..6d87830 100644
--- a/lib/checkout_op.tcl
+++ b/lib/checkout_op.tcl
@@ -182,27 +182,23 @@ method _update_ref {} {
#
} else {
catch {set merge_base [git merge-base $new $cur]}
- switch -- $merge_type {
- ff {
- if {$merge_base eq $new} {
- # The current branch is actually newer.
- #
- set new $cur
- } elseif {$merge_base eq $cur} {
- # The current branch is older.
- #
- set reflog_msg "merge $new_expr: Fast-forward"
- } else {
- _error $this "Branch '$newbranch' already exists.\n\nIt cannot fast-forward to $new_expr.\nA merge is required."
- return 0
+ if {$merge_base eq $cur} {
+ # The current branch is older.
+ #
+ set reflog_msg "merge $new_expr: Fast-forward"
+ } else {
+ switch -- $merge_type {
+ ff {
+ if {$merge_base eq $new} {
+ # The current branch is actually newer.
+ #
+ set new $cur
+ } else {
+ _error $this "Branch '$newbranch' already exists.\n\nIt cannot fast-forward to $new_expr.\nA merge is required."
+ return 0
+ }
}
- }
- reset {
- if {$merge_base eq $cur} {
- # The current branch is older.
- #
- set reflog_msg "merge $new_expr: Fast-forward"
- } else {
+ reset {
# The current branch will lose things.
#
if {[_confirm_reset $this $cur]} {
@@ -211,11 +207,11 @@ method _update_ref {} {
return 0
}
}
- }
- default {
- _error $this "Only 'ff' and 'reset' merge is currently supported."
- return 0
- }
+ default {
+ _error $this "Only 'ff' and 'reset' merge is currently supported."
+ return 0
+ }
+ }
}
}