Browse Source

Update git-set-mtimes script to also set directory timestamps and to use the "author date" instead of the "committer date" since that's what's shown in a bare "git log" (so it ends up being less surprising)

This obviously deprecates any need for the old "git-set-dir-times" script, so it's also removed here.
Tianon Gravi 11 years ago
parent
commit
0bb1458242
3 changed files with 3 additions and 22 deletions
  1. 1 1
      bashbrew/build.sh
  2. 0 19
      bashbrew/git-set-dir-times
  3. 2 2
      bashbrew/git-set-mtimes

+ 1 - 1
bashbrew/build.sh

@@ -224,7 +224,7 @@ while [ "$#" -gt 0 ]; do
 	done
 	
 	if [ "$doBuild" ]; then
-		( set -x; cd "$gitRepo/$gitDir" && "$dir/git-set-dir-times" ) &>> "$thisLog"
+		( set -x; cd "$gitRepo/$gitDir" && "$dir/git-set-mtimes" ) &>> "$thisLog"
 		
 		( set -x; docker build -t "$repoTag" "$gitRepo/$gitDir" ) &>> "$thisLog"
 		

+ 0 - 19
bashbrew/git-set-dir-times

@@ -1,19 +0,0 @@
-#!/bin/bash
-set -e
-
-"$(dirname "$(readlink -f "$BASH_SOURCE")")/git-set-file-times"
-
-IFS=$'\n'
-topLevelDirs=( $(find -mindepth 1 -maxdepth 1 -type d -not -name .git) )
-unset IFS
-
-IFS=$'\n'
-allDirs=( $(find "${topLevelDirs[@]}" -depth -type d) . )
-unset IFS
-
-for dir in "${allDirs[@]}"; do
-	ref="$(ls -At "$dir" | grep -v '^.git$' | head -1)"
-	if [ "$ref" ]; then
-		touch --no-dereference --reference "$dir/$ref" "$dir"
-	fi
-done

+ 2 - 2
bashbrew/git-set-file-times → bashbrew/git-set-mtimes

@@ -2,11 +2,11 @@
 set -e
 
 IFS=$'\n'
-files=( $(git ls-files) )
+files=( $({ git ls-files | xargs dirname | sort -u && git ls-files; } | sort -r) )
 unset IFS
 
 for f in "${files[@]}"; do
-	stamp="$(git --no-pager log -1 --format='format:%ci' -- "$f")"
+	stamp="$(git --no-pager log -1 --format='format:%ai' -- "$f")"
 	touchFormat="$(date --date="$stamp" +'%Y%m%d%H%M.%S')"
 	touch --no-dereference -t "$touchFormat" "$f"
 done