The first one is a clear bug fix. For the second, since --no-time (-T) never worked (-m does), I could also just remove its entry from longopts. We've done without it for so long, there's little point to adding an undocumented --no-time, now.
>From ed37ad2fe34cb37a1dc1687fb6c441e2ebd2e86b Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@fb.com> Date: Mon, 24 Oct 2016 10:10:04 -0700 Subject: [PATCH 1/2] gzip --no-name: avoid spurious warning I noticed that while attempting to create gzip's own gzip-compressed release tarball, gzip would emit this warning and exit with status 2: gzip: stdin: warning: file time stamp out of range for gzip format Here is a minimal reproducer: : | gzip --no-name > k * zip.c (zip): Skip validity check when no_time is set. * gzip.c (no_time): Make this variable global. * gzip.h (no_time): Declare it extern. * tests/timestamp: Add a test to exercise the fix. Introduced by commit v1.8-6-g51dee92 --- gzip.c | 2 +- gzip.h | 1 + tests/timestamp | 3 +++ zip.c | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gzip.c b/gzip.c index 0fca5a3..f990fa2 100644 --- a/gzip.c +++ b/gzip.c @@ -173,7 +173,7 @@ static int decompress = 0; /* decompress (-d) */ static int force = 0; /* don't ask questions, compress links (-f) */ static int keep = 0; /* keep (don't delete) input files */ static int no_name = -1; /* don't save or restore the original file name */ -static int no_time = -1; /* don't save or restore the original file time */ + int no_time = -1; /* don't save or restore the original file time */ static int recursive = 0; /* recurse through directories (-r) */ static int list = 0; /* list the file contents (-l) */ int verbose = 0; /* be verbose (-v) */ diff --git a/gzip.h b/gzip.h index f298b47..4117306 100644 --- a/gzip.h +++ b/gzip.h @@ -199,6 +199,7 @@ typedef int file_t; /* Do not use stdio */ extern int exit_code; /* program exit code */ extern int verbose; /* be verbose (-v) */ +extern int no_time; /* --no-time (-T) */ extern int quiet; /* be quiet (-q) */ extern int level; /* compression level */ extern int test; /* check .z file integrity */ diff --git a/tests/timestamp b/tests/timestamp index 7acfe5d..141c1d4 100755 --- a/tests/timestamp +++ b/tests/timestamp @@ -49,4 +49,7 @@ touch -t 210602070628.15 in || { test $? = 2 || fail=1 } +# Ensure that --no-name does not provoke a time stamp warning. +: | gzip --no-name > k || fail=1 + Exit $fail diff --git a/zip.c b/zip.c index eb60409..cebd719 100644 --- a/zip.c +++ b/zip.c @@ -54,7 +54,9 @@ int zip(in, out) flags |= ORIG_NAME; } put_byte(flags); /* general flags */ - if (0 < time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff) + if (no_time) + stamp = 0; + else if (0 < time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff) stamp = time_stamp.tv_sec; else { -- 2.7.4 >From 6d0eabd745de16616beda963e0bee662a1664478 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@fb.com> Date: Mon, 24 Oct 2016 09:58:22 -0700 Subject: [PATCH 2/2] gzip: accept --no-time option (undocumented, like -m) The undocumented -m option has been accepted since the beginning, but its associated --no-time option has never been accepted, due to the use of 'T' (not mentioned in shortopts) instead of 'm' in the definition of longopts. This made it so an attempt to use this long option would elicit only a bare "Try `gzip --help' for more information." * gzip.c (longopts): Specify 'm' with --no-time, not 'T'. --- gzip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gzip.c b/gzip.c index f990fa2..9e34c80 100644 --- a/gzip.c +++ b/gzip.c @@ -285,7 +285,7 @@ static const struct option longopts[] = {"recursive", 0, 0, 'r'}, /* recurse through directories */ {"suffix", 1, 0, 'S'}, /* use given suffix instead of .gz */ {"test", 0, 0, 't'}, /* test compressed file integrity */ - {"no-time", 0, 0, 'T'}, /* don't save or restore the time stamp */ + {"no-time", 0, 0, 'm'}, /* don't save or restore the time stamp */ {"verbose", 0, 0, 'v'}, /* verbose mode */ {"version", 0, 0, 'V'}, /* display version number */ {"fast", 0, 0, '1'}, /* compress faster */ -- 2.7.4