diff -ur tar-1.14/ChangeLog tar-1.14-mod/ChangeLog
--- tar-1.14/ChangeLog	2004-05-11 10:11:47.000000000 +0200
+++ tar-1.14-mod/ChangeLog	2004-08-20 11:04:57.336812296 +0200
@@ -1,3 +1,17 @@
+2004-08-20  Bryan Ford  <baford@mit.edu>
+
+	* src/tar.c: New option --exclude-caches, to exclude
+	cache directories automatically on archive creation.
+	Cache directories are directories containing a
+	standardized tag file, as specified at:
+		http://www.brynosaurus.com/cachedir/spec.html	
+	* src/common.h: New variable exclude_caches_option.
+	* src/create.c: New function check_cache_directory(),
+	called from dump_dir0() if exclude_caches_option is set,
+	to check for a cache directory tag and exclude the directory
+	if such a tag is found.
+	* doc/tar.texi: Updated accordingly.
+
 2004-05-10  Sergey Poznyakoff  <gray@Mirddin.farlep.net>
 
 	* configure.ac: Fixed prerequisite headers for sys/buf.h
diff -ur tar-1.14/doc/tar.texi tar-1.14-mod/doc/tar.texi
--- tar-1.14/doc/tar.texi	2004-05-10 13:49:04.000000000 +0200
+++ tar-1.14-mod/doc/tar.texi	2004-08-20 11:05:43.236834432 +0200
@@ -201,6 +201,11 @@
 @set xref-exclude-from @xref{exclude}
 @set pxref-exclude-from @pxref{exclude}
 
+@set op-exclude-caches @kbd{--exclude-caches}
+@set ref-exclude-from @ref{exclude-caches}
+@set xref-exclude-from @xref{exclude-caches}
+@set pxref-exclude-from @pxref{exclude-caches}
+
 @set op-extract @kbd{--extract} (@kbd{--get}, @kbd{-x})
 @set ref-extract @ref{extract}
 @set xref-extract @xref{extract}
@@ -2742,6 +2747,11 @@
 Similar to @samp{--exclude}, except @command{tar} will use the list of
 patterns in the file @var{file}.  @FIXME-xref{}
 
+@item --exclude-caches
+
+Automatically excludes all directories
+containing a cache directory tag.  @FIXME-xref{}
+
 @item --file=@var{archive}
 @itemx -f @var{archive}
 
@@ -6138,6 +6148,24 @@
 @FIXME{do the exclude options files need to have stuff separated by
 newlines the same as the files-from option does?}
 
+@table @kbd
+@item --exclude-caches
+Causes @command{tar} to ignore directories containing a cache directory tag.
+@end table
+
+@findex exclude-caches
+When creating an archive,
+the @samp{--exclude-caches} option
+causes @command{tar} to exclude all directories
+that contain a @dfn{cache directory tag}.
+A cache directory tag is a short file
+with the well-known name @file{CACHEDIR.TAG}
+and having a standard header
+specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
+Various applications write cache directory tags
+into directories they use to hold regenerable, non-precious data,
+so that such data can be more easily excluded from backups.
+
 @menu
 * controlling pattern-patching with exclude::
 * problems with exclude::
diff -ur tar-1.14/src/common.h tar-1.14-mod/src/common.h
--- tar-1.14/src/common.h	2004-05-10 13:49:08.000000000 +0200
+++ tar-1.14-mod/src/common.h	2004-07-31 14:35:25.000000000 +0200
@@ -160,6 +160,9 @@
 /* Patterns that match file names to be excluded.  */
 GLOBAL struct exclude *excluded;
 
+/* Exclude directories containing a cache directory tag. */
+GLOBAL bool exclude_caches_option;
+
 /* Specified file containing names to work on.  */
 GLOBAL const char *files_from_option;
 
