# HG changeset patch # User Bruno Haible # Date 1109965002 0 # Node ID 18b4bb3dea4774bba95f2d42e285597bb2ba2cb9 # Parent 0aebab2c04d4de379a32a20916fd31640e989fc3 Preserve timestamps of files that have not changed. diff --git a/ChangeLog b/ChangeLog --- 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 --- 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_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