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

[PATCH 1/2] rebase--am: use --cherry-pick instead of --ignore-if-in-upstream

From
John Keeping <john@keeping.me.uk>
Date
Jul 15, 2014, 19:14 UTC
Message-ID
<47e67c62fb2a8c8846f5d3a12d71aebf8fa875d7.1405451643.git.john@keeping.me.uk>
In-Reply-To
<20140707211456.GA2322@serenity.lan>

When using `git format-patch --ignore-if-in-upstream` we are only allowed to give a single revision range. In the next commit we will want to add an additional exclusion revision in order to handle fork points correctly, so convert `git-rebase--am` to use a symmetric difference with `--cherry-pick --right-only`.

This does not change the result of the format-patch invocation, just how we spell the arguments.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 git-rebase--am.sh | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index ca20e1e..902bf2d 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -29,7 +29,13 @@ skip)
 	;;
 esac
 
-test -n "$rebase_root" && root_flag=--root
+if test -z "$rebase_root"
+	# this is now equivalent to ! -z "$upstream"
+then
+	revisions=$upstream...$orig_head
+else
+	revisions=$onto...$orig_head
+fi
 
 ret=0
 if test -n "$keep_empty"
@@ -38,14 +44,15 @@ then
 	# empty commits and even if it didn't the format doesn't really lend
 	# itself well to recording empty patches.  fortunately, cherry-pick
 	# makes this easy
-	git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty "$revisions"
+	git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
+		--right-only "$revisions"
 	ret=$?
 else
 	rm -f "$GIT_DIR/rebased-patches"
 
-	git format-patch -k --stdout --full-index --ignore-if-in-upstream \
+	git format-patch -k --stdout --full-index --cherry-pick --right-only \
 		--src-prefix=a/ --dst-prefix=b/ --no-renames --no-cover-letter \
-		$root_flag "$revisions" >"$GIT_DIR/rebased-patches"
+		"$revisions" >"$GIT_DIR/rebased-patches"
 	ret=$?
 
 	if test 0 != $ret
-- 
2.0.1.472.g6f92e5f.dirty
Previous: John KeepingNext: John Keeping
Message 6 of 15 in “[BUG] rebase no longer omits local commits”
  1. Ted FelixJul 3, 2014
  2. John KeepingJul 3, 2014
  3. John KeepingJul 3, 2014
  4. Junio C HamanoJul 7, 2014
  5. John KeepingJul 7, 2014
  6. 1/2 rebase--am: use --cherry-pick instead of --ignore-if-in-upstreamJohn Keeping, Jul 15, 2014
  7. 2/2 rebase: omit patch-identical commits with --fork-pointJohn Keeping, Jul 15, 2014
  8. Ted FelixJul 15, 2014
  9. Junio C HamanoJul 15, 2014
  10. 1/2 rebase--am: use --cherry-pick instead of --ignore-if-in-upstreamJohn Keeping, Jul 16, 2014
  11. 2/2 rebase: omit patch-identical commits with --fork-pointJohn Keeping, Jul 16, 2014
  12. Junio C HamanoJul 16, 2014
  13. John KeepingJul 16, 2014
  14. Ted FelixJul 16, 2014
  15. John KeepingJul 17, 2014

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.