[StGit PATCH 2/5] Treat filename '-' as stdin/stdout in edit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: David Kågedal <davidk@xxxxxxxxxxxxxx>

Signed-off-by: David Kågedal <davidk@xxxxxxxxxxxxxx>
Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx>

---

 stgit/commands/edit.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)


diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py
index ec2c4ae..4d1475f 100644
--- a/stgit/commands/edit.py
+++ b/stgit/commands/edit.py
@@ -96,7 +96,10 @@ def __update_patch(pname, fname, options):
     bottom = patch.get_bottom()
     top = patch.get_top()
 
-    f = open(fname)
+    if fname == '-':
+        f = sys.stdin
+    else:
+        f = open(fname)
     message, author_name, author_email, author_date, diff = parse_patch(f)
     f.close()
 
@@ -171,9 +174,12 @@ def __generate_file(pname, fname, options):
     text = tmpl % tmpl_dict
 
     # write the file to be edited
-    f = open(fname, 'w+')
-    f.write(text)
-    f.close()
+    if fname == '-':
+        sys.stdout.write(text)
+    else:
+        f = open(fname, 'w+')
+        f.write(text)
+        f.close()
 
 def __edit_update_patch(pname, options):
     """Edit the given patch interactively.

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux