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

[PATCH 5/5] parse-options: use prefix_filename_except_for_dash() helper

From
Jeff King <peff@peff.net>
Date
Mar 4, 2023, 10:31 UTC
Message-ID
<ZAMeExFKTULOFZF1@coredump.intra.peff.net>
In-Reply-To
<ZAMb8LSpm2gOrpeY@coredump.intra.peff.net>

Since our fix_filename()'s only remaining special case is handling "-", we can use the newly-minted helper function that handles this already.

Signed-off-by: Jeff King <peff@peff.net>
---
If we do eventually find that "!file || !*file" is a sign of a bug, we
could perhaps just simplify this whole function away. :)
 parse-options.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/parse-options.c b/parse-options.c
index 25bae8b585b..6dd4c090e03 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -63,10 +63,8 @@ static void fix_filename(const char *prefix, char **file)
 {
 	if (!file || !*file)
 		; /* leave as NULL */
-	else if (!strcmp("-", *file))
-		*file = xstrdup(*file);
 	else
-		*file = prefix_filename(prefix, *file);
+		*file = prefix_filename_except_for_dash(prefix, *file);
 }
 
 static enum parse_opt_result opt_command_mode_error(
-- 
2.40.0.rc1.500.g967c04631e
Previous: Jeff KingNext: Jeff King
Message 13 of 24 in “`git bundle create -` may not write to `stdout`”
  1. Michael HenryFeb 25, 2023
  2. Jeff KingFeb 26, 2023
  3. Junio C HamanoMar 3, 2023
  4. Jeff KingMar 3, 2023
  5. Junio C HamanoMar 3, 2023
  6. Jeff KingMar 4, 2023
  7. Jeff KingMar 4, 2023
  8. 0/5 handling "-" as stdin/stdout in git bundleJeff King, Mar 4, 2023
  9. 1/5 bundle: let "-" mean stdin for reading operationsJeff King, Mar 4, 2023
  10. 2/5 bundle: document handling of "-" as stdinJeff King, Mar 4, 2023
  11. 3/5 bundle: don't blindly apply prefix_filename() to "-"Jeff King, Mar 4, 2023
  12. 4/5 parse-options: consistently allocate memory in fix_filename()Jeff King, Mar 4, 2023
  13. 5/5 parse-options: use prefix_filename_except_for_dash() helperJeff King, Mar 4, 2023
  14. bundle: turn on --all-progress-implied by defaultJeff King, Mar 4, 2023
  15. Robin H. JohnsonMar 6, 2023
  16. Jeff KingMar 6, 2023
  17. Jeff KingMar 6, 2023
  18. Junio C HamanoMar 6, 2023
  19. Junio C HamanoMar 6, 2023
  20. Junio C HamanoMar 4, 2023
  21. Jeff KingMar 4, 2023
  22. Michael HenryMar 3, 2023
  23. Jeff KingMar 4, 2023
  24. Michael HenryMar 4, 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.