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

[PATCH] archive: Refuse to write the archive to a terminal.

From
Josh Triplett <josh@joshtriplett.org>
Date
Sep 16, 2009, 10:31 UTC
Message-ID
<20090916103129.GA21430@feather>

If not given the -o/--output option, git archive writes the archive to stdout. This proves unhelpful if not redirected or piped somewhere. Rather than spewing binary at the user's terminal, die with an appropriate message.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---

I considered adding a -f/--force option, like gzip has, but writing an archive to a tty seems like a sufficiently insane use case that I'll let whoever actually needs that write the patch for it. ;)

 builtin-archive.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-archive.c b/builtin-archive.c
index 12351e9..73accd0 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -101,6 +101,9 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 		create_output_file(output);
 		if (!format)
 			format = format_from_name(output);
+	} else if (isatty(1)) {
+		die("Archive not written to a terminal.\n"
+		    "Specify output filename or redirect output.");
 	}
 
 	if (format) {
-- 
1.6.3.3
Next: Johannes Sixt
Message 1 of 7 in “archive: Refuse to write the archive to a terminal.”
  1. archive: Refuse to write the archive to a terminal.Josh Triplett, Sep 16, 2009
  2. Johannes SixtSep 16, 2009
  3. Mikael MagnussonSep 16, 2009
  4. Reece DunnSep 16, 2009
  5. Matthieu MoySep 16, 2009
  6. Josh TriplettSep 17, 2009
  7. Johannes SixtSep 17, 2009

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.