Skip to content

Commit d921c36

Browse files
committed
Merge branch 'js/bugreport-no-suffix-fix'
"git bugreport --no-suffix" was not supported and instead segfaulted, which has been corrected. * js/bugreport-no-suffix-fix: bugreport.c: fix a crash in `git bugreport` with `--no-suffix` option
2 parents 199074f + b3b57c6 commit d921c36

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Documentation/git-bugreport.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ git-bugreport - Collect information for user to file a bug report
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git bugreport' [(-o | --output-directory) <path>] [(-s | --suffix) <format>]
11+
'git bugreport' [(-o | --output-directory) <path>]
12+
[(-s | --suffix) <format> | --no-suffix]
1213
[--diagnose[=<mode>]]
1314

1415
DESCRIPTION
@@ -51,9 +52,12 @@ OPTIONS
5152

5253
-s <format>::
5354
--suffix <format>::
55+
--no-suffix::
5456
Specify an alternate suffix for the bugreport name, to create a file
5557
named 'git-bugreport-<formatted-suffix>'. This should take the form of a
5658
strftime(3) format string; the current local time will be used.
59+
`--no-suffix` disables the suffix and the file is just named
60+
`git-bugreport` without any disambiguation measure.
5761

5862
--no-diagnose::
5963
--diagnose[=<mode>]::

builtin/bugreport.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static void get_populated_hooks(struct strbuf *hook_info, int nongit)
6464
}
6565

6666
static const char * const bugreport_usage[] = {
67-
N_("git bugreport [(-o | --output-directory) <path>] [(-s | --suffix) <format>]\n"
67+
N_("git bugreport [(-o | --output-directory) <path>]\n"
68+
" [(-s | --suffix) <format> | --no-suffix]\n"
6869
" [--diagnose[=<mode>]]"),
6970
NULL
7071
};
@@ -138,8 +139,11 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
138139
strbuf_complete(&report_path, '/');
139140
output_path_len = report_path.len;
140141

141-
strbuf_addstr(&report_path, "git-bugreport-");
142-
strbuf_addftime(&report_path, option_suffix, localtime_r(&now, &tm), 0, 0);
142+
strbuf_addstr(&report_path, "git-bugreport");
143+
if (option_suffix) {
144+
strbuf_addch(&report_path, '-');
145+
strbuf_addftime(&report_path, option_suffix, localtime_r(&now, &tm), 0, 0);
146+
}
143147
strbuf_addstr(&report_path, ".txt");
144148

145149
switch (safe_create_leading_directories(report_path.buf)) {

0 commit comments

Comments
 (0)