# [PATCH] Use patch file's modtime as the git author and commiter date

2 messages from 2007-02-11 to 2007-02-12. Participants: Theodore Ts'o, Josef Sipek.
Thread: https://gitlist.dev/t/6775

## Theodore Ts'o, 2007-02-11 23:24

Subject: [PATCH] Use patch file's modtime as the git author and commiter date
Message-ID: <11712362751442-git-send-email-tytso@mit.edu>
URL: https://gitlist.dev/e/11712362751442-git-send-email-tytso%40mit.edu

```
By using the same author and committer date, it keeps the git commit
id's stable if the patches haven't changed.  Otherwise, repeated
invocations of "guilt pop -a; guilt push -a" will create new commit's
with different commit dates, creating a lot of garbage commits that
won't disappear for a LONG time, even after running "git-gc --prune",
thanks to the reflog in git 1.5.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 guilt |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/guilt b/guilt
index ced441b..7cb52c4 100755
--- a/guilt
+++ b/guilt
@@ -248,6 +248,10 @@ function push_patch
 
 		export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
 	fi
+	local backup_author_date="$GIT_AUTHOR_DATE"
+	local backup_committer_date="$GIT_COMMITTER_DATE"
+	export GIT_AUTHOR_DATE=`stat -c %y $p`
+	export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE
 
 	# commit
 	local treeish=`git-write-tree`
@@ -271,6 +275,16 @@ function push_patch
 			unset GIT_AUTHOR_EMAIL
 		fi
 	fi
+	if [ ! -z "$backup_author_date" ]; then
+		export GIT_AUTHOR_DATE="$backup_author_date"
+	else
+		unset GIT_AUTHOR_DATE
+	fi
+		if [ ! -z "$backup_committer_date" ]; then
+		export GIT_COMMITTER_DATE="$backup_committer_date"
+	else
+		unset GIT_COMMITTER_DATE
+	fi
 
 	rm -f /tmp/guilt.msg.$$ /tmp/guilt.log.$$
 
-- 
1.5.0.rc4.2.g4249

```

## Josef Sipek, 2007-02-12 06:57

Subject: Re: [PATCH] Use patch file's modtime as the git author and commiter date
Message-ID: <20070212065720.GB31806@filer.fsl.cs.sunysb.edu>
URL: https://gitlist.dev/e/20070212065720.GB31806%40filer.fsl.cs.sunysb.edu
In-Reply-To: <11712362751442-git-send-email-tytso@mit.edu>

```
On Sun, Feb 11, 2007 at 06:24:35PM -0500, Theodore Ts'o wrote:
> By using the same author and committer date, it keeps the git commit
> id's stable if the patches haven't changed.  Otherwise, repeated
> invocations of "guilt pop -a; guilt push -a" will create new commit's
> with different commit dates, creating a lot of garbage commits that
> won't disappear for a LONG time, even after running "git-gc --prune",
> thanks to the reflog in git 1.5.

Applied. Thanks.

Josef "Jeff" Sipek.

-- 
Real Programmers consider "what you see is what you get" to be just as bad a
concept in Text Editors as it is in women. No, the Real Programmer wants a
"you asked for it, you got it" text editor -- complicated, cryptic,
powerful, unforgiving, dangerous.

```
