From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org
Cc: Jay Soffian <jaysoffian@gmail.com>
Subject: [RFC/PATCH] rebase: add -x option to record original commit name
Date: Fri, 5 Feb 2010 20:19:26 -0500 [thread overview]
Message-ID: <1265419166-21388-1-git-send-email-jaysoffian@gmail.com> (raw)
It is often more convenient to use rebase --onto than cherry-pick when
relocating a range of commits, as cherry-pick only supports a single commit at a
time.
This commit teaches rebase the "-x" to record the original commit name, in the
same way as cherry-pick's "-x" option.
---
Note that I explictly did not add support for anything but the simple
format-patch + am codepath. I think it's unlikely to want to record the
original commit name in cases where "-m/-p" are needed.
However, this option might be useful when using "--interactive", but I wanted
to get feedback first as rebase--interactive is a little scarier to patch. :-)
Thoughts?
Documentation/git-rebase.txt | 5 +++++
git-am.sh | 14 ++++++++++++++
git-rebase.sh | 9 +++++++++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 823f2a4..2fb0e96 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -315,6 +315,11 @@ which makes little sense.
so that the commit marked for squashing comes right after the
commit to be modified, and change the action of the moved
commit from `pick` to `squash` (or `fixup`).
+
+-x::
+ Append to the original commit message a note that indicates which commit
+ this change originated from, similar to cherry-pick's -x option. This
+ option is not compatible with -m, -p or --interactive.
+
This option is only valid when '--interactive' option is used.
diff --git a/git-am.sh b/git-am.sh
index c8b9cbb..83805eb 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -31,6 +31,7 @@ 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
+add-commit-name* (internal use for git-rebase)
rebasing* (internal use for git-rebase)"
. git-sh-setup
@@ -296,6 +297,7 @@ git_apply_opt=
committer_date_is_author_date=
ignore_date=
allow_rerere_autoupdate=
+add_commit_name=
while test $# != 0
do
@@ -347,6 +349,8 @@ do
allow_rerere_autoupdate="$1" ;;
-q|--quiet)
GIT_QUIET=t ;;
+ --add-commit-name)
+ add_commit_name=t ;;
--)
shift; break ;;
*)
@@ -454,6 +458,7 @@ else
echo "$keep" >"$dotest/keep"
echo "$scissors" >"$dotest/scissors"
echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
+ echo "$add_commit_name" > "$dotest/add_commit_name"
echo "$GIT_QUIET" >"$dotest/quiet"
echo 1 >"$dotest/next"
if test -n "$rebasing"
@@ -507,6 +512,10 @@ then
else
no_inbody_headers=
fi
+if test "$(cat "$dotest/add_commit_name")" = t
+then
+ add_commit_name=t
+fi
if test "$(cat "$dotest/quiet")" = t
then
GIT_QUIET=t
@@ -630,6 +639,11 @@ do
then
echo "$ADD_SIGNOFF"
fi
+ if test "$add_commit_name" = t
+ then
+ test -z "$commit" && die "Internal error: expecting a commit name."
+ echo "(cherry picked from commit $commit)"
+ fi
} >"$dotest/final-commit"
;;
*)
diff --git a/git-rebase.sh b/git-rebase.sh
index fb4fef7..511599e 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -53,6 +53,7 @@ git_am_opt=
rebase_root=
force_rebase=
allow_rerere_autoupdate=
+add_commit_name=
continue_merge () {
test -n "$prev_head" || die "prev_head must be defined"
@@ -353,6 +354,10 @@ do
--rerere-autoupdate|--no-rerere-autoupdate)
allow_rerere_autoupdate="$1"
;;
+ -x)
+ git_am_opt="$git_am_opt --add-commit-name"
+ add_commit_name=t
+ ;;
-*)
usage
;;
@@ -386,6 +391,10 @@ else
die "previous rebase directory $dotest still exists." \
'Try git rebase (--continue | --abort | --skip)'
fi
+ if test -n "$add_commit_name"
+ then
+ die "-x not compatible with --merge"
+ fi
fi
# The tree must be really really clean.
--
1.7.0.rc1.200.g9c1f9
next reply other threads:[~2010-02-06 1:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-06 1:19 Jay Soffian [this message]
2010-02-06 1:35 ` [RFC/PATCH] rebase: add -x option to record original commit name Junio C Hamano
2010-02-06 1:58 ` Jay Soffian
2010-02-06 2:00 ` Jay Soffian
2010-02-06 2:57 ` Junio C Hamano
2010-02-06 4:18 ` Jay Soffian
2010-02-06 4:43 ` Junio C Hamano
2010-02-06 5:19 ` Jay Soffian
2010-02-06 13:32 ` tytso
2010-02-06 17:47 ` Junio C Hamano
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=1265419166-21388-1-git-send-email-jaysoffian@gmail.com \
--to=jaysoffian@gmail.com \
--cc=git@vger.kernel.org \
/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).