git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] bugreport: add 'seconds' to default outfile name

From
Jacob Stopak <jacob@initialcommit.io>
Date
Oct 14, 2023, 04:01 UTC
Message-ID
<20231014040101.8333-1-jacob@initialcommit.io>

Currently, git bugreport postfixes the default bugreport filename (and diagnostics zip filename if --diagnose is supplied) with the current calendar hour and minute values, assuming the -s flag is absent.

If a user runs the bugreport command more than once within a calendar minute, a filename conflict with an existing file occurs and the program errors, since the new output filename was already used for the previous file. If the user waits anywhere from 1 to 60 seconds (depending on _when_ during the calendar minute the first command was run) the command works again with no error since the default filename is now unique, and multiple bug reports are able to be created with default settings.

This is a minor thing but can cause confusion especially for first time users of the bugreport command, who are likely to run it multiple times in quick succession to learn how it works, (like I did).

This patch adds the calendar second value to the default bugreport filename. This technically just shortens the window during which the issue occurs, but a single second is a small enough time increment that users will avoid the filename conflict in practice in this scenario.

This means the user will end up with multiple bugreport files being created if they run the command multiple times quickly, but that feels more intuitive and consistent than an error arbitrarily occuring within a calendar minute, especially given that the time window in which the error currently occurs is variable as described above.

Signed-off-by: Jacob Stopak <jacob@initialcommit.io>
---
 builtin/bugreport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index d2ae5c305d..b556c6e135 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -106,7 +106,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
 	struct tm tm;
 	enum diagnose_mode diagnose = DIAGNOSE_NONE;
 	char *option_output = NULL;
-	char *option_suffix = "%Y-%m-%d-%H%M";
+	char *option_suffix = "%Y-%m-%d-%H%M%S";
 	const char *user_relative_path = NULL;
 	char *prefixed_filename;
 	size_t output_path_len;

base-commit: 493f4622739e9b64f24b465b21aa85870dd9dc09
-- 
2.42.0.297.g393e7d1581
Next: Kristoffer Haugsbakk
Message 1 of 23 in “bugreport: add 'seconds' to default outfile name”
  1. bugreport: add 'seconds' to default outfile nameJacob Stopak, Oct 14, 2023
  2. Kristoffer HaugsbakkOct 14, 2023
  3. Junio C HamanoOct 14, 2023
  4. Dragan SimicOct 14, 2023
  5. Junio C HamanoOct 14, 2023
  6. Dragan SimicOct 14, 2023
  7. Jacob StopakOct 15, 2023
  8. Dragan SimicOct 15, 2023
  9. Jacob StopakOct 15, 2023
  10. Junio C HamanoOct 15, 2023
  11. 0/3 bugreport: include +i in outfile suffix as neededJacob Stopak, Oct 15, 2023
  12. 1/3 bugreport: include +i in outfile suffix as neededJacob Stopak, Oct 15, 2023
  13. Junio C HamanoOct 15, 2023
  14. 0/1 bugreport: include +i in outfile suffix as neededJacob Stopak, Oct 16, 2023
  15. 1/1 bugreport: include +i in outfile suffix as neededJacob Stopak, Oct 16, 2023
  16. Junio C HamanoOct 16, 2023
  17. Jacob StopakOct 17, 2023
  18. Junio C HamanoOct 21, 2023
  19. Emily ShafferOct 26, 2023
  20. Jacob StopakOct 27, 2023
  21. Jacob StopakJan 6, 2024
  22. 2/3 bugreport: match diagnostics filename with reportJacob Stopak, Oct 15, 2023
  23. 3/3 bugreport: don't create --diagnose zip w/o reportJacob Stopak, Oct 15, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.