# ``tar --newer-mtime'' behaviour change or BUG?



## yks (Jan 19, 2010)

It seems that recently the `tar' behaviour regarding the options `--newer-mtime'' and `--newer-mtime-than'' has changed.
At least, in FreeBSD 7.2 the command 

```
tar czf <file> --newer-mtime <date> .
```
created an archive of ALL files, with their relative paths, which had been modified ever since, and in FreeBSD 8.0 this includes only the files, all path components of which had been modified, which is very inconvenient. (This relates to the /usr/bin/tar program)
I created an example: 3 dirs with 2 files in each

```
# find . |xargs ls -l
.:
drwxr-xr-x  2 yks  yks  512 Jan 19 14:21 dir1
drwxr-xr-x  2 yks  yks  512 Jan 19 14:21 dir2
drwxr-xr-x  2 yks  yks  512 Jan 19 14:21 dir3

./dir1:
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file1
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file2

./dir2:
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file1
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file2

./dir3:
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file1
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file2
```

Then we execute commands:

```
$ which tar
/usr/bin/tar
$ touch lastmod
$ find . -name file1 | xargs touch
$ tar czf a.tar.gz --newer-mtime-than lastmod .
$ tar tf a.tar.gz
```

We expect the newer files with name `file1' to be added to the archive, regardless of their directories' modification time (we modified files but not the directories).
And we see two different archives:
FreeBSD 7.2 tar version: bsdtar 2.5.5 - libarchive 2.5.5

```
./
./dir1/
./dir2/
./dir3/
./dir3/file1
./dir2/file1
./dir1/file1
```

FreeBSD 8.0 tar version: bsdtar 2.7.0 - libarchive 2.7.0:

```
./
```

No files were added in 8.0!


After executing

```
$ touch *
```
which `touch'ed dir1, dir2, dir3,
the tar DOES add the required files into the archive, but it's not always possible to upward-recursively `touch' the directories in which the newer files reside.
The option `--newer-mtime' works analogously, i.e. when feeding it the date of the `lastmod' file, the results are the same.
Is this a bug, a feature, or what, and if a feature, then is it possible to emulate previous behaviour, and to add the issue to `man'?


----------

