From: Clark Williams <clark.williams@gmail.com>
To: git@vger.kernel.org
Subject: [StGit PATCH] add option to import series directly from a tar archive
Date: Sat, 06 Sep 2008 22:47:19 -0500 [thread overview]
Message-ID: <48C34EC7.9040102@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 679 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Catalin/Karl,
Attached is my first cut at adding the ability to import a patch series by specifying
the tarball. For example, the following command:
$ stg import --tarfile patch-2.6.26.3-rt6.bz2
will apply the latest -rt patch series to your current kernel tree.
No Karl, I haven't developed a test for it (yet). I wanted to see what you guys
thought first :)
Clark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAkjDTscACgkQqA4JVb61b9dNRgCZAW+tOCgz5Y+A0IdomcOA4X7v
u8MAnRvFWMXRJ0Kxv1rAnBRnheq6Iidi
=W7Dl
-----END PGP SIGNATURE-----
[-- Attachment #2: tarfiles.patch --]
[-- Type: text/plain, Size: 2562 bytes --]
patch to allow importing a series from a tar archive
From: Clark Williams <williams@redhat.com>
Signed-off-by: Clark Williams <williams@redhat.com>
---
stgit/commands/imprt.py | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index 227743f..0e9bb73 100644
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -87,7 +87,10 @@ options = [make_option('-m', '--mail',
make_option('--commname',
help = 'use COMMNAME as the committer name'),
make_option('--commemail',
- help = 'use COMMEMAIL as the committer e-mail')
+ help = 'use COMMEMAIL as the committer e-mail'),
+ make_option('--tarfile',
+ help = 'import a series from a tar archive',
+ action = "store_true"),
] + make_sign_options()
@@ -287,6 +290,45 @@ def __import_url(url, options):
urllib.urlretrieve(url, filename)
__import_file(filename, options)
+def __import_tarfile(tar, options):
+ """Import patch series from a tar archive
+ """
+ import tarfile
+ import tempfile
+
+ if not tarfile.is_tarfile(tar):
+ raise CmdException, "%s is not a tarfile!" % tar
+
+
+ t = tarfile.open(tar, 'r')
+ names = t.getnames()
+
+ # verify paths in the tarfile are safe
+ for n in names:
+ if n.startswith('/'):
+ raise CmdException, "Absolute path found in %s" % tar
+ if n.startswith("../"):
+ raise CmdException, "Relative path found in %s" % tar
+
+ # find the series file
+ seriesfile = '';
+ for m in names:
+ if m.endswith('/series') or m == 'series':
+ seriesfile = m
+ break
+ if seriesfile == '':
+ raise CmdException, "no series file found in %s" % tar
+
+ # unpack into a tmp dir
+ tmpdir = tempfile.mkdtemp('.stg')
+ t.extractall(tmpdir)
+
+ # apply the series
+ __import_series(os.path.join(tmpdir, seriesfile), options)
+
+ # cleanup the tmpdir
+ os.system('rm -rf %s' % tmpdir)
+
def func(parser, options, args):
"""Import a GNU diff file as a new patch
"""
@@ -308,6 +350,8 @@ def func(parser, options, args):
__import_mbox(filename, options)
elif options.url:
__import_url(filename, options)
+ elif options.tarfile:
+ __import_tarfile(filename, options)
else:
__import_file(filename, options)
next reply other threads:[~2008-09-07 3:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-07 3:47 Clark Williams [this message]
2008-09-08 18:03 ` [StGit PATCH] add option to import series directly from a tar archive Karl Hasselström
2008-09-08 18:11 ` Clark Williams
2008-09-08 21:22 ` Karl Hasselström
2008-09-12 12:21 ` Samuel Tardieu
2008-09-12 12:57 ` Clark Williams
2008-09-12 13:59 ` Samuel Tardieu
2008-09-12 15:44 ` Karl Hasselström
2008-09-12 13:07 ` Karl Hasselström
2008-09-12 13:08 ` Karl Hasselström
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=48C34EC7.9040102@gmail.com \
--to=clark.williams@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.