summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-11-17 22:19:05 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2011-11-17 22:19:05 +0200
commit02bf3a96a931678211117534ee535863c780c6dc (patch)
treeaef3d1856e83347b358afb06c2743eb4b47a9939
parent79138eaef1094eae50d4dfc84bb5007de06d6376 (diff)
downloadtar-02bf3a96a931678211117534ee535863c780c6dc.tar.gz
Warn about existing files in keep-old-files mode (complements 8f390db9).
This is controlled by "existing-file" warning code, which is off by default. * src/common.h (WARN_EXISTING_FILE): New warning code. (WARN_VERBOSE_WARNINGS): Add WARN_EXISTING_FILE. * src/extract.c (maybe_recoverable): warn about existing file if WARN_EXISTING_FILE is set. * src/warning.c: New warning type: "existing-file"
-rw-r--r--src/common.h3
-rw-r--r--src/extract.c2
-rw-r--r--src/warning.c4
3 files changed, 7 insertions, 2 deletions
diff --git a/src/common.h b/src/common.h
index c29ffc0d..b60c4a07 100644
--- a/src/common.h
+++ b/src/common.h
@@ -810,11 +810,12 @@ void checkpoint_run (bool do_write);
#define WARN_UNKNOWN_KEYWORD 0x00020000
#define WARN_XDEV 0x00040000
#define WARN_DECOMPRESS_PROGRAM 0x00080000
+#define WARN_EXISTING_FILE 0x00100000
/* The warnings composing WARN_VERBOSE_WARNINGS are enabled by default
in verbose mode */
#define WARN_VERBOSE_WARNINGS (WARN_RENAME_DIRECTORY|WARN_NEW_DIRECTORY|\
- WARN_DECOMPRESS_PROGRAM)
+ WARN_DECOMPRESS_PROGRAM|WARN_EXISTING_FILE)
#define WARN_ALL (~WARN_VERBOSE_WARNINGS)
void set_warning_option (const char *arg);
diff --git a/src/extract.c b/src/extract.c
index d24f98f6..60ec747f 100644
--- a/src/extract.c
+++ b/src/extract.c
@@ -643,6 +643,8 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
switch (old_files_option)
{
case KEEP_OLD_FILES:
+ WARNOPT (WARN_EXISTING_FILE,
+ (0, 0, _("%s: skipping existing file"), file_name));
return RECOVER_SKIP;
case KEEP_NEWER_FILES:
diff --git a/src/warning.c b/src/warning.c
index 5d1bcabc..102364d5 100644
--- a/src/warning.c
+++ b/src/warning.c
@@ -42,6 +42,7 @@ static char const *const warning_args[] = {
"unknown-keyword",
"xdev",
"decompress-program",
+ "existing-file",
NULL
};
@@ -66,7 +67,8 @@ static int warning_types[] = {
WARN_UNKNOWN_CAST,
WARN_UNKNOWN_KEYWORD,
WARN_XDEV,
- WARN_DECOMPRESS_PROGRAM
+ WARN_DECOMPRESS_PROGRAM,
+ WARN_EXISTING_FILE
};
ARGMATCH_VERIFY (warning_args, warning_types);