git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/3] Document and refuse rebase -s ours

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 15, 2009, 21:04 UTC
Message-ID
<7veinzfqj9.fsf@alter.siamese.dyndns.org>
In-Reply-To
<cover.1258309432.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
> I also implemented Nicolas's suggestion to reject -s ours outright;
> I'm not really happy with starting a blacklist there, but maybe it
> helps the next unwary user.

I am inclined to agree with you and Nicolas on this, but I'll let the list decide if [3/3] is a good idea.

I'd rewrite [3/3] in the following way to keep it easier to maintain the blacklist, like this.

            case "$1" in
    -       ours)
    +       ours | theirs | octopus | subtree)
                    die "Refusing to rebase with $1; see git help rebase."
            esac

It would also make it easier to turn this into a whitelist if we choose to,

 git-rebase--interactive.sh |    5 +----
 git-rebase.sh              |    5 +----
 git-sh-setup.sh            |    7 +++++++
 3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 53d35f3..de7448b 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -571,10 +571,7 @@ 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
+		git_check_merge_strategy_used_in_rebase "${STRATEGY#-s }"
 		;;
 	-m)
 		# we use merge anyway
diff --git a/git-rebase.sh b/git-rebase.sh
index 2d7d566..dd9ec63 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -306,10 +306,7 @@ do
 			strategy="$2"
 			shift ;;
 		esac
-		if test $strategy = ours
-		then
-			die "Refusing to rebase with 'ours' strategy; see git help rebase."
-		fi
+		git_check_merge_strategy_used_in_rebase "$strategy"
 		do_merge=t
 		;;
 	-n|--no-stat)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index c41c2f7..724955f 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -199,3 +199,10 @@ case $(uname -s) in
 	}
 	;;
 esac
+
+git_check_merge_strategy_used_in_rebase () {
+	case "$1" in
+	ours)
+		die "Refusing to rebase with $1; see git help rebase."
+	esac
+}
Previous: A Large Angry SCMNext: Thomas Rast
Message 35 of 38 in “git pull --rebase and losing commits”
  1. Peter KreftingNov 2, 2009
  2. Thomas RastNov 2, 2009
  3. Nanako ShiraishiNov 2, 2009
  4. Björn SteinbrinkNov 2, 2009
  5. Peter KreftingNov 3, 2009
  6. Johannes SchindelinNov 3, 2009
  7. Peter KreftingNov 3, 2009
  8. Clarify documentation on the "ours" merge strategy.Peter Krefting, Nov 11, 2009
  9. BazNov 11, 2009
  10. Thomas RastNov 11, 2009
  11. BazNov 11, 2009
  12. Junio C HamanoNov 11, 2009
  13. Re: Clarify documentation on the "ours" merge strategy.Nicolas Sebrecht, Nov 11, 2009
  14. Thomas RastNov 11, 2009
  15. Junio C HamanoNov 12, 2009
  16. Peter KreftingNov 12, 2009
  17. Nanako ShiraishiNov 14, 2009
  18. Junio C HamanoNov 15, 2009
  19. Peter KreftingNov 16, 2009
  20. Björn SteinbrinkNov 12, 2009
  21. 0/3 Document and refuse rebase -s oursThomas Rast, Nov 15, 2009
  22. 1/3 Documentation: clarify 'ours' merge strategyThomas Rast, Nov 15, 2009
  23. 2/3 rebase docs: clarify --merge and --strategyThomas Rast, Nov 15, 2009
  24. Junio C HamanoNov 15, 2009
  25. Thomas RastNov 15, 2009
  26. 3/3 rebase: refuse to rebase with -s oursThomas Rast, Nov 15, 2009
  27. Sverre RabbelierNov 15, 2009
  28. Thomas RastNov 15, 2009
  29. Johannes SchindelinNov 16, 2009
  30. Junio C HamanoNov 16, 2009
  31. Johannes SchindelinNov 16, 2009
  32. Junio C HamanoNov 16, 2009
  33. Sverre RabbelierNov 16, 2009
  34. A Large Angry SCMNov 16, 2009
  35. Junio C HamanoNov 15, 2009
  36. Thomas RastNov 15, 2009
  37. Thomas RastNov 3, 2009
  38. Randal L. SchwartzNov 3, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.