diff -ur tar-1.14/src/create.c tar-1.14-mod/src/create.c
--- tar-1.14/src/create.c	2004-04-26 11:17:20.000000000 +0200
+++ tar-1.14-mod/src/create.c	2004-08-20 11:06:43.065739056 +0200
@@ -903,6 +903,45 @@
     }
 }
 
+/* Look in directory DIRNAME for a cache directory tag file
+   with the magic name "CACHEDIR.TAG" and a standard header,
+   as described at:
+	http://www.brynosaurus.com/cachedir
+   Applications can write this file into directories they create
+   for use as caches containing purely regenerable, non-precious data,
+   allowing us to avoid archiving them if --exclude-caches is specified. */
+static bool
+check_cache_directory (char *dirname)
+{
+  static char tagname[] = "CACHEDIR.TAG";
+  char *tagpath;
+  int fd;
+  int tag_present = false;
+
+  tagpath = xmalloc(strlen(dirname) + strlen(tagname) + 1);
+  strcpy(tagpath, dirname);
+  strcat(tagpath, tagname);
+
+  fd = open(tagpath, O_RDONLY);
+  if (fd >= 0)
+    {
+      static char taghdr[] = "Signature: 8a477f597d28d172789f06886806bc55";
+      static char tagbuf[43];
+
+      if (read(fd, tagbuf, 43) == 43)
+        {
+	  if (memcmp(taghdr, tagbuf, 43) == 0)
+	    tag_present = true;
+	}
+
+      close(fd);
+    }
+
+  free(tagpath);
+
+  return tag_present;
+}
+
 static void
 dump_dir0 (char *directory,
 	   struct tar_stat_info *st, int top_level, dev_t parent_device)
@@ -993,6 +1032,16 @@
       return;
     }
 
+  if (exclude_caches_option
+      && check_cache_directory(st->orig_file_name))
+    {
+      if (verbose_option)
+	WARN ((0, 0,
+	       _("%s: contains a cache directory tag; not dumped"),
+	       quotearg_colon (st->orig_file_name)));
+      return;
+    }
+
   {
     char const *entry;
     size_t entry_len;
diff -ur tar-1.14/src/tar.c tar-1.14-mod/src/tar.c
--- tar-1.14/src/tar.c	2004-05-10 13:49:19.000000000 +0200
+++ tar-1.14-mod/src/tar.c	2004-07-31 14:33:14.000000000 +0200
@@ -184,6 +184,7 @@
   CHECKPOINT_OPTION,
   DELETE_OPTION,
   EXCLUDE_OPTION,
+  EXCLUDE_CACHES_OPTION,
   FORCE_LOCAL_OPTION,
   FORMAT_OPTION,
   GROUP_OPTION,
@@ -255,6 +256,7 @@
   {"directory", required_argument, 0, 'C'},
   {"exclude", required_argument, 0, EXCLUDE_OPTION},
   {"exclude-from", required_argument, 0, 'X'},
+  {"exclude-caches", no_argument, 0, EXCLUDE_CACHES_OPTION},
   {"extract", no_argument, 0, 'x'},
   {"file", required_argument, 0, 'f'},
   {"files-from", required_argument, 0, 'T'},
@@ -474,6 +476,7 @@
       --null                   -T reads null-terminated names, disable -C\n\
       --exclude=PATTERN        exclude files, given as a PATTERN\n\
   -X, --exclude-from=FILE      exclude patterns listed in FILE\n\
+      --exclude-caches         exclude directories containing a cache tag\n\
       --anchored               exclude patterns match file name start (default)\n\
       --no-anchored            exclude patterns match after any /\n\
       --ignore-case            exclusion ignores case\n\
@@ -990,6 +993,10 @@
 	add_exclude (excluded, optarg, exclude_options | recursion_option);
 	break;
 
+      case EXCLUDE_CACHES_OPTION:
+	exclude_caches_option = true;
+	break;
+
       case FORCE_LOCAL_OPTION:
 	force_local_option = true;
 	break;

