New option --sort=ORDER

This option makes tar sort the entries of directories that will be
added to an archive according to ORDER (none, name, or order).

Based on proposition by Dick Streefland (https://savannah.gnu.org/patch/?7892).

* src/common.h (savedir_sort_order): New global.
* src/create.c: Pass savedir_sort_order to streamsavedir.
* src/misc.c: Likewise.
* src/tar.c: New option --sort.

* NEWS: Update.
* doc/tar.texi: Document the --sort option.
* doc/tar.1: Likewise.
This commit is contained in:
Sergey Poznyakoff
2014-02-14 00:11:57 +02:00
parent 62497f0e26
commit 29a6964af3
7 changed files with 89 additions and 4 deletions

View File

@@ -3319,6 +3319,27 @@ The @option{--warning=existing-file} option can be used together with
this option to produce warning messages about existing old files
(@pxref{warnings}).
@opsummary{sort}
@item --sort=@var{order}
Specify the directory sorting order when reading directories.
@var{Order} may be one of the following:
@table @samp
@item none
No directory sorting is performed. This is the default.
@item name
Sort the directory entries on name. The operating system may deliver
directory entries in a more or less random order, and sorting them
makes archive creation reproducible.
@item inode
Sort the directory entries on inode number. Sorting directories on
inode number may reduce the amount of disk seek operations when
creating an archive for some file systems.
@end table
@opsummary{sparse}
@item --sparse
@itemx -S