mirror of
https://github.com/git/git.git
synced 2024-11-28 04:23:30 +08:00
send-email: allow send-email to run outside a repo
send-email is supposed to be able to run from outside a repo. This ability was broken by commitscaf0c3d6
(make the message file name more specific) and5df9fcf6
(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>
This commit is contained in:
parent
e9cc02f0e4
commit
eed6ca7c40
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user