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

[PATCH v4 7/7] rebase -i: use new --ff cherry-pick option

From
Christian Couder <chriscool@tuxfamily.org>
Date
Mar 6, 2010, 20:34 UTC
Message-ID
<20100306203447.2960.47050.chriscool@tuxfamily.org>
In-Reply-To
<20100306203250.2960.30309.chriscool@tuxfamily.org>
This simplifies rebase -i a little bit.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 git-rebase--interactive.sh |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 3e4fd14..92d19f5 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -222,8 +222,8 @@ do_with_author () {
 }
 
 pick_one () {
-	no_ff=
-	case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac
+	ff=--ff
+	case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
 	output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
 	test -d "$REWRITTEN" &&
 		pick_one_preserving_merges "$@" && return
@@ -232,16 +232,7 @@ pick_one () {
 		output git cherry-pick "$@"
 		return
 	fi
-	parent_sha1=$(git rev-parse --verify $sha1^) ||
-		die "Could not get the parent of $sha1"
-	current_sha1=$(git rev-parse --verify HEAD)
-	if test -z "$no_ff" && test "$current_sha1" = "$parent_sha1"
-	then
-		output git reset --hard $sha1
-		output warn Fast-forward to $(git rev-parse --short $sha1)
-	else
-		output git cherry-pick "$@"
-	fi
+	output git cherry-pick $ff "$@"
 }
 
 pick_one_preserving_merges () {
-- 
1.7.0.1.307.g861f4
Previous: Christian Couder
Message 12 of 12 in “add --ff option to cherry-pick”
  1. 0/7 add --ff option to cherry-pickChristian Couder, Mar 6, 2010
  2. 1/7 parse-options: add parse_options_concat() to concat optionsChristian Couder, Mar 6, 2010
  3. 2/7 builtin/merge: make checkout_fast_forward() non staticChristian Couder, Mar 6, 2010
  4. 3/7 revert: add --ff option to allow fast forward when cherry-pickingChristian Couder, Mar 6, 2010
  5. Junio C HamanoMar 7, 2010
  6. Paolo BonziniMar 7, 2010
  7. Junio C HamanoMar 7, 2010
  8. Christian CouderMar 7, 2010
  9. 4/7 cherry-pick: add tests for new --ff optionChristian Couder, Mar 6, 2010
  10. 5/7 Documentation: describe new cherry-pick --ff optionChristian Couder, Mar 6, 2010
  11. 6/7 cherry-pick: add a no-op --no-ff option to future proof scriptsChristian Couder, Mar 6, 2010
  12. 7/7 rebase -i: use new --ff cherry-pick optionChristian Couder, Mar 6, 2010

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.