Thread (17 messages) flat view 17 messages, 7 authors, 2016-06-15
DORMANTno replies

[PATCH 3/3] rebase: refuse to rebase with -s ours

From: Thomas Rast <hidden>
Date: 2016-06-15 22:47:43
Subsystem: documentation, the rest · Maintainers: Jonathan Corbet, Linus Torvalds

Possibly related (same subject, not in this thread)

Using the "ours" strategy with rebase just discards all changes,
turning <branch> into <upstream> (or <newbase> if given).  This is
unlikely to be what the user wants, so simply refuse to do it.

Also document what would happen near the -s option, and point the user
at it with the error message.

Signed-off-by: Thomas Rast <redacted>
---
 Documentation/git-rebase.txt |    3 ++-
 git-rebase--interactive.sh   |    4 ++++
 git-rebase.sh                |    4 ++++
 3 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 5fa9100..2203e63 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -241,7 +241,8 @@ rebased series, starting with <upstream>.
 +
 Due to the peculiarities of 'git-rebase' (see \--merge above), using
 the 'ours' strategy simply discards all patches from the <branch>,
-which makes little sense.
+which makes little sense.  Thus 'git-rebase' does not accept this
+strategy.
 
 -q::
 --quiet::
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 53ad248..c6bc156 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -584,6 +584,10 @@ first and then run 'git rebase --continue' again."
 			STRATEGY="-s $2"
 			shift ;;
 		esac
+		if test "$STRATEGY" = "-s ours"
+		then
+			die "Refusing to rebase with 'ours' strategy; see git help rebase."
+		fi
 		;;
 	-m)
 		# we use merge anyway
diff --git a/git-rebase.sh b/git-rebase.sh
index 6ec155c..2d7d566 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -306,6 +306,10 @@ do
 			strategy="$2"
 			shift ;;
 		esac
+		if test $strategy = ours
+		then
+			die "Refusing to rebase with 'ours' strategy; see git help rebase."
+		fi
 		do_merge=t
 		;;
 	-n|--no-stat)
-- 
1.6.5.2.420.gf6c057.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help