From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org, "David Kågedal" <davidk@lysator.liu.se>
Subject: [StGit PATCH 2/5] Treat filename '-' as stdin/stdout in edit
Date: Fri, 14 Dec 2007 07:25:09 +0100 [thread overview]
Message-ID: <20071214062509.29148.23933.stgit@yoghurt> (raw)
In-Reply-To: <20071214062251.29148.86191.stgit@yoghurt>
From: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
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.
next prev parent reply other threads:[~2007-12-14 6:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 6:24 [StGit PATCH 0/5] Various odds and ends Karl Hasselström
2007-12-14 6:25 ` [StGit PATCH 1/5] Added --save-template flag to edit command Karl Hasselström
2007-12-14 6:25 ` Karl Hasselström [this message]
2007-12-14 6:25 ` [StGit PATCH 3/5] Let parse_patch take a string instead of a file parameter Karl Hasselström
2007-12-14 6:25 ` [StGit PATCH 4/5] Make generic --message/--file/--save-template flags Karl Hasselström
2007-12-14 6:44 ` Karl Hasselström
2007-12-14 6:25 ` [StGit PATCH 5/5] Name the exit codes to improve legibility Karl Hasselström
2007-12-14 6:45 ` 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=20071214062509.29148.23933.stgit@yoghurt \
--to=kha@treskal.com \
--cc=catalin.marinas@gmail.com \
--cc=davidk@lysator.liu.se \
--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.