@@ -1156,7 +1156,7 @@ static void get_notes_args(struct strvec *arg, struct rev_info *rev)
1156
1156
}
1157
1157
}
1158
1158
1159
- static void make_cover_letter (struct rev_info * rev , int use_stdout ,
1159
+ static void make_cover_letter (struct rev_info * rev , int use_separate_file ,
1160
1160
struct commit * origin ,
1161
1161
int nr , struct commit * * list ,
1162
1162
const char * branch_name ,
@@ -1176,7 +1176,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
1176
1176
1177
1177
committer = git_committer_info (0 );
1178
1178
1179
- if (! use_stdout &&
1179
+ if (use_separate_file &&
1180
1180
open_next_file (NULL , rev -> numbered_files ? NULL : "cover-letter" , rev , quiet ))
1181
1181
die (_ ("failed to create cover-letter file" ));
1182
1182
@@ -1945,20 +1945,27 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1945
1945
if (rev .show_notes )
1946
1946
load_display_notes (& rev .notes_opt );
1947
1947
1948
- if (! output_directory && ! use_stdout )
1949
- output_directory = config_output_directory ;
1948
+ if (use_stdout + rev . diffopt . close_file + !! output_directory > 1 )
1949
+ die ( _ ( "--stdout, --output, and --output-directory are mutually exclusive" )) ;
1950
1950
1951
- if (!use_stdout )
1952
- output_directory = set_outdir (prefix , output_directory );
1953
- else
1951
+ if (use_stdout ) {
1954
1952
setup_pager ();
1955
-
1956
- if (output_directory ) {
1953
+ } else if (rev .diffopt .close_file ) {
1954
+ /*
1955
+ * The diff code parsed --output; it has already opened the
1956
+ * file, but but we must instruct it not to close after each
1957
+ * diff.
1958
+ */
1959
+ rev .diffopt .close_file = 0 ;
1960
+ } else {
1957
1961
int saved ;
1962
+
1963
+ if (!output_directory )
1964
+ output_directory = config_output_directory ;
1965
+ output_directory = set_outdir (prefix , output_directory );
1966
+
1958
1967
if (rev .diffopt .use_color != GIT_COLOR_ALWAYS )
1959
1968
rev .diffopt .use_color = GIT_COLOR_NEVER ;
1960
- if (use_stdout )
1961
- die (_ ("standard output, or directory, which one?" ));
1962
1969
/*
1963
1970
* We consider <outdir> as 'outside of gitdir', therefore avoid
1964
1971
* applying adjust_shared_perm in s-c-l-d.
@@ -2120,7 +2127,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
2120
2127
if (cover_letter ) {
2121
2128
if (thread )
2122
2129
gen_message_id (& rev , "cover" );
2123
- make_cover_letter (& rev , use_stdout ,
2130
+ make_cover_letter (& rev , !! output_directory ,
2124
2131
origin , nr , list , branch_name , quiet );
2125
2132
print_bases (& bases , rev .diffopt .file );
2126
2133
print_signature (rev .diffopt .file );
@@ -2175,7 +2182,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
2175
2182
gen_message_id (& rev , oid_to_hex (& commit -> object .oid ));
2176
2183
}
2177
2184
2178
- if (! use_stdout &&
2185
+ if (output_directory &&
2179
2186
open_next_file (rev .numbered_files ? NULL : commit , NULL , & rev , quiet ))
2180
2187
die (_ ("failed to create output files" ));
2181
2188
shown = log_tree_commit (& rev , commit );
@@ -2188,7 +2195,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
2188
2195
* the log; when using one file per patch, we do
2189
2196
* not want the extra blank line.
2190
2197
*/
2191
- if (! use_stdout )
2198
+ if (output_directory )
2192
2199
rev .shown_one = 0 ;
2193
2200
if (shown ) {
2194
2201
print_bases (& bases , rev .diffopt .file );
@@ -2199,7 +2206,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
2199
2206
else
2200
2207
print_signature (rev .diffopt .file );
2201
2208
}
2202
- if (! use_stdout )
2209
+ if (output_directory )
2203
2210
fclose (rev .diffopt .file );
2204
2211
}
2205
2212
stop_progress (& progress );
0 commit comments