git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: aneesh.kumar@gmail.com
To: pasky@suse.cz
Cc: git@vger.kernel.org, "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>
Subject: (unknown)
Subject: 
Date: Wed, 13 Aug 2008 20:24:28 +0530	[thread overview]
Message-ID: <1218639268-12267-1-git-send-email-aneesh.kumar@gmail.com> (raw)

From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>

topgit: Implement tg-import

This can be used to import a set of commits
between range specified by range1..range2
This should help us to convert an already
existing quilt, stgit branches to topgit
managed one

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>

---
 Makefile     |    2 +-
 README       |    7 ++++++
 tg-create.sh |   22 ++++++++----------
 tg-export.sh |    2 +-
 tg-import.sh |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 87 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index 6eade1e..95624ac 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ sharedir = $(PREFIX)/share/topgit
 hooksdir = $(cmddir)/hooks
 
 
-commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh
+commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh tg-import.sh
 hooks_in = hooks/pre-commit.sh
 
 commands_out = $(patsubst %.sh,%,$(commands_in))
diff --git a/README b/README
index b58a1b4..8b8f4d7 100644
--- a/README
+++ b/README
@@ -330,6 +330,13 @@ tg export
 	TODO: Make stripping of [PATCH] and other prefixes configurable
 	TODO: --mbox option for other mode of operation
 
+tg import
+~~~~~~~~
+	Import the commits between the given revision range into
+	a topgit managed branch
+
+	Usage: tg import rev1..rev2
+
 tg update
 ~~~~~~~~~
 	Update the current topic branch wrt. changes in the branches
diff --git a/tg-create.sh b/tg-create.sh
index 939af33..6cce7ed 100644
--- a/tg-create.sh
+++ b/tg-create.sh
@@ -31,17 +31,18 @@ done
 
 deps="${deps# }"
 if [ -z "$deps" ]; then
-	if [ -z "$name" -a -s "$git_dir/top-name" -a -s "$git_dir/top-deps" -a -s "$git_dir/top-merge" ]; then
-		# We are setting up the base branch now; resume merge!
-		name="$(cat "$git_dir/top-name")"
+	head="$(git symbolic-ref HEAD)"
+	bname="${head#refs/top-bases/}"
+	if [ "$bname" != "$head" -a -s "$git_dir/top-deps" -a -s "$git_dir/top-merge" ]; then
+		# We are on a base branch now; resume merge!
 		deps="$(cat "$git_dir/top-deps")"
 		merge="$(cat "$git_dir/top-merge")"
+		name="$bname"
 		restarted=1
 		info "Resuming $name setup..."
 	else
 		# The common case
 		[ -z "$name" ] && die "no branch name given"
-		head="$(git symbolic-ref HEAD)"
 		deps="${head#refs/heads/}"
 		[ "$deps" != "$head" ] || die "refusing to auto-depend on non-head ref ($head)"
 		info "Automatically marking dependency on $deps"
@@ -58,7 +59,7 @@ done
 	die "branch '$name' already exists"
 
 # Clean up any stale stuff
-rm -f "$git_dir/top-name" "$git_dir/top-deps" "$git_dir/top-merge"
+rm -f "$git_dir/top-deps" "$git_dir/top-merge"
 
 
 ## Create base
@@ -68,8 +69,7 @@ if [ -n "$merge" ]; then
 	branch="${merge%% *}"
 	merge="${merge#* }"
 	info "Creating $name base from $branch..."
-	# We create a detached head so that we can abort this operation
-	git checkout -q "$(git rev-parse "$branch")"
+	switch_to_base "$name" "$branch"
 fi
 
 
@@ -83,10 +83,9 @@ while [ -n "$merge" ]; do
 
 	if ! git merge "$branch"; then
 		info "Please commit merge resolution and call: tg create"
-		info "It is also safe to abort this operation using:"
-		info "git reset --hard some_branch"
-		info "(You are on a detached HEAD now.)"
-		echo "$name" >"$git_dir/top-name"
+		info "It is also safe to abort this operation using \`git reset --hard\`"
+		info "but please remember you are on the base branch now;"
+		info "you will want to switch to a different branch."
 		echo "$deps" >"$git_dir/top-deps"
 		echo "$merge" >"$git_dir/top-merge"
 		exit 2
