[PATCH] guilt: Make sure the commit time is increasing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Git has various algorithms, most notably in git rev-list, git
name-rev, and others, which depend on the commit time increasing.  We
want to keep the commit time the same as much as possible, but if
necessary, adjust the time stamps of the patch files to obey this
constraint.

Signed-off-by: "Theodore Ts'o" <tytso@xxxxxxx>
---
 guilt |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/guilt b/guilt
index b6e2a6c..2371e98 100755
--- a/guilt
+++ b/guilt
@@ -535,6 +535,13 @@ commit()
                         export GIT_AUTHOR_EMAIL="`echo $author_str | sed -e 's/[^<]*//'`"
 		fi
 
+		ct=$(git log -1 --pretty=%ct)
+		if [ $ct -gt $(stat -c %Y "$p") ]; then
+		    echo "Warning time went backwards, adjusting mod time of" \
+			$(basename "$p")
+		    touch -d @$(expr $ct + 60) "$p" || touch "$p"
+		fi
+
 		# must strip nano-second part otherwise git gets very
 		# confused, and makes up strange timestamps from the past
 		# (chances are it decides to interpret it as a unix
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]