From: Steffen Prohaska <prohaska@zib.de>
To: git@vger.kernel.org
Cc: Steffen Prohaska <prohaska@zib.de>
Subject: [PATCH] transplant: move a series of commits to a different parent
Date: Sat, 23 Jun 2007 21:27:57 +0200 [thread overview]
Message-ID: <11826268772950-git-send-email-prohaska@zib.de> (raw)
In-Reply-To: <1BD13366-B4BD-4630-9046-49567A345CBC@zib.de>
git-transplant.sh <onto> <from> <to>
transplant starts with the contents of <onto> and puts on top of
it the contents of files if they are touched by the series of
commits <from>..<to>. If a commit touches a file the content of
this file is taken as it is in the commit. No merging is
performed. Original authors, commiters, and commit messages are
preserved.
Warning: this is just a quick hack to solve _my_ problem.
- No error checking is performed.
- Removal of files is not handled.
- Whitespace in filename is not handled.
- The index is left in dirty state.
- No branch is created for the result.
- The script is not integrated with git's shell utilities.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
git-transplant.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
create mode 100755 git-transplant.sh
This script seems to solved the problem for me. I can place
the topic branch imported from cvs to the right place.
What do you think? Is this a sane way to handle the situation?
Steffen
diff --git a/git-transplant.sh b/git-transplant.sh
new file mode 100755
index 0000000..3320071
--- /dev/null
+++ b/git-transplant.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+[[ $# == 3 ]] || { echo "$0 <onto> <from> <to>"; exit 1; }
+onto=$(git-rev-parse $1)
+from=$(git-rev-parse $2)
+to=$(git-rev-parse $3)
+
+# copied from git-filter-branch.sh
+set_ident () {
+ lid="$(echo "$1" | tr "A-Z" "a-z")"
+ uid="$(echo "$1" | tr "a-z" "A-Z")"
+ pick_id_script='
+ /^'$lid' /{
+ s/'\''/'\''\\'\'\''/g
+ h
+ s/^'$lid' \([^<]*\) <[^>]*> .*$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/export GIT_'$uid'_NAME='\''&'\''/p
+
+ g
+ s/^'$lid' [^<]* <\([^>]*\)> .*$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/export GIT_'$uid'_EMAIL='\''&'\''/p
+
+ g
+ s/^'$lid' [^<]* <[^>]*> \(.*\)$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/export GIT_'$uid'_DATE='\''&'\''/p
+
+ q
+ }
+ '
+
+ LANG=C LC_ALL=C sed -ne "$pick_id_script"
+ # Ensure non-empty id name.
+ echo "[ -n \"\$GIT_${uid}_NAME\" ] || export GIT_${uid}_NAME=\"\${GIT_${uid}_EMAIL%%@*}\""
+}
+
+parent=$onto
+git-read-tree --reset $parent
+
+for commit in $(git-rev-list --reverse $from..$to)
+do
+ echo "rewriting commit $commit..."
+ git-diff-tree -r $commit | grep ^: | cut -b 9-15,57-97,100- |
+ while read mode sha path
+ do
+ echo " $mode $sha $path"
+ git-update-index --add --cacheinfo $mode $sha $path
+ done
+
+ eval "$(git-cat-file commit $commit |set_ident AUTHOR)"
+ eval "$(git-cat-file commit $commit |set_ident COMMITTER)"
+
+ parent=$(git-cat-file commit $commit | sed -e '1,/^$/d' | git-commit-tree $(git-write-tree) -p $parent)
+ echo "... new commit $parent"
+done
+
+echo ""
+echo "new head is $parent"
--
1.5.2.2.315.gc649a
next prev parent reply other threads:[~2007-06-23 19:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-23 12:51 [PATCH] cvsimport: test case for severe branch import problem Steffen Prohaska
2007-06-23 13:26 ` Steffen Prohaska
2007-06-23 19:27 ` Steffen Prohaska [this message]
2007-06-23 20:54 ` [PATCH] transplant: move a series of commits to a different parent Johannes Schindelin
2007-06-24 6:55 ` Steffen Prohaska
2007-06-23 21:04 ` Alex Riesen
2007-06-24 7:08 ` Steffen Prohaska
2007-06-24 8:20 ` Alex Riesen
2007-06-24 10:26 ` Johannes Schindelin
2007-06-24 10:45 ` Steffen Prohaska
2007-06-25 7:16 ` Johannes Sixt
2007-06-25 7:49 ` Steffen Prohaska
2007-06-25 8:03 ` Johannes Sixt
2007-06-24 8:29 ` Alex Riesen
2007-06-24 9:05 ` Steffen Prohaska
2007-06-24 9:30 ` Alex Riesen
2007-06-24 17:13 ` Steffen Prohaska
2007-06-24 18:35 ` Alex Riesen
2007-06-24 20:54 ` Steffen Prohaska
2007-06-24 22:20 ` Alex Riesen
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=11826268772950-git-send-email-prohaska@zib.de \
--to=prohaska@zib.de \
--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).