From d75b6fbbca2c12dd075e37ea4fe1dbb271219b09 Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Fri, 12 Sep 2025 21:18:53 +0100 Subject: [PATCH 1/2] Work around the lack of nanosecond accuracy in busybox touch. --- gitattributesdb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gitattributesdb b/gitattributesdb index 987750d..5e0b33b 100755 --- a/gitattributesdb +++ b/gitattributesdb @@ -173,7 +173,7 @@ store_attributes() { # Function to restore path attributes from the database. restore_attributes() { - local COUNT=0 ID PATHNAME PREV_WARN=0 WARN=0 + local COUNT=0 ID FMT PATHNAME PREV_WARN=0 WARN=0 # Informational message. log "Restoring path attributes from database" @@ -209,11 +209,16 @@ restore_attributes() { # Restore {a,m}times (and ACLs on Linux). if [[ "$PLATFORM" == "Linux" ]]; then - touch -m -d "$(date -d "@${DB_MTIMES[$ID]}" +'%Y-%m-%d %H:%M:%S.%N' 2>/dev/null)0" -- "$PATHNAME" 2>/dev/null || { + # BusyBox touch doesn't support nanosecond accuracy, so work around it. + FMT="%Y-%m-%d %H:%M:%S" + touch --help 2>&1 | grep BusyBox >/dev/null 2>&1 || { + FMT+=".%N" + } + touch -m -d "$(date -d "@${DB_MTIMES[$ID]}" +"$FMT" 2>/dev/null)" -- "$PATHNAME" 2>/dev/null || { warn "Failed to restore mtime: $PATHNAME" (( WARN++ )) } - touch -a -d "$(date -d "@${DB_ATIMES[$ID]}" +'%Y-%m-%d %H:%M:%S.%N' 2>/dev/null)0" -- "$PATHNAME" 2>/dev/null || { + touch -a -d "$(date -d "@${DB_ATIMES[$ID]}" +"$FMT" 2>/dev/null)" -- "$PATHNAME" 2>/dev/null || { warn "Failed to restore atime: $PATHNAME" (( WARN++ )) } From 6f956ff56af0a65b6dd8f84aa845031c22998c61 Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Fri, 12 Sep 2025 21:19:47 +0100 Subject: [PATCH 2/2] Fix shellcheck validation. --- gitattributesdb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gitattributesdb b/gitattributesdb index 5e0b33b..c35886c 100755 --- a/gitattributesdb +++ b/gitattributesdb @@ -4,6 +4,8 @@ # Darren 'Tadgy' Austin # Licensed under the terms of the GNU General Public License version 3. +# shellcheck disable=SC2317 + # Defaults. DB_FILE=".gitattributesdb" # Database file, relative to the repository root. DB_EXTRA=".gitattributesdb-extra" # List of base64 encoded paths (one per line) to also store/restore attributes for.