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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]