[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using --no-name with pipes by default for reproducibility (a patch inclu
From: |
Karel Klic |
Subject: |
Using --no-name with pipes by default for reproducibility (a patch included) |
Date: |
Mon, 02 Aug 2010 10:39:31 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100720 Fedora/3.0.6-1.fc12 Thunderbird/3.0.6 |
Hi,
a Fedora user recently complained [1] about metadata (--name enabled by
default) breaking checksums with no obvious advantage.
$ echo "foo" | gzip | sha1sum; sleep 1; echo "foo" | gzip | sha1sum
b1803d7287d7001ab13aa8ca598248b837f61944 -
3100bbc82e16778390147936310432407235f45e -
While --name might be useful when compressing a file, I think it should
not be enabled by default for pipes, so we get
$ echo "foo" | gzip | sha1sum; sleep 1; echo "foo" | gzip | sha1sum
505705216e4b4ed1f80dc55fb97d5e7f8a48d84f -
505705216e4b4ed1f80dc55fb97d5e7f8a48d84f -
Is there a reason why --name is enabled by default for pipes?
The user suggests that --name is less useful than having the possibility
of comparing checksums even when compressing a file, so it should be
disabled by default.
Best regards,
Karel Klic
[1] https://bugzilla.redhat.com/show_bug.cgi?id=615824
Here is a patch: Do not store file name and mtime by default when
compressing data from a pipe.
diff -up gzip-1.4/gzip.c.no_time gzip-1.4/gzip.c
--- gzip-1.4/gzip.c.no_time 2010-07-26 17:53:26.524902628 +0200
+++ gzip-1.4/gzip.c 2010-07-26 17:56:20.954778912 +0200
@@ -518,14 +518,15 @@ int main (int argc, char **argv)
}
} /* loop on all arguments */
- /* By default, save name and timestamp on compression but do not
- * restore them on decompression.
- */
- if (no_time < 0) no_time = decompress;
- if (no_name < 0) no_name = decompress;
-
file_count = argc - optind;
+ /* By default, save name and timestamp on compression except when
+ * reading data from stdin, and do not restore them on
+ * decompression.
+ */
+ if (no_time < 0) no_time = decompress || (file_count == 0);
+ if (no_name < 0) no_name = decompress || (file_count == 0);
+
#if O_BINARY
#else
if (ascii && !quiet) {
- Using --no-name with pipes by default for reproducibility (a patch included),
Karel Klic <=