From f8591e6962b75af307f68844a5e4d5acf9c4a9eb Mon Sep 17 00:00:00 2001 From: Ryusuke Konishi Date: Thu, 3 May 2012 18:57:15 +0900 Subject: [PATCH] diff: regard two files as identical only if inode numbers and ctimes equal The diff program regards two directories (or files) as identical when both their block devices and inode numbers equal. This could be a problem in some cases, for instance, when underlying filesystem has snapshots or versioning capability. In such filesystems, different versions of a file (or a directory) may have the same inode number and the same block device. Thus, the diff program does not output any changes for them. This is a workaround for this problem. This rewrites same_file macro so that two files or directories are regarded as identical only if their inode numbers and ctimes equal. Signed-off-by: Ryusuke Konishi --- src/system.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/system.h b/src/system.h index 2767b57..0523710 100644 --- a/src/system.h +++ b/src/system.h @@ -164,7 +164,9 @@ verify (sizeof (lin) <= sizeof (long int)); /* Do struct stat *S, *T describe the same file? Answer -1 if unknown. */ #ifndef same_file # define same_file(s, t) \ - ((((s)->st_ino == (t)->st_ino) && ((s)->st_dev == (t)->st_dev)) \ + ((((s)->st_ino == (t)->st_ino) && \ + S_ISREG((s)->st_mode) && S_ISREG((t)->st_mode) && \ + ((s)->st_ctime == (t)->st_ctime)) \ || same_special_file (s, t)) #endif -- 1.7.9.3