Skip to content

Commit

Permalink
[PATCH] guilt: Make sure the commit time is increasing
Browse files Browse the repository at this point in the history
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" <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
[jeffpc: fixup test 051 to handle unchanged patch files' timestamps changing]
  • Loading branch information
tytso authored and jeffpc committed Jul 14, 2010
1 parent f833954 commit 429c3a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions guilt
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,16 @@ 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
ct=`expr $ct + 60`
if [ $ct -gt `date +%s` ]; then
touch "$p"
else
touch -d @$ct "$p"
fi
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
Expand Down
4 changes: 4 additions & 0 deletions regression/t-051.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ fixup_time_info second
fixup_time_info third
fixup_time_info fourth
fixup_time_info fifth
fixup_time_info modify
fixup_time_info add
fixup_time_info remove
fixup_time_info mode

p=first

Expand Down

0 comments on commit 429c3a5

Please sign in to comment.