|
23 | 23 | use Text::ParseWords;
|
24 | 24 | use Data::Dumper;
|
25 | 25 | use Term::ANSIColor;
|
26 |
| -use File::Temp qw/ tempdir /; |
| 26 | +use File::Temp qw/ tempdir tempfile /; |
27 | 27 | use Error qw(:try);
|
28 | 28 | use Git;
|
29 | 29 |
|
@@ -156,7 +156,10 @@ sub format_2822_time {
|
156 | 156 | # Behavior modification variables
|
157 | 157 | my ($quiet, $dry_run) = (0, 0);
|
158 | 158 | my $format_patch;
|
159 |
| -my $compose_filename = $repo->repo_path() . "/.gitsendemail.msg.$$"; |
| 159 | +my $compose_filename = ($repo ? |
| 160 | + tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) : |
| 161 | + tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1]; |
| 162 | + |
160 | 163 |
|
161 | 164 | # Handle interactive edition of files.
|
162 | 165 | my $multiedit;
|
@@ -267,6 +270,9 @@ sub signal_handler {
|
267 | 270 | usage();
|
268 | 271 | }
|
269 | 272 |
|
| 273 | +die "Cannot run git format-patch from outside a repository\n" |
| 274 | + if $format_patch and not $repo; |
| 275 | + |
270 | 276 | # Now, let's fill any that aren't set in with defaults:
|
271 | 277 |
|
272 | 278 | sub read_config {
|
@@ -404,6 +410,7 @@ sub split_addrs {
|
404 | 410 |
|
405 | 411 | # returns 1 if the conflict must be solved using it as a format-patch argument
|
406 | 412 | sub check_file_rev_conflict($) {
|
| 413 | + return unless $repo; |
407 | 414 | my $f = shift;
|
408 | 415 | try {
|
409 | 416 | $repo->command('rev-parse', '--verify', '--quiet', $f);
|
|
445 | 452 | }
|
446 | 453 |
|
447 | 454 | if (@rev_list_opts) {
|
| 455 | + die "Cannot run git format-patch from outside a repository\n" |
| 456 | + unless $repo; |
448 | 457 | push @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);
|
449 | 458 | }
|
450 | 459 |
|
|
0 commit comments