From: Tom Clarke <tom@u2i.com>
To: gitster@pobox.com
Cc: Johannes.Schindelin@gmx.de, git@vger.kernel.org,
Tom Clarke <tom@u2i.com>
Subject: [PATCH] Adding rebase merge strategy
Date: Mon, 1 Oct 2007 17:08:40 +0200 [thread overview]
Message-ID: <11912513203420-git-send-email-tom@u2i.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0709281751390.28395@racer.site>
In addition to adding git-merge-rebase.sh, git-merge.sh is modified
to handle the rebase strategy specially and avoids running update-ref
as rebase won't generate a merge commit. It also adds a warning
if a message is supplied when the rebase isn't used as this
will be ignored.
Signed-off-by: Tom Clarke <tom@u2i.com>
---
Incorporated comments from Johannes Schindlen.
.gitignore | 1 +
Documentation/merge-strategies.txt | 6 +++++
Makefile | 2 +-
git-merge-rebase.sh | 17 ++++++++++++++
git-merge.sh | 24 +++++++++++++++++--
t/t3031-merge-rebase.sh | 44 ++++++++++++++++++++++++++++++++++++
6 files changed, 90 insertions(+), 4 deletions(-)
create mode 100755 git-merge-rebase.sh
create mode 100755 t/t3031-merge-rebase.sh
diff --git a/.gitignore b/.gitignore
index e0b91be..fe5cdc4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,6 +73,7 @@ git-merge-tree
git-merge-octopus
git-merge-one-file
git-merge-ours
+git-merge-rebase
git-merge-recursive
git-merge-resolve
git-merge-stupid
diff --git a/Documentation/merge-strategies.txt b/Documentation/merge-strategies.txt
index 7df0266..dff1909 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -33,3 +33,9 @@ ours::
merge is always the current branch head. It is meant to
be used to supersede old development history of side
branches.
+
+rebase::
+ This rebases the current branch based on a single head.
+ Commits are rewritten as with git-rebase. This doesn't
+ produce a merge. The procedure for dealing with conflicts
+ is the same as with git-rebase.
diff --git a/Makefile b/Makefile
index 8db4dbe..e6d3812 100644
--- a/Makefile
+++ b/Makefile
@@ -215,7 +215,7 @@ SCRIPT_SH = \
git-sh-setup.sh \
git-am.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
- git-merge-resolve.sh git-merge-ours.sh \
+ git-merge-resolve.sh git-merge-ours.sh git-merge-rebase.sh \
git-lost-found.sh git-quiltimport.sh git-submodule.sh \
git-filter-branch.sh \
git-stash.sh
diff --git a/git-merge-rebase.sh b/git-merge-rebase.sh
new file mode 100755
index 0000000..b75be3f
--- /dev/null
+++ b/git-merge-rebase.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Tom Clarke
+#
+# Resolve two trees with rebase
+
+# The first parameters up to -- are merge bases ignore them
+while test $1 != "--"; do shift; done
+shift
+
+# ignore the first head, it's not needed in a rebase merge
+shift
+
+# Give up if we are given two or more remotes -- not handling octopus.
+test $# = 1 || exit 2
+
+git rebase $1 || exit 2
diff --git a/git-merge.sh b/git-merge.sh
index 6c513dc..b58bee2 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -16,11 +16,12 @@ test -z "$(git ls-files -u)" ||
LF='
'
-all_strategies='recur recursive octopus resolve stupid ours subtree'
+all_strategies='recur recursive octopus resolve stupid ours subtree rebase'
default_twohead_strategies='recursive'
default_octopus_strategies='octopus'
no_fast_forward_strategies='subtree ours'
-no_trivial_strategies='recursive recur subtree ours'
+no_trivial_strategies='recursive recur subtree ours rebase'
+no_update_ref='rebase'
use_strategies=
allow_fast_forward=t
@@ -81,11 +82,18 @@ finish () {
echo "No merge message -- not updating HEAD"
;;
*)
- git update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1
+ case " $wt_strategy " in
+ *" $no_update_ref "*)
+ ;;
+ *)
+ git update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1
+ ;;
+ esac
;;
esac
;;
esac
+
case "$1" in
'')
;;
@@ -418,6 +426,16 @@ do
;;
esac
+ # Check to see if there's a message in a merge type that won't produce a commit
+ if test $have_message = "t"
+ then
+ case " $strategy " in
+ *" $no_update_ref "*)
+ echo >&2 "warning: Message is not used for $strategy merge strategy"
+ ;;
+ esac
+ fi
+
# Remember which strategy left the state in the working tree
wt_strategy=$strategy
diff --git a/t/t3031-merge-rebase.sh b/t/t3031-merge-rebase.sh
new file mode 100755
index 0000000..daa03b1
--- /dev/null
+++ b/t/t3031-merge-rebase.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+test_description='merge-rebase backend test'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo hello >a &&
+ git add a &&
+ test_tick && git commit -m initial &&
+
+ git checkout -b branch &&
+ echo hello >b &&
+ git add b &&
+ test_tick && git commit -m onbranch &&
+
+ git checkout master &&
+ echo update >a &&
+ git add a &&
+ test_tick && git commit -m update
+'
+test_expect_success 'merging using rebase does not create merge commit' '
+ git checkout branch &&
+ git merge -s rebase master &&
+
+ ( git log --pretty=oneline ) >actual &&
+ (
+ echo "4db7a5a013e67aa623d1fd294e8d46e89b3ace8f onbranch"
+ echo "893371811dbd13e85c098b72d1ab42bcfd24c2db update"
+ echo "0e960b10429bf3f1e168ee2cc7d531ac7c622580 initial"
+ ) >expected &&
+ git diff -w -u expected actual
+'
+git reset --hard HEAD@{2}
+
+test_expect_success 'merging using rebase with message gives warning' '
+ git merge -m "a message" -s rebase master 2> actual &&
+ (
+ echo "warning: Message is not used for rebase merge strategy"
+ ) >expected &&
+ git diff -w -u expected actual
+'
+
+test_done
--
1.5.3.rc7.3.g850f-dirty
next prev parent reply other threads:[~2007-10-01 15:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-28 16:15 [PATCH] Adding rebase merge strategy Tom Clarke
2007-09-28 17:03 ` Johannes Schindelin
2007-09-28 17:18 ` Tom Clarke
2007-10-01 15:08 ` Tom Clarke [this message]
2007-10-01 15:50 ` Johannes Schindelin
2007-10-01 21:01 ` Junio C Hamano
2007-10-01 21:41 ` Tom Clarke
2007-10-01 22:17 ` Carl Worth
2007-10-01 22:21 ` Tom Clarke
2007-10-01 22:30 ` Shawn O. Pearce
2007-10-01 22:53 ` Carl Worth
2007-10-01 23:11 ` Junio C Hamano
2007-10-02 10:00 ` Johannes Schindelin
2007-10-02 10:29 ` Tom Clarke
2007-10-02 18:40 ` Junio C Hamano
2007-10-03 14:11 ` Tom Clarke
2007-10-03 15:54 ` Johannes Schindelin
2007-10-01 23:09 ` J. Bruce Fields
2007-10-01 22:28 ` Junio C Hamano
[not found] <11885023904126-git-send-email-tom@u2i.com>
2007-08-30 19:36 ` Tom Clarke
2007-08-30 19:53 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11912513203420-git-send-email-tom@u2i.com \
--to=tom@u2i.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.