From: "Jörg Sommer" <joerg@alea.gnuu.de>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Johannes.Schindelin@gmx.de,
"Jörg Sommer" <joerg@alea.gnuu.de>
Subject: [PATCH v2 13/13] Add option --preserve-tags
Date: Mon, 14 Apr 2008 02:21:09 +0200 [thread overview]
Message-ID: <1208132469-26471-13-git-send-email-joerg@alea.gnuu.de> (raw)
In-Reply-To: <1208132469-26471-12-git-send-email-joerg@alea.gnuu.de>
With this new option tags set on commits, they are part of a rebase, are
reset to the rebased commits. This way the tags on a branch are kept
across rebases.
Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>
---
Documentation/git-rebase.txt | 6 ++++-
git-rebase--interactive.sh | 42 ++++++++++++++++++++++++++++++++++++++--
t/t3404-rebase-interactive.sh | 10 +++++++++
3 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 9ebbb90..cc4e94f 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -11,7 +11,8 @@ SYNOPSIS
'git-rebase' [-i | --interactive] [-v | --verbose] [-m | --merge]
[-s <strategy> | --strategy=<strategy>]
[-C<n>] [ --whitespace=<option>] [-p | --preserve-merges]
- [-f | --first-parent] [--onto <newbase>] <upstream> [<branch>]
+ [-f | --first-parent] [-t | --preserve-tags]
+ [--onto <newbase>] <upstream> [<branch>]
'git-rebase' --continue | --skip | --abort
DESCRIPTION
@@ -252,6 +253,9 @@ OPTIONS
showing all commits from the merged branches show only the
commits and merges following the first parent of each commit.
+-t, \--preserve-tags::
+ If one of the commits has a tag, reset it to the new commit object.
+
include::merge-strategies.txt[]
NOTES
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index c601655..e874c31 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -11,7 +11,7 @@
# http://article.gmane.org/gmane.comp.version-control.git/22407
USAGE='(--continue | --abort | --skip | [--preserve-merges] [--first-parent]
- [--verbose] [--onto <branch>] <upstream> [<branch>])'
+ [--preserve-tags] [--verbose] [--onto <branch>] <upstream> [<branch>])'
OPTIONS_SPEC=
. git-sh-setup
@@ -397,9 +397,31 @@ insert_value_at_key_into_list () {
create_extended_todo_list () {
(
+ if test t = "${PRESERVE_TAGS:-}"
+ then
+ tag_list=$(git show-ref --abbrev=7 --tags | \
+ (
+ while read sha1 tag
+ do
+ tag=${tag#refs/tags/}
+ if test ${last_sha1:-0000} = $sha1
+ then
+ saved_tags="$saved_tags:$tag"
+ else
+ printf "%s" "${last_sha1:+ $last_sha1#$saved_tags}"
+ last_sha1=$sha1
+ saved_tags=$tag
+ fi
+ done
+ echo "${last_sha1:+ $last_sha1:$saved_tags}"
+ ) )
+ else
+ tag_list=
+ fi
while IFS=_ read commit parents subject
do
- if test "${last_parent:-$commit}" != "$commit"
+ if test t = "$PRESERVE_MERGES" -a \
+ "${last_parent:-$commit}" != "$commit"
then
if test t = "${delayed_mark:-f}"
then
@@ -416,6 +438,14 @@ create_extended_todo_list () {
get_value_from_list $commit "${marked_commits:-}" \
>/dev/null && echo mark
+ if tmp=$(get_value_from_list $commit "$tag_list")
+ then
+ for t in $(echo $tmp | tr : ' ')
+ do
+ echo tag $t
+ done
+ fi
+
case "$parents" in
*' '*)
delayed_mark=t
@@ -575,6 +605,9 @@ do
FIRST_PARENT=t
PRESERVE_MERGES=t
;;
+ -t|--preserve-tags)
+ PRESERVE_TAGS=t
+ ;;
-i|--interactive)
# yeah, we know
;;
@@ -631,11 +664,14 @@ do
SHORTONTO=$(git rev-parse --short=7 $ONTO)
common_rev_list_opts="--abbrev-commit --abbrev=7
--left-right --cherry-pick $UPSTREAM...$HEAD"
- if test t = "$PRESERVE_MERGES" -o t = "${FIRST_PARENT:-f}"
+ if test t = "$PRESERVE_MERGES" -o t = "${FIRST_PARENT:-f}" \
+ -o t = "${PRESERVE_TAGS:-}"
then
opts=
test t = "${FIRST_PARENT:-f}" && \
opts="$opts --first-parent"
+ test t != "$PRESERVE_MERGES" && \
+ opts="$opts --no-merges"
git rev-list --pretty='format:%h_%p_%s' --topo-order \
$opts $common_rev_list_opts | \
grep -v ^commit | \
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 9901555..d20ed4f 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -319,6 +319,16 @@ test_expect_success 'tag sets tags' '
"$(git rev-parse HEAD^2~2 HEAD~2 HEAD~1 HEAD~1)"
'
+test_expect_success 'interactive -t preserves tags' '
+ git rebase -i -p -t --onto dead-end master &&
+ test "$(git rev-parse bb-tag1 bb-tag2 bb-tag3a bb-tag3b)" = \
+ "$(git rev-parse HEAD^2~2 HEAD~2 HEAD~1 HEAD~1)" &&
+ head=$(git rev-parse HEAD) &&
+ git rebase -i -t dead-end &&
+ test "$(git rev-parse bb-tag1 bb-tag2 bb-tag3a bb-tag3b)" = \
+ "$(git rev-parse HEAD~7 $head~2 HEAD~1 HEAD~1)"
+'
+
test_expect_success '--continue tries to commit' '
git checkout to-be-rebased &&
test_tick &&
--
1.5.5
next prev parent reply other threads:[~2008-04-14 0:52 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-23 21:42 [PATCH 1/4] Move redo merge code in a function Jörg Sommer
2008-03-23 21:42 ` [PATCH 2/4] Rework redo_merge Jörg Sommer
2008-03-23 21:42 ` [PATCH 3/4] Add a function for get the parents of a commit Jörg Sommer
2008-03-23 21:42 ` [PATCH 4/4] git-rebase -i: New option to support rebase with merges Jörg Sommer
2008-03-23 22:41 ` Johannes Schindelin
2008-03-24 11:14 ` Jörg Sommer
2008-03-24 13:08 ` Johannes Schindelin
2008-03-24 23:40 ` Jörg Sommer
2008-03-24 18:35 ` Junio C Hamano
2008-03-24 23:30 ` Junio C Hamano
2008-03-25 10:13 ` Jörg Sommer
2008-03-26 8:02 ` Junio C Hamano
2008-04-09 23:58 ` Teach rebase interactive more commands to do better preserve merges Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 01/10] Teach rebase interactive the mark command Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 02/10] Teach rebase interactive the reset command Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 03/10] Teach rebase interactive the merge command Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 04/10] Move redo merge code in a function Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 05/10] Rework redo_merge Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 06/10] Unify the lenght of $SHORT* and the commits in the TODO list Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 07/10] fake-editor: output TODO list if unchanged Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 08/10] Don't append default merge message to -m message Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 09/10] Select all lines with fake-editor Jörg Sommer
2008-04-09 23:58 ` [PATCH/RFC 10/10] Do rebase with preserve merges with advanced TODO list Jörg Sommer
2008-04-12 0:00 ` [PATCH/RFC 06/10] Unify the lenght of $SHORT* and the commits in the " Junio C Hamano
2008-04-12 9:13 ` Jörg Sommer
2008-04-13 6:20 ` Junio C Hamano
2008-04-13 16:39 ` Jörg Sommer
2008-04-14 1:06 ` Tarmigan
2008-04-11 23:56 ` [PATCH/RFC 02/10] Teach rebase interactive the reset command Junio C Hamano
2008-04-12 9:37 ` Jörg Sommer
2008-04-10 9:33 ` [PATCH/RFC 01/10] Teach rebase interactive the mark command Mike Ralphson
2008-04-12 10:17 ` Jörg Sommer
2008-04-11 23:48 ` Junio C Hamano
2008-04-12 10:11 ` Jörg Sommer
2008-04-13 3:56 ` Shawn O. Pearce
2008-04-13 16:50 ` Jörg Sommer
2008-04-14 6:24 ` Shawn O. Pearce
2008-04-14 6:54 ` Junio C Hamano
2008-04-14 10:06 ` Jörg Sommer
2008-04-14 0:20 ` [PATCH v2 01/13] fake-editor: output TODO list if unchanged Jörg Sommer
2008-04-14 0:20 ` [PATCH v2 02/13] Don't append default merge message to -m message Jörg Sommer
2008-04-14 0:20 ` [PATCH v2 03/13] Move cleanup code into it's own function Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 04/13] Teach rebase interactive the mark command Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 05/13] Teach rebase interactive the reset command Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 06/13] Move redo merge code in a function Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 07/13] Teach rebase interactive the merge command Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 08/13] Unify the lenght of $SHORT* and the commits in the TODO list Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 09/13] Select all lines with fake-editor Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 10/13] Do rebase with preserve merges with advanced TODO list Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 11/13] Add option --first-parent Jörg Sommer
2008-04-14 0:21 ` [PATCH v2 12/13] Teach rebase interactive the tag command Jörg Sommer
2008-04-14 0:21 ` Jörg Sommer [this message]
2008-04-22 5:32 ` [PATCH v2 04/13] Teach rebase interactive the mark command Junio C Hamano
2008-04-22 8:13 ` Junio C Hamano
2008-04-22 8:52 ` Johannes Schindelin
2008-04-22 9:55 ` Jörg Sommer
2008-04-22 10:31 ` Johannes Schindelin
2008-04-22 16:56 ` Junio C Hamano
2008-04-22 17:12 ` Johannes Schindelin
2008-04-29 0:25 ` Junio C Hamano
2008-04-29 0:39 ` Johannes Schindelin
2008-04-29 5:17 ` Junio C Hamano
2008-04-29 7:12 ` Johannes Sixt
2008-04-29 10:52 ` Johannes Schindelin
2008-04-29 21:16 ` Junio C Hamano
2008-04-29 21:25 ` Johannes Schindelin
2008-04-29 22:23 ` Junio C Hamano
2008-04-29 22:55 ` Johannes Schindelin
2008-04-29 23:06 ` Junio C Hamano
2008-04-29 23:31 ` Johannes Schindelin
2008-04-30 1:23 ` Junio C Hamano
2008-04-30 6:25 ` Johannes Sixt
2008-04-30 7:10 ` Junio C Hamano
2008-04-30 8:47 ` Johannes Schindelin
2008-04-30 9:19 ` Junio C Hamano
2008-04-30 10:29 ` Johannes Sixt
2008-04-30 11:56 ` Johannes Schindelin
2008-05-01 19:04 ` Junio C Hamano
2008-05-03 12:45 ` Johannes Schindelin
2008-05-03 17:09 ` Junio C Hamano
2008-05-04 9:38 ` Johannes Schindelin
2008-05-04 12:52 ` Jörg Sommer
2008-04-30 13:06 ` Dmitry Potapov
2008-05-01 12:59 ` Johannes Schindelin
2008-04-22 18:04 ` Junio C Hamano
2008-04-25 9:11 ` Jörg Sommer
2008-04-25 9:44 ` [PATCH v2.2] " Jörg Sommer
2008-04-27 6:13 ` Junio C Hamano
2008-04-27 8:28 ` Jörg Sommer
2008-04-14 10:39 ` [PATCH v2.1] " Jörg Sommer
2008-04-14 23:29 ` Shawn O. Pearce
2008-04-20 23:44 ` mark parsing in fast-import Jörg Sommer
2008-04-21 0:26 ` Shawn O. Pearce
2008-04-21 8:41 ` Jörg Sommer
2008-04-21 23:59 ` Shawn O. Pearce
2008-04-22 9:39 ` Jörg Sommer
2008-04-22 23:15 ` Shawn O. Pearce
2008-04-25 9:04 ` [PATCH v2] Make mark parsing much more restrictive Jörg Sommer
2008-04-20 16:52 ` [PATCH v2 02/13] Don't append default merge message to -m message Junio C Hamano
2008-04-21 0:17 ` Jörg Sommer
2008-04-22 5:27 ` Junio C Hamano
2008-03-23 22:33 ` [PATCH 3/4] Add a function for get the parents of a commit Johannes Schindelin
2008-03-23 22:29 ` [PATCH 2/4] Rework redo_merge Johannes Schindelin
2008-03-23 22:26 ` [PATCH 1/4] Move redo merge code in a function Johannes Schindelin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1208132469-26471-13-git-send-email-joerg@alea.gnuu.de \
--to=joerg@alea.gnuu.de \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).