git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH - stgit] Patch to allow import of compressed files

From
CWClark Williams <clark.williams@gmail.com>
Date
Jun 9, 2008, 18:38 UTC
Message-ID
<484D78BF.6030504@gmail.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This patch allows StGit to directly import compressed (.gz and .bz2) files with reasonable patch names.

I do a lot of work on modified kernel trees and usually the first two things imported are a stable update patch followed immediately by an -rt patch, both of which are compressed. With this patch I can just copy the files down directly from kernel.org and import them, rather than having to keep uncompressed copies around.

Hey, I'm lazy... :)
Clark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkhNeL4ACgkQqA4JVb61b9cu0ACdH/Z71xh4gaD5euF3BgYnIhiO AkUAnipyN/dsTBQDyhc6uzFhxdxPeYvJ =2G71 -----END PGP SIGNATURE-----

From: Clark Williams <williams@redhat.com>
Patch to allow import from compressed (.gz and .bz2) files
Signed-off-by: Clark Williams <williams@redhat.com>
---
 stgit/commands/imprt.py |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index 4a4b792..83dae2f 100644
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -178,8 +178,22 @@ def __create_patch(filename, message, author_name, author_email,
 def __import_file(filename, options, patch = None):
     """Import a patch from a file or standard input
     """
+    if patch:
+        pname = patch
+    else:
+        pname = filename
+
     if filename:
-        f = file(filename)
+        if filename.endswith(".gz"):
+            import gzip
+            f = gzip.open(filename)
+            pname = filename.replace(".gz", "")
+        elif filename.endswith(".bz2"):
+            import bz2
+            f = bz2.BZ2File(filename, 'r')
+            pname = filename.replace(".bz2", "")
+        else:
+            f = file(filename)
     else:
         f = sys.stdin
 
@@ -197,11 +211,6 @@ def __import_file(filename, options, patch = None):
     if filename:
         f.close()
 
-    if patch:
-        pname = patch
-    else:
-        pname = filename
-
     __create_patch(pname, message, author_name, author_email,
                    author_date, diff, options)
 
Next: Karl Hasselström
Message 1 of 18 in “Patch to allow import of compressed files”
  1. Patch to allow import of compressed filesClark Williams, Jun 9, 2008
  2. Karl HasselströmJun 10, 2008
  3. Asheesh LaroiaJun 10, 2008
  4. Sverre RabbelierJun 10, 2008
  5. Karl HasselströmJun 10, 2008
  6. Sverre RabbelierJun 10, 2008
  7. Karl HasselströmJun 10, 2008
  8. Sverre RabbelierJun 10, 2008
  9. Clark WilliamsJun 10, 2008
  10. Clark WilliamsJun 10, 2008
  11. Clark WilliamsJun 10, 2008
  12. Asheesh LaroiaJun 10, 2008
  13. Clark WilliamsJun 10, 2008
  14. Clark WilliamsJun 10, 2008
  15. Karl HasselströmJun 11, 2008
  16. Clark WilliamsJun 11, 2008
  17. Karl HasselströmJun 11, 2008
  18. David KågedalJun 19, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.