@@ -96,7 +95,6 @@ done
 
 ## Set up the topic branch
 
-git update-ref "refs/top-bases/$name" "HEAD" ""
 git checkout -b "$name"
 
 echo "$deps" | sed 's/ /\n/g' >"$root_dir/.topdeps"
diff --git a/tg-export.sh b/tg-export.sh
index 62361dd..73ad2ef 100644
--- a/tg-export.sh
+++ b/tg-export.sh
@@ -190,7 +190,7 @@ recurse_deps driver "$name"
 
 
 if [ "$driver" = "collapse" ]; then
-	git update-ref "refs/heads/$output" "$(cat "$playground/$name")" ""
+	git update-ref "refs/heads/$output" "$(cat "$playground/$name")"
 
 	depcount="$(cat "$playground/^ticker" | wc -l)"
 	echo "Exported topic branch $name (total $depcount topics) to branch $output"
diff --git a/tg-import.sh b/tg-import.sh
new file mode 100644
index 0000000..6c991c5
--- /dev/null
+++ b/tg-import.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# GPLv2
+
+
+tg_get_commit_msg()
+{
+	commit="$1"
+	git log -1 --pretty=format:"From: %an <%ae>%n%n%s%n%n%b" "$commit"
+}
+
+tg_get_branch_name()
+{
+	# nice sed script from git-format-patch.sh
+	commit="$1"
+	titleScript='
+	s/[^-a-z.A-Z_0-9]/-/g
+        s/\.\.\.*/\./g
+	s/\.*$//
+	s/--*/-/g
+	s/^-//
+	s/-$//
+	q
+'
+	git log -1 --pretty=format:"%s" "$commit" | sed -e "$titleScript"
+}
+
+tg_process_commit()
+{
+	commit="$1"
+	branch_name=$(tg_get_branch_name "$commit")
+	echo "Importing $commit to $branch_name"
+	tg create tp/"$branch_name"
+	git read-tree "$commit"
+	tg_get_commit_msg "$commit" > .topmsg
+	git add -f .topmsg .topdeps
+	git commit -C "$commit"
+}
+
+# nice arg verification stolen from git-format-patch.sh
+for revpair
+do
+	case "$revpair" in
+	?*..?*)
+		rev1=`expr "z$revpair" : 'z\(.*\)\.\.'`
+		rev2=`expr "z$revpair" : 'z.*\.\.\(.*\)'`
+		;;
+	*)
+		die "Unknow range spec $revpair"
+		;;
+	esac
+	git rev-parse --verify "$rev1^0" >/dev/null 2>&1 ||
+		die "Not a valid rev $rev1 ($revpair)"
+	git rev-parse --verify "$rev2^0" >/dev/null 2>&1 ||
+		die "Not a valid rev $rev2 ($revpair)"
+	git cherry -v "$rev1" "$rev2" |
+	while read sign rev comment
+	do
+		case "$sign" in
+		'-')
+			info "Merged already: $comment"
+			;;
+		*)
+			tg_process_commit "$rev"
+			;;
+		esac
+	done
+done
-- 
tg: (f27e693..) tp/topgit-Implement-tg-import (depends on: master)

             reply	other threads:[~2008-08-13 14:55 UTC|newest]

Thread overview: 162+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-13 14:54 aneesh.kumar [this message]
2008-08-13 15:16 ` your mail Aneesh Kumar K.V
  -- strict thread matches above, loose matches on Subject: below --
2016-06-16  3:54 (unknown) 岸洋介
2016-06-12  9:38 (unknown), Financial Service
2016-06-07 14:01 [PATCH v3 0/6] send-email: cleaner tests and quote email Tom Russello
2016-06-08 13:01 ` (unknown), Samuel GROOT
2016-05-16 15:58 (unknown), Nathan Wendt
2016-04-11 19:04 (unknown), miwilliams
2016-04-11 16:02 (unknown) Michael S. Tsirkin
2016-03-28 13:38 (unknown), ratheesh kannoth
2015-12-16  3:02 (unknown), David Greene
2015-12-16  5:57 ` (unknown) Junio C Hamano
2015-12-16  8:44   ` (unknown) Patrick Steinhardt
2015-12-18 17:35     ` (unknown) David Greene
2015-12-14 13:14 (unknown) Ros Sothen
2015-11-06  3:34 (unknown), David Greene
2015-09-28 17:55 (unknown), Kosta Zertsekel
2015-09-19 10:58 (unknown), 戸島達哉
2015-09-01  2:13 (unknown), David Turner
2015-08-05 12:47 (unknown) Ivan Chernyavsky
2015-05-12 12:38 (unknown), Varis Van Rob
2015-05-11 17:56 (unknown), dturner
2015-04-08 20:44 (unknown), Mamta Upadhyay
2015-03-13  1:34 (unknown) cody.taylor
2015-02-25  8:53 (unknown) stefan leijen
2015-02-17 18:14 [PATCH] read-cache.c: free cache entry when refreshing fails Junio C Hamano
2015-02-17 18:27 ` (unknown), Stefan Beller
2015-01-12 20:59 (unknown), امير الاحزان
2014-10-30 12:23 (unknown), Fedor Eftimitsa
2014-09-28 10:51 (unknown) bambecapuno06
2014-09-08 11:36 (unknown), R. Klomp
2014-08-26 11:16 (unknown), mail
2014-07-15 16:31 (unknown), Woody Wu
2014-06-17 17:13 (unknown), David Turner
2014-06-01 21:24 (unknown), C. Benson Manica
2014-05-22 22:35 (unknown), Mrs. Jiang Ming
2014-04-19 14:27 (unknown), Siegel, Suzan
2014-03-19  0:45 (unknown) szager
2014-03-05  8:43 (unknown) Stephanie Bennett
2014-02-20  0:55 (unknown) Bozhidar Bozhev
2013-12-18 14:09 (unknown) Maxime Coste
2013-08-07 12:54 (unknown), a a
2013-05-25  3:57 (unknown), Kirill Berezin
2013-05-20  9:58 [PATCH 0/6] t5000: add test for pax extended header generation René Scharfe
2013-05-20  9:58 ` [PATCH 6/6] t5000: test long filenames René Scharfe
2013-05-20 19:55   ` Eric Sunshine
     [not found]     ` <CAPig+cTitT9Z+2pxeNh3dXi4b7X738qpkUnEmTi2yvQoCPtHqA@mail.g mail.com>
2013-05-20 20:01       ` (unknown), Marty Landman
2013-05-17 18:02 (unknown), ASHISH VERMA
2012-12-28 16:43 (unknown) Eric S. Raymond
2012-12-28 19:33 ` (unknown) Junio C Hamano
2012-10-17 12:16 (unknown), Marco Siegl | buerosiegl.com
2012-06-12 21:12 (unknown), rohit sood
2012-05-06 14:17 (unknown), Bruce Zu
2012-05-06 14:13 (unknown), Bruce Zu
2012-05-06 13:54 (unknown), Bruce Zu
2012-03-13 12:18 (unknown), Adam Kicak
2012-02-15  3:12 (unknown), Chris Leong
2012-02-09 23:58 (unknown), Zbigniew Jędrzejewski-Szmek
2012-02-08  0:41 (unknown), mstormo
2012-02-05 20:41 [PATCH] Change include order in two compat/ files to avoid compiler warning Junio C Hamano
2012-02-05 22:32 ` (unknown), Ben Walton
2012-01-10 23:56 (unknown), Steven Line
2011-11-10 22:56 (unknown), Marcel Schaible
2011-11-02 16:38 (unknown), Ben Walton
2011-08-18  6:36 (unknown) milki
2011-08-04 17:27 (unknown) Hin-Tak Leung
2011-05-26  9:02 (unknown) Nicole Hamilt
2011-02-02 17:31 (unknown), Kamol Siesan
2010-12-28 22:56 (unknown), COCA COLA
2010-12-27  6:07 (unknown), COCA COLA
2010-09-20 16:37 (unknown), Leonid Podolny
2010-09-17 18:39 (unknown), Michael Scholl
2010-05-07 21:46 (unknown), Mr Chen Guan
2010-05-07 21:46 (unknown), Mr Chen Guan
2010-05-07 21:46 (unknown), Mr Chen Guan
2010-03-25  5:53 (unknown) выгнать 
2010-03-19 21:12 (unknown), Michael Cox
2010-03-08 21:56 (unknown) Timur Aydin
2010-02-25  5:55 (unknown), yingshou guo
2010-01-22  2:14 (unknown), Horst H. von Brand
2009-09-12 13:00 (unknown) Tito
2009-07-24 21:21 [PATCH 0/2] Section renaming can lose content Alex Vandiver
2009-07-24 21:21 ` [PATCH 1/2] Make section_name_match start on '[', and return the length on success Alex Vandiver
2009-07-24 21:21   ` [PATCH 2/2] After renaming a section, print any trailing variable definitions Alex Vandiver
2009-07-24 22:11     ` Nanako Shiraishi
2009-07-24 23:39       ` Junio C Hamano
2009-07-25  0:28         ` (unknown), Nanako Shiraishi
2009-07-16 19:22 (unknown) Henrik Austad
2009-06-23  1:07 (unknown) Larry D'Anna
2009-05-27 13:28 (unknown), David Forman
2009-05-13  5:11 (unknown), Tom H
2009-05-11 18:57 (unknown) Don Slutz
2009-05-11 18:57 (unknown) Don Slutz
2009-05-11 18:57 (unknown) Don Slutz
2009-05-11 18:57 (unknown) Don Slutz
2009-05-11 18:57 (unknown) Don Slutz
2009-05-11 18:57 (unknown) Don Slutz
2009-05-11 18:57 (unknown) Don Slutz
2009-05-10 22:48 [JGIT PATCH 1/2] Fix deadlock in native git protocol client for upload-pack Shawn O. Pearce
2009-05-10 22:48 ` [JGIT PATCH 2/2] Decrease the fetch pack client buffer to the lower minimum Shawn O. Pearce
2009-05-11  0:43   ` Junio C Hamano
2009-05-11  0:55     ` Shawn O. Pearce
2009-05-11  3:51       ` Junio C Hamano
2009-05-11 14:10         ` Shawn O. Pearce
2009-05-11 14:23           ` (unknown), Carl Mercier
2009-05-07 17:01 (unknown), Bevan Watkiss
2009-04-16 23:17 (unknown), Fawad Hassan Ismail
2009-03-30  5:03 (unknown), David Aguilar
2009-03-27 20:39 (unknown), Lachlan Deck
2009-03-16 19:06 undoing something John Dlugosz
2009-03-16 19:14 ` Junio C Hamano
2009-03-16 19:48   ` John Dlugosz
2009-03-16 21:45     ` (unknown), Nanako Shiraishi
2009-03-13  8:21 (unknown) Werner Riener
2009-02-06  9:45 (unknown), info
2009-02-06  9:43 (unknown), info
2009-01-09 19:02 (unknown) nathan.panike
2008-10-05 23:36 (unknown), Robin Rosenberg
2008-08-21 19:15 (unknown) bpeeluk
2008-06-23 20:54 (unknown), VIP Casino Club
2008-06-16 20:02 (unknown) amery
2008-06-16 19:42 (unknown) amery
2008-05-10 22:32 (unknown), Krzysztof Kowalczyk
2008-01-20 21:59 (unknown), Marc-André Lureau
2007-12-05 19:00 [PATCH 0/6] builtin-remote Johannes Schindelin
2007-12-05 19:00 ` (unknown) Johannes Schindelin
2007-11-26 20:00 (unknown) Michael Dressel
2007-11-11 13:08 (unknown) Michael Dressel
2007-11-01 20:44 (unknown), Francesco Pretto
2007-11-01 14:23 (unknown) Heikki Orsila
2007-10-22 18:16 (unknown) racin
2007-10-13  4:01 (unknown), Michael Witten
2007-09-04 13:59 (unknown) Russ Brown
2007-08-19 22:04 (unknown) Luciano Rocha
2007-07-01 18:25 (unknown) Sean D'Epagnier
2007-06-13  0:50 [PATCH] Interpret :/<pattern> as a regular expression Johannes Schindelin
2007-06-13  4:52 ` Junio C Hamano
2007-06-13 11:17   ` (unknown) Johannes Schindelin
2007-06-03 15:30 (unknown) Randal L. Schwartz
2007-05-06  3:51 (unknown), Aaron Gray
2007-04-04 16:59 (unknown) Geert Bosch
2007-03-18  9:36 [wishlist] git branch -d -r remotename Sam Vilain
2007-03-18 11:01 ` Sam Vilain
2007-03-18 11:01   ` Sam Vilain
2007-03-18 19:42     ` Junio C Hamano
2007-03-18 21:46       ` Sam Vilain
2007-03-19  6:18         ` Junio C Hamano
2007-03-19  6:40           ` Junio C Hamano
2007-03-19 23:37             ` (unknown) Sam Vilain
2006-11-21 22:24 (unknown) Johannes Schindelin
2006-10-25 14:50 (unknown) andyparkins
2006-10-25 14:49 (unknown) andyparkins
2006-10-25 18:41 ` (unknown) Junio C Hamano
2006-10-25 14:49 (unknown) andyparkins
2006-10-25 14:47 (unknown) andyparkins
2006-10-25 14:53 ` (unknown) Jakub Narebski
2006-10-25 15:10   ` (unknown) Andy Parkins
2006-10-25 15:31     ` (unknown) Karl Hasselström
2006-10-25 18:38     ` (unknown) Junio C Hamano
2006-10-25 22:03       ` (unknown) Andy Parkins
2006-10-25 22:16         ` (unknown) Junio C Hamano
2006-10-25 22:20           ` (unknown) Junio C Hamano
2006-10-26  7:14             ` (unknown) Andy Parkins
2006-10-26 13:22             ` (unknown) Josef Weidendorfer
2006-10-26 15:35               ` (unknown) Linus Torvalds
2006-10-25 22:16         ` (unknown) Shawn Pearce
2006-10-20 14:24 (unknown) andyparkins
2006-10-20 14:24 (unknown) andyparkins
2006-10-20 14:21 (unknown) andyparkins
2006-10-20 13:25 (unknown) andyparkins
2006-10-05  1:54 (unknown), JOSEPH KULIG
2006-09-24 21:55 (unknown) sonny132390
2006-09-21  4:04 (unknown) Nicolas Pitre
2006-09-09 21:46 (unknown), Rajkumar S
2006-08-18 10:35 (unknown), Wolfgang Denk
2006-07-01 15:33 (unknown), Mark
2006-05-26 15:16 (unknown) Juergen Ruehle
2006-05-21 23:53 (unknown) J. Bruce Fields
2006-05-21 23:53 ` (unknown) J. Bruce Fields
2006-05-21 23:53   ` (unknown) J. Bruce Fields
2006-03-28 19:31 (unknown) CustomerDepartament
2006-01-30 18:50 (unknown) Mark Wooding
2005-10-05  6:10 (unknown), Willem Swart
2005-07-23  9:10 (unknown) Junio Hamano
2005-05-28 14:15 (unknown) Thomas Glanzmann
2005-04-26 19:14 (unknown) Bram Cohen
2005-04-22 22:19 (unknown), atani
2005-04-18 22:45 (unknown), Matt W.
2005-04-16  0:51 (unknown) Scott Wright
2005-04-14 22:47 (unknown) Timo Hirvonen
2005-04-14 22:43 (unknown) Timo Hirvonen
2005-04-14 22:30 (unknown), Timo Hirvonen

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=1218639268-12267-1-git-send-email-aneesh.kumar@gmail.com \
    --to=aneesh.kumar@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pasky@suse.cz \
    /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).