{"thread":{"id":"14983","subject":"(unknown)","startedAt":"2008-08-13T14:54:28Z","lastAt":"2008-08-13T15:16:13Z","messageCount":2,"participants":["aneesh.kumar@gmail.com","Aneesh Kumar K.V"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"87055","messageId":"1218639268-12267-1-git-send-email-aneesh.kumar@gmail.com","threadId":"14983","inReplyTo":null,"subject":"(unknown)","fromName":"","fromEmail":"aneesh.kumar@gmail.com","sentAt":"2008-08-13T14:54:28Z","receivedAt":"2008-08-13T14:54:28Z","isPatch":false,"sender":{"key":"aneesh.kumar@gmail.com","avatar":"https://gravatar.com/avatar/0621fc0b2f14ead1e9024382f16053a808c148596da30c1b92572fa075621f68?d=mp&s=160"},"body":"From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\n\ntopgit: Implement tg-import\n\nThis can be used to import a set of commits\nbetween range specified by range1..range2\nThis should help us to convert an already\nexisting quilt, stgit branches to topgit\nmanaged one\n\nSigned-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\n\n---\n Makefile     |    2 +-\n README       |    7 ++++++\n tg-create.sh |   22 ++++++++----------\n tg-export.sh |    2 +-\n tg-import.sh |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 5 files changed, 87 insertions(+), 14 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 6eade1e..95624ac 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -6,7 +6,7 @@ sharedir = $(PREFIX)/share/topgit\n hooksdir = $(cmddir)/hooks\n \n \n-commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh\n+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\n hooks_in = hooks/pre-commit.sh\n \n commands_out = $(patsubst %.sh,%,$(commands_in))\ndiff --git a/README b/README\nindex b58a1b4..8b8f4d7 100644\n--- a/README\n+++ b/README\n@@ -330,6 +330,13 @@ tg export\n \tTODO: Make stripping of [PATCH] and other prefixes configurable\n \tTODO: --mbox option for other mode of operation\n \n+tg import\n+~~~~~~~~\n+\tImport the commits between the given revision range into\n+\ta topgit managed branch\n+\n+\tUsage: tg import rev1..rev2\n+\n tg update\n ~~~~~~~~~\n \tUpdate the current topic branch wrt. changes in the branches\ndiff --git a/tg-create.sh b/tg-create.sh\nindex 939af33..6cce7ed 100644\n--- a/tg-create.sh\n+++ b/tg-create.sh\n@@ -31,17 +31,18 @@ done\n \n deps=\"${deps# }\"\n if [ -z \"$deps\" ]; then\n-\tif [ -z \"$name\" -a -s \"$git_dir/top-name\" -a -s \"$git_dir/top-deps\" -a -s \"$git_dir/top-merge\" ]; then\n-\t\t# We are setting up the base branch now; resume merge!\n-\t\tname=\"$(cat \"$git_dir/top-name\")\"\n+\thead=\"$(git symbolic-ref HEAD)\"\n+\tbname=\"${head#refs/top-bases/}\"\n+\tif [ \"$bname\" != \"$head\" -a -s \"$git_dir/top-deps\" -a -s \"$git_dir/top-merge\" ]; then\n+\t\t# We are on a base branch now; resume merge!\n \t\tdeps=\"$(cat \"$git_dir/top-deps\")\"\n \t\tmerge=\"$(cat \"$git_dir/top-merge\")\"\n+\t\tname=\"$bname\"\n \t\trestarted=1\n \t\tinfo \"Resuming $name setup...\"\n \telse\n \t\t# The common case\n \t\t[ -z \"$name\" ] && die \"no branch name given\"\n-\t\thead=\"$(git symbolic-ref HEAD)\"\n \t\tdeps=\"${head#refs/heads/}\"\n \t\t[ \"$deps\" != \"$head\" ] || die \"refusing to auto-depend on non-head ref ($head)\"\n \t\tinfo \"Automatically marking dependency on $deps\"\n@@ -58,7 +59,7 @@ done\n \tdie \"branch '$name' already exists\"\n \n # Clean up any stale stuff\n-rm -f \"$git_dir/top-name\" \"$git_dir/top-deps\" \"$git_dir/top-merge\"\n+rm -f \"$git_dir/top-deps\" \"$git_dir/top-merge\"\n \n \n ## Create base\n@@ -68,8 +69,7 @@ if [ -n \"$merge\" ]; then\n \tbranch=\"${merge%% *}\"\n \tmerge=\"${merge#* }\"\n \tinfo \"Creating $name base from $branch...\"\n-\t# We create a detached head so that we can abort this operation\n-\tgit checkout -q \"$(git rev-parse \"$branch\")\"\n+\tswitch_to_base \"$name\" \"$branch\"\n fi\n \n \n@@ -83,10 +83,9 @@ while [ -n \"$merge\" ]; do\n \n \tif ! git merge \"$branch\"; then\n \t\tinfo \"Please commit merge resolution and call: tg create\"\n-\t\tinfo \"It is also safe to abort this operation using:\"\n-\t\tinfo \"git reset --hard some_branch\"\n-\t\tinfo \"(You are on a detached HEAD now.)\"\n-\t\techo \"$name\" >\"$git_dir/top-name\"\n+\t\tinfo \"It is also safe to abort this operation using \\`git reset --hard\\`\"\n+\t\tinfo \"but please remember you are on the base branch now;\"\n+\t\tinfo \"you will want to switch to a different branch.\"\n \t\techo \"$deps\" >\"$git_dir/top-deps\"\n \t\techo \"$merge\" >\"$git_dir/top-merge\"\n \t\texit 2\n@@ -96,7 +95,6 @@ done\n \n ## Set up the topic branch\n \n-git update-ref \"refs/top-bases/$name\" \"HEAD\" \"\"\n git checkout -b \"$name\"\n \n echo \"$deps\" | sed 's/ /\\n/g' >\"$root_dir/.topdeps\"\ndiff --git a/tg-export.sh b/tg-export.sh\nindex 62361dd..73ad2ef 100644\n--- a/tg-export.sh\n+++ b/tg-export.sh\n@@ -190,7 +190,7 @@ recurse_deps driver \"$name\"\n \n \n if [ \"$driver\" = \"collapse\" ]; then\n-\tgit update-ref \"refs/heads/$output\" \"$(cat \"$playground/$name\")\" \"\"\n+\tgit update-ref \"refs/heads/$output\" \"$(cat \"$playground/$name\")\"\n \n \tdepcount=\"$(cat \"$playground/^ticker\" | wc -l)\"\n \techo \"Exported topic branch $name (total $depcount topics) to branch $output\"\ndiff --git a/tg-import.sh b/tg-import.sh\nnew file mode 100644\nindex 0000000..6c991c5\n--- /dev/null\n+++ b/tg-import.sh\n@@ -0,0 +1,68 @@\n+#!/bin/sh\n+# TopGit - A different patch queue manager\n+# GPLv2\n+\n+\n+tg_get_commit_msg()\n+{\n+\tcommit=\"$1\"\n+\tgit log -1 --pretty=format:\"From: %an <%ae>%n%n%s%n%n%b\" \"$commit\"\n+}\n+\n+tg_get_branch_name()\n+{\n+\t# nice sed script from git-format-patch.sh\n+\tcommit=\"$1\"\n+\ttitleScript='\n+\ts/[^-a-z.A-Z_0-9]/-/g\n+        s/\\.\\.\\.*/\\./g\n+\ts/\\.*$//\n+\ts/--*/-/g\n+\ts/^-//\n+\ts/-$//\n+\tq\n+'\n+\tgit log -1 --pretty=format:\"%s\" \"$commit\" | sed -e \"$titleScript\"\n+}\n+\n+tg_process_commit()\n+{\n+\tcommit=\"$1\"\n+\tbranch_name=$(tg_get_branch_name \"$commit\")\n+\techo \"Importing $commit to $branch_name\"\n+\ttg create tp/\"$branch_name\"\n+\tgit read-tree \"$commit\"\n+\ttg_get_commit_msg \"$commit\" > .topmsg\n+\tgit add -f .topmsg .topdeps\n+\tgit commit -C \"$commit\"\n+}\n+\n+# nice arg verification stolen from git-format-patch.sh\n+for revpair\n+do\n+\tcase \"$revpair\" in\n+\t?*..?*)\n+\t\trev1=`expr \"z$revpair\" : 'z\\(.*\\)\\.\\.'`\n+\t\trev2=`expr \"z$revpair\" : 'z.*\\.\\.\\(.*\\)'`\n+\t\t;;\n+\t*)\n+\t\tdie \"Unknow range spec $revpair\"\n+\t\t;;\n+\tesac\n+\tgit rev-parse --verify \"$rev1^0\" >/dev/null 2>&1 ||\n+\t\tdie \"Not a valid rev $rev1 ($revpair)\"\n+\tgit rev-parse --verify \"$rev2^0\" >/dev/null 2>&1 ||\n+\t\tdie \"Not a valid rev $rev2 ($revpair)\"\n+\tgit cherry -v \"$rev1\" \"$rev2\" |\n+\twhile read sign rev comment\n+\tdo\n+\t\tcase \"$sign\" in\n+\t\t'-')\n+\t\t\tinfo \"Merged already: $comment\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\ttg_process_commit \"$rev\"\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+done\n-- \ntg: (f27e693..) tp/topgit-Implement-tg-import (depends on: master)\n"},{"id":"87061","messageId":"20080813151613.GA6448@skywalker","threadId":"14983","inReplyTo":"1218639268-12267-1-git-send-email-aneesh.kumar@gmail.com","subject":"Re: your mail","fromName":"Aneesh Kumar K.V","fromEmail":"aneesh.kumar@linux.vnet.ibm.com","sentAt":"2008-08-13T15:16:13Z","receivedAt":"2008-08-13T15:16:13Z","isPatch":false,"sender":{"key":"aneesh.kumar@linux.vnet.ibm.com","avatar":"https://gravatar.com/avatar/a32cbcc7e70c8eb5a4cdbd1ea0b6c2ead382f2529cc43f51fd350767f079d92d?d=mp&s=160"},"body":"On Wed, Aug 13, 2008 at 08:24:28PM +0530, aneesh.kumar@gmail.com wrote:\n> From: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\n> \n> topgit: Implement tg-import\n> \n> This can be used to import a set of commits\n> between range specified by range1..range2\n> This should help us to convert an already\n> existing quilt, stgit branches to topgit\n> managed one\n> \n> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>\n> \n> ---\n>  Makefile     |    2 +-\n>  README       |    7 ++++++\n>  tg-create.sh |   22 ++++++++----------\n>  tg-export.sh |    2 +-\n>  tg-import.sh |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  5 files changed, 87 insertions(+), 14 deletions(-)\n> \n\ntg-create.sh and tg-export.sh should not be part of this patch. I will\nsend a new version.\n\n-aneesh\n"}]}