git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
To: git@vger.kernel.org
Cc: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>
Subject: [PATCH 1/7] git-rebase--am.sh: avoid special-casing --keep-empty
Date: Wed, 18 Jul 2012 00:27:29 -0700	[thread overview]
Message-ID: <1342596455-17046-2-git-send-email-martin.von.zweigbergk@gmail.com> (raw)
In-Reply-To: <1342596455-17046-1-git-send-email-martin.von.zweigbergk@gmail.com>

Since 0fbb95d (am: don't call mailinfo if $rebasing, 2012-06-26), the
patch body to apply when running 'git am --rebasing' is not taken from
the mbox, but directly from the commit. If such a commit is "empty",
'git am --rebasing' still happily applies it and commits. However,
since the input to 'git am --rebasing' only ever comes from 'git
format-patch', which completely leaves the commit out from its output
if it's empty, no empty commits are ever created by 'git am
--rebasing'. By teaching 'git am --rebasing' a --keep-empty option and
letting the caller decide whether or not to keep empty commits, we can
unify the two different mechanisms that git-rebase--am.sh uses for
rebasing.
---
 git-am.sh         | 10 +++++++++-
 git-rebase--am.sh | 20 ++++++--------------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index b6a5300..37641b7 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -37,7 +37,8 @@ abort           restore the original branch and abort the patching operation.
 committer-date-is-author-date    lie about committer date
 ignore-date     use current timestamp for author date
 rerere-autoupdate update the index with reused conflict resolution if possible
-rebasing*       (internal use for git-rebase)"
+rebasing*       (internal use for git-rebase)
+keep-empty*     (internal use for git-rebase)"
 
 . git-sh-setup
 . git-sh-i18n
@@ -375,6 +376,7 @@ git_apply_opt=
 committer_date_is_author_date=
 ignore_date=
 allow_rerere_autoupdate=
+keep_empty=
 
 if test "$(git config --bool --get am.keepcr)" = true
 then
@@ -414,6 +416,8 @@ do
 		abort=t ;;
 	--rebasing)
 		rebasing=t threeway=t ;;
+	--keep-empty)
+		keep_empty=t ;;
 	-d|--dotest)
 		die "$(gettext "-d option is no longer supported.  Do not use.")"
 		;;
@@ -669,6 +673,10 @@ do
 			echo "$commit" >"$dotest/original-commit"
 			get_author_ident_from_commit "$commit" >"$dotest/author-script"
 			git diff-tree --root --binary "$commit" >"$dotest/patch"
+			test -s "$dotest/patch" || test -n "$keep_empty" || {
+				go_next
+				continue
+			}
 		else
 			git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
 				<"$dotest/$msgnum" >"$dotest/info" ||
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index 392ebc9..37c1b23 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -17,20 +17,12 @@ skip)
 esac
 
 test -n "$rebase_root" && root_flag=--root
-
-if test -n "$keep_empty"
-then
-	# we have to do this the hard way.  git format-patch completely squashes
-	# 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 --allow-empty "$revisions"
-else
-	git format-patch -k --stdout --full-index --ignore-if-in-upstream \
-		--src-prefix=a/ --dst-prefix=b/ \
-		--no-renames $root_flag "$revisions" |
-	git am $git_am_opt --rebasing --resolvemsg="$resolvemsg"
-fi && move_to_original_branch
+test -n "$keep_empty" && git_am_opt="$git_am_opt --keep-empty"
+git format-patch -k --stdout --full-index --ignore-if-in-upstream \
+	--src-prefix=a/ --dst-prefix=b/ \
+	--no-renames $root_flag "$revisions" |
+git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" &&
+move_to_original_branch
 
 ret=$?
 test 0 != $ret -a -d "$state_dir" && write_basic_state
-- 
1.7.11.1.104.ge7b44f1

  reply	other threads:[~2012-07-18  7:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18  7:27 [PATCH 0/7] correctly calculate patches to rebase Martin von Zweigbergk
2012-07-18  7:27 ` Martin von Zweigbergk [this message]
2012-07-18  7:27   ` [PATCH 2/7] git-rebase--interactive.sh: extract function for adding "pick" line Martin von Zweigbergk
2012-07-18  7:27     ` [PATCH 3/7] git-rebase--interactive: group all $preserve_merges code Martin von Zweigbergk
2012-07-18  7:27       ` [PATCH 4/7] git-rebase--interactive.sh: look up subject in add_pick_line Martin von Zweigbergk
2012-07-18  7:27         ` [PATCH 5/7] rebase -p: use --cherry-mark for todo file Martin von Zweigbergk
2012-07-18  7:27           ` [PATCH 6/7] rebase -p: don't request --left-right only to ignore left side Martin von Zweigbergk
2012-07-18  7:27             ` [PATCH 7/7] rebase (without -p): correctly calculate patches to rebase Martin von Zweigbergk
2012-07-20  8:18               ` Johannes Sixt
2012-07-20 15:58                 ` Martin von Zweigbergk
2012-07-20  8:14         ` [PATCH 4/7] git-rebase--interactive.sh: look up subject in add_pick_line Johannes Sixt
2012-07-20 15:47           ` Martin von Zweigbergk
2012-07-22 20:51             ` Junio C Hamano
2012-07-18 12:48     ` [PATCH 2/7] git-rebase--interactive.sh: extract function for adding "pick" line Neil Horman
2012-07-18  7:32 ` [PATCH 0/7] correctly calculate patches to rebase Martin von Zweigbergk

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=1342596455-17046-2-git-send-email-martin.von.zweigbergk@gmail.com \
    --to=martin.von.zweigbergk@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=nhorman@tuxdriver.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).