Skip to content

Commit

Permalink
send-email: allow send-email to run outside a repo
Browse files Browse the repository at this point in the history
send-email is supposed to be able to run from outside a repo. This
ability was broken by commits caf0c3d (make the message file name more
specific) and 5df9fcf (interpret unknown files as revision lists).

This commit provides a fix for both.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jay Soffian authored and Junio C Hamano committed Feb 15, 2009
1 parent e9cc02f commit eed6ca7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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;

Expand Down Expand Up @@ -156,7 +156,10 @@ sub format_2822_time {
# 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;
Expand Down Expand Up @@ -267,6 +270,9 @@ sub signal_handler {
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 {
Expand Down Expand Up @@ -404,6 +410,7 @@ sub split_addrs {

# 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);
Expand Down Expand Up @@ -445,6 +452,8 @@ ($)
}

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);
}

Expand Down

0 comments on commit eed6ca7

Please sign in to comment.