All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org
Cc: Jay Soffian <jaysoffian@gmail.com>,
	Thomas Rast <trast@student.ethz.ch>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 1/3] send-email: allow send-email to run outside a repo
Date: Sat, 14 Feb 2009 23:32:13 -0500	[thread overview]
Message-ID: <1234672335-54321-2-git-send-email-jaysoffian@gmail.com> (raw)
In-Reply-To: <1234672335-54321-1-git-send-email-jaysoffian@gmail.com>

send-email is supposed to be able to run from outside a repo. This
ability was broken by commits caf0c3d6 (make the message file name more
specific) and 5df9fcf6 (interpret unknown files as revision lists).

This commit provides a fix for both.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
Junio,

I think you have this one applied already, but I don't currently in next
nor pu, so I rebased it on next. I also put it first in the series per
your request.

j.

 git-send-email.perl |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 77ca8fe..9dad100 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -23,7 +23,7 @@ use Getopt::Long;
 use Text::ParseWords;
 use Data::Dumper;
 use Term::ANSIColor;
-use File::Temp qw/ tempdir /;
+use File::Temp qw/ tempdir tempfile /;
 use Error qw(:try);
 use Git;
 
@@ -156,7 +156,10 @@ if ($@) {
 # Behavior modification variables
 my ($quiet, $dry_run) = (0, 0);
 my $format_patch;
-my $compose_filename = $repo->repo_path() . "/.gitsendemail.msg.$$";
+my $compose_filename = ($repo ?
+	tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) :
+	tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1];
+
 
 # Handle interactive edition of files.
 my $multiedit;
@@ -267,6 +270,9 @@ unless ($rc) {
     usage();
 }
 
+die "Cannot run git format-patch from outside a repository\n"
+	if $format_patch and not $repo;
+
 # Now, let's fill any that aren't set in with defaults:
 
 sub read_config {
@@ -404,6 +410,7 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
 
 # returns 1 if the conflict must be solved using it as a format-patch argument
 sub check_file_rev_conflict($) {
+	return unless $repo;
 	my $f = shift;
 	try {
 		$repo->command('rev-parse', '--verify', '--quiet', $f);
@@ -445,6 +452,8 @@ while (defined(my $f = shift @ARGV)) {
 }
 
 if (@rev_list_opts) {
+	die "Cannot run git format-patch from outside a repository\n"
+		unless $repo;
 	push @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);
 }
 
-- 
1.6.2.rc0.251.g344d

  reply	other threads:[~2009-02-15  4:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-15  4:32 [PATCH v2 0/3] send-email Jay Soffian
2009-02-15  4:32 ` Jay Soffian [this message]
2009-02-15  4:32   ` [PATCH v2 2/3] send-email: handle multiple Cc addresses when reading mbox message Jay Soffian
2009-02-15  4:32     ` [PATCH v2 3/3] send-email: --suppress-cc improvements Jay Soffian
2009-02-15  5:07     ` [PATCH v2 2/3] send-email: handle multiple Cc addresses when reading mbox message Greg KH

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=1234672335-54321-2-git-send-email-jaysoffian@gmail.com \
    --to=jaysoffian@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=trast@student.ethz.ch \
    /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.