From e000df5f90225c315f77fd773430ecd4445528dd Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 4 Mar 2005 19:36:42 +0000 Subject: [PATCH] Preserve timestamps of files that have not changed. --- ChangeLog | 5 +++-- gnulib-tool | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 51283b5001..4a576c58be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ 2005-03-04 Derek R. Price - * gnulib-tool: Only replace files via --import when they have - actually changed. + * gnulib-tool (func_cp_if_changed, func_mv_if_changed): New functions. + (func_import): Only replace files via --import when they have actually + changed. 2005-03-03 Derek R. Price Bruno Haible diff --git a/gnulib-tool b/gnulib-tool index aa2f4795d3..44fd4a1a04 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -22,7 +22,7 @@ progname=$0 package=gnulib -cvsdatestamp='$Date: 2005-03-04 19:28:13 $' +cvsdatestamp='$Date: 2005-03-04 19:36:42 $' last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` @@ -118,27 +118,31 @@ func_fatal_error () } # func_cp_if_changed SRC DEST -# -# cp, but avoid munging timestamps if the file hasn't changed. +# Like cp, but avoids munging timestamps if the file hasn't changed. +# Uses also the variables +# - dry_run true if actions shall only be printed, blank otherwise func_cp_if_changed () { if test $# -ne 2; then - echo "usage: cp_if_changed SRC DEST" >&2 + echo "usage: func_cp_if_changed SRC DEST" >&2 fi test -n "$dry_run" && dry=echo - if cmp "$1" "$2" >/dev/null 2>&1; then :; else + if cmp "$1" "$2" >/dev/null 2>&1; then + : + else $dry cp -p "$1" "$2" fi } # func_mv_if_changed SRC DEST -# -# mv, but avoid munging timestamps if the file hasn't changed. -# Remove the source file if it is not renamed. +# Like mv, but avoids munging timestamps if the file hasn't changed. +# Removes SRC if it is not renamed. +# Uses also the variables +# - dry_run true if actions shall only be printed, blank otherwise func_mv_if_changed () { if test $# -ne 2; then - echo "usage: mv_if_changed SRC DEST" >&2 + echo "usage: func_mv_if_changed SRC DEST" >&2 fi test -n "$dry_run" && dry=echo if cmp "$1" "$2" >/dev/null 2>&1; then -- 2.30.2