Skip to content

Commit 1e1693b

Browse files
peffgitster
authored andcommitted
format-patch: tie file-opening logic to output_directory
In format-patch we're either outputting to stdout or to individual files in an output directory (which may be just "./"). Our logic for whether to open a new file for each patch is checked with "!use_stdout", but it is equally correct to check for a non-NULL output_directory. The distinction will matter when we add a new single-stream output in a future patch, when only one of the three methods will want individual files. Let's swap the logic here in preparation. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c6f781 commit 1e1693b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

builtin/log.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ static void get_notes_args(struct strvec *arg, struct rev_info *rev)
11531153
}
11541154
}
11551155

1156-
static void make_cover_letter(struct rev_info *rev, int use_stdout,
1156+
static void make_cover_letter(struct rev_info *rev, int use_separate_file,
11571157
struct commit *origin,
11581158
int nr, struct commit **list,
11591159
const char *branch_name,
@@ -1173,7 +1173,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
11731173

11741174
committer = git_committer_info(0);
11751175

1176-
if (!use_stdout &&
1176+
if (use_separate_file &&
11771177
open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
11781178
die(_("failed to create cover-letter file"));
11791179

@@ -2117,7 +2117,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
21172117
if (cover_letter) {
21182118
if (thread)
21192119
gen_message_id(&rev, "cover");
2120-
make_cover_letter(&rev, use_stdout,
2120+
make_cover_letter(&rev, !!output_directory,
21212121
origin, nr, list, branch_name, quiet);
21222122
print_bases(&bases, rev.diffopt.file);
21232123
print_signature(rev.diffopt.file);
@@ -2172,7 +2172,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
21722172
gen_message_id(&rev, oid_to_hex(&commit->object.oid));
21732173
}
21742174

2175-
if (!use_stdout &&
2175+
if (output_directory &&
21762176
open_next_file(rev.numbered_files ? NULL : commit, NULL, &rev, quiet))
21772177
die(_("failed to create output files"));
21782178
shown = log_tree_commit(&rev, commit);
@@ -2185,7 +2185,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
21852185
* the log; when using one file per patch, we do
21862186
* not want the extra blank line.
21872187
*/
2188-
if (!use_stdout)
2188+
if (output_directory)
21892189
rev.shown_one = 0;
21902190
if (shown) {
21912191
print_bases(&bases, rev.diffopt.file);
@@ -2196,7 +2196,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
21962196
else
21972197
print_signature(rev.diffopt.file);
21982198
}
2199-
if (!use_stdout)
2199+
if (output_directory)
22002200
fclose(rev.diffopt.file);
22012201
}
22022202
stop_progress(&progress);

0 commit comments

Comments
 (0)