threads / discuss / 17309

how to force a commit date matching info from a mbox ?

Subject: how to force a commit date matching info from a mbox ?

## tl;dr

19 messages between Jan 22, 2009 and Jan 24, 2009.

replies: 18people: 6as markdown or json

Christian MICHON· Jan 22, 2009, 22:41 UTC · lore
Hi list,

I've a big set of patches in a mbox file: there's sufficient info inside for git-am to work.

Yet, each time I do import these, my sha1sums are changing because of different commit dates.

I'd like to force the commit date to match the info/date from the time I received the email (and therefore always get back the right sha1sums).

is this possible ?

There's hundreds of these patches: I'm looking for the right switch or 1 liner trick instead of a long shell script which will import 1 by 1 the patches and force the commit date by environment.

TIA
-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !
Junio C Hamano· Jan 23, 2009, 00:14 UTC · re: Christian MICHON · lore

Re: how to force a commit date matching info from a mbox ?

Christian MICHON <christian.michon@gmail.com> writes:
Show 5 quoted lines
> I'd like to force the commit date to match the info/date from the time
> I received the email (and therefore always get back the right
> sha1sums).
>
> is this possible ?

"am" being a tool to accept patches written in some past to faithfully record both author timestamp and committer timestamp, what you seem to want is outside of the current scope of the tool.

A patch to butcher "git-am" to copy GIT_COMMITTER_DATE from GIT_AUTHOR_DATE and export it should be trivial to implement, though.

Perhaps something like this totally untested patch.
 git-am.sh     |   13 ++++++++++++-
 t/t4150-am.sh |   20 ++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletions(-)
diff --git c/git-am.sh w/git-am.sh
index e20dd88..e96071d 100755
--- c/git-am.sh
+++ w/git-am.sh
@@ -23,6 +23,7 @@ resolvemsg=     override error message when patch failure occurs
 r,resolved      to be used after a patch failure
 skip            skip the current patch
 abort           restore the original branch and abort the patching operation.
+committer-date-is-author-date    lie about committer date
 rebasing        (internal use for git-rebase)"
 
 . git-sh-setup
@@ -133,6 +134,7 @@ dotest="$GIT_DIR/rebase-apply"
 sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
 resolvemsg= resume=
 git_apply_opt=
+committer_date_is_author_date=
 
 while test $# != 0
 do
@@ -168,6 +170,8 @@ do
 		git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
 	-C|-p)
 		git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
+	--committer-date-is-author-date)
+		committer_date_is_author_date=t ;;
 	--)
 		shift; break ;;
 	*)
@@ -521,7 +525,14 @@ do
 
 	tree=$(git write-tree) &&
 	parent=$(git rev-parse --verify HEAD) &&
-	commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
+	commit=$(
+		if test -n "$committer_date_is_author_date"
+		then
+			GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+			export GIT_COMMITTER_DATE
+		fi &&
+		git commit-tree $tree -p $parent <"$dotest/final-commit"
+	) &&
 	git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
 	stop_here $this
 
diff --git c/t/t4150-am.sh w/t/t4150-am.sh
index 796f795..8d3fb00 100755
--- c/t/t4150-am.sh
+++ w/t/t4150-am.sh
@@ -257,4 +257,24 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' '
 	test -z "$(git diff second)"
 '
 
+test_expect_success 'am --committer-date-is-author-date' '
+	git checkout first &&
+	test_tick &&
+	git am --committer-date-is-author-date patch1 &&
+	git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
+	at=$(sed -ne "/^author /s/.*> //p" head1) &&
+	ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
+	test "$at" = "$ct"
+'
+
+test_expect_success 'am without --committer-date-is-author-date' '
+	git checkout first &&
+	test_tick &&
+	git am patch1 &&
+	git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
+	at=$(sed -ne "/^author /s/.*> //p" head1) &&
+	ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
+	test "$at" != "$ct"
+'
+
 test_done
Nanako Shiraishi· Jan 23, 2009, 00:45 UTC · re: Junio C Hamano · lore

Re: how to force a commit date matching info from a mbox ?

Quoting Junio C Hamano <gitster@pobox.com>:
Show 16 quoted lines
> Christian MICHON <christian.michon@gmail.com> writes:
>
>> I'd like to force the commit date to match the info/date from the time
>> I received the email (and therefore always get back the right
>> sha1sums).
>>
>> is this possible ?
>
> "am" being a tool to accept patches written in some past to faithfully
> record both author timestamp and committer timestamp, what you seem to
> want is outside of the current scope of the tool.
>
> A patch to butcher "git-am" to copy GIT_COMMITTER_DATE from
> GIT_AUTHOR_DATE and export it should be trivial to implement, though.
>
> Perhaps something like this totally untested patch.
You have test scripts already, but you say it is untested?
I often wanted to have an opposite of what Christian wants. I always have some changes I am holding off, and when I decide to trickle them out to the main repository, I do not want the resulting commit to carry old dates that are recorded in the format-patch output. Instead I want to pretend that I worked on them today. Is this something you can teach git-am and git-rebase to do easily?
-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
Junio C Hamano· Jan 23, 2009, 07:37 UTC · re: Nanako Shiraishi · lore

Re: how to force a commit date matching info from a mbox ?

Nanako Shiraishi <nanako3@lavabit.com> writes:
Show 5 quoted lines
> Quoting Junio C Hamano <gitster@pobox.com>:
>
>> Perhaps something like this totally untested patch.
>
> You have test scripts already, but you say it is untested?
Correct.  I did not run that new test, let alone existing ones ;-)
Nanako Shiraishi· Jan 23, 2009, 08:26 UTC · re: Junio C Hamano · lore

Re: how to force a commit date matching info from a mbox ?

Quoting Junio C Hamano <gitster@pobox.com>:
Show 9 quoted lines
> Nanako Shiraishi <nanako3@lavabit.com> writes:
>
>> Quoting Junio C Hamano <gitster@pobox.com>:
>>
>>> Perhaps something like this totally untested patch.
>>
>> You have test scripts already, but you say it is untested?
>
> Correct.  I did not run that new test, let alone existing ones ;-)
I applied your patch and run the test suite, including the new one, and they passed.
I tried to write a new option I said that I wanted in my previous message.  Here is a patch.
--->8---
Subject: [PATCH] git-am: Add --ignore-date option

This new option makes the command ignore the date header field recorded in the format-patch output. The commits will have the timestamp when they are created instead.

You can work a lot in one day to accumulate many changes, but apply and push to the public repository only some of them at the end of the first day. Then next day you can spend all your working hours reading comics or chatting with your coworkers, and apply your remaining patches from the previous day using this option to pretend that you have been working at the end of the day.

Signed-off-by: しらいしななこ <nanako3@lavabit.com>
---
 git-am.sh     |   12 +++++++++++-
 t/t4150-am.sh |    9 +++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index e96071d..eb88d90 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -24,6 +24,7 @@ r,resolved      to be used after a patch failure
 skip            skip the current patch
 abort           restore the original branch and abort the patching operation.
 committer-date-is-author-date    lie about committer date
+ignore-date     use current timestamp for author date
 rebasing        (internal use for git-rebase)"
 
 . git-sh-setup
@@ -135,6 +136,7 @@ sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
 resolvemsg= resume=
 git_apply_opt=
 committer_date_is_author_date=
+ignore_date=
 
 while test $# != 0
 do
@@ -172,6 +174,8 @@ do
 		git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
 	--committer-date-is-author-date)
 		committer_date_is_author_date=t ;;
+	--ignore-date)
+		ignore_date=t ;;
 	--)
 		shift; break ;;
 	*)
@@ -379,7 +383,13 @@ do
 
 	GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
 	GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
-	GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
+	case "$ignore_date" in
+	    t)
+		GIT_AUTHOR_DATE="$(date -R)"
+		;;
+	    '')
+		GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
+	esac
 
 	if test -z "$GIT_AUTHOR_EMAIL"
 	then
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 8d3fb00..5ecf456 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -277,4 +277,13 @@ test_expect_success 'am without --committer-date-is-author-date' '
 	test "$at" != "$ct"
 '
 
+test_expect_success 'am --ignore-date' '
+	git checkout first &&
+	test_tick &&
+	git am --ignore-date patch1 &&
+	git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
+	at=$(sed -ne "/^author /s/.*> //p" head1) &&
+	echo "$at" | grep "+0000"
+'
+
 test_done
-- 
1.6.1.224.gb56c7

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
Junio C Hamano· Jan 23, 2009, 09:39 UTC · re: Nanako Shiraishi · lore

Re: how to force a commit date matching info from a mbox ?

Nanako Shiraishi <nanako3@lavabit.com> writes:
Show 5 quoted lines
> Quoting Junio C Hamano <gitster@pobox.com>:
>
>> Correct.  I did not run that new test, let alone existing ones ;-)
>
> I applied your patch and run the test suite, including the new one, and they passed.
Thanks.
> I tried to write a new option I said that I wanted in my previous message.  Here is a patch.
>
> --->8---
> Subject: [PATCH] git-am: Add --ignore-date option
Good.

Leaving "Subject: " in saves me typing, because I do not have to insert it manually when editing the submitted patch in my MUA to chop off everything before the scissors.

Show 10 quoted lines
> This new option makes the command ignore the date header field recorded in
> the format-patch output.  The commits will have the timestamp when they
> are created instead.
>
> You can work a lot in one day to accumulate many changes, but apply and
> push to the public repository only some of them at the end of the first
> day.  Then next day you can spend all your working hours reading comics or
> chatting with your coworkers, and apply your remaining patches from the
> previous day using this option to pretend that you have been working at
> the end of the day.
LOL.  A slacker option is a tough sell to a serious management, though.

I think it would work equally well if you somehow manage to pass this through "git-rebase", but this won't work with "git-rebase --interactive".

Show 12 quoted lines
> @@ -379,7 +383,13 @@ do
>  
>  	GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
>  	GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
> -	GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
> +	case "$ignore_date" in
> +	    t)
> +		GIT_AUTHOR_DATE="$(date -R)"
> +		;;
> +	    '')
> +		GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
> +	esac

Please align case arm labels with case/esac; iow, do not indent t) and '') by four spaces, when you write your next case/esac statement.

"date -R" is a GNU extension; avoid it (I'll show you how at the end).
Show 16 quoted lines
> diff --git a/t/t4150-am.sh b/t/t4150-am.sh
> index 8d3fb00..5ecf456 100755
> --- a/t/t4150-am.sh
> +++ b/t/t4150-am.sh
> @@ -277,4 +277,13 @@ test_expect_success 'am without --committer-date-is-author-date' '
>  	test "$at" != "$ct"
>  '
>  
> +test_expect_success 'am --ignore-date' '
> +	git checkout first &&
> +	test_tick &&
> +	git am --ignore-date patch1 &&
> +	git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
> +	at=$(sed -ne "/^author /s/.*> //p" head1) &&
> +	echo "$at" | grep "+0000"
> +'
This is a convoluted logic.

The committer and author dates are set to -0700 timezone by test_tick, while TZ is set to UTC (+0000) by test-lib.sh, and you are taking advantage of them to see which one is being used.

But I do not think of a better way to do this offhand, so I'll let it pass.

Regarding the "date -R" thing, I think we can take advantage of the fact that an empty GIT_AUTHOR_DATE (and GIT_COMMITTER_DATE) means "do not use this environment variable, but use the current date instead". Something like this patch on top of yours, whose first hunk reverts your change to use "date -R", and sets GIT_AUTHOR_DATE to empty when --ignore-date is asked for.

No, I didn't test it.
diff --git i/git-am.sh w/git-am.sh
index eb88d90..f935178 100755
--- i/git-am.sh
+++ w/git-am.sh
@@ -383,13 +383,7 @@ do
 
 	GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")"
 	GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")"
-	case "$ignore_date" in
-	    t)
-		GIT_AUTHOR_DATE="$(date -R)"
-		;;
-	    '')
-		GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
-	esac
+	GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")"
 
 	if test -z "$GIT_AUTHOR_EMAIL"
 	then
@@ -536,6 +530,10 @@ do
 	tree=$(git write-tree) &&
 	parent=$(git rev-parse --verify HEAD) &&
 	commit=$(
+		if test -n "$ignore_date"
+		then
+			GIT_AUTHOR_DATE=
+		fi
 		if test -n "$committer_date_is_author_date"
 		then
 			GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
Jeff King· Jan 23, 2009, 22:29 UTC · re: Junio C Hamano · lore

Re: how to force a commit date matching info from a mbox ?

On Fri, Jan 23, 2009 at 01:39:27AM -0800, Junio C Hamano wrote:
Show 8 quoted lines
> > --->8---
> > Subject: [PATCH] git-am: Add --ignore-date option
> 
> Good.
> 
> Leaving "Subject: " in saves me typing, because I do not have to insert it
> manually when editing the submitted patch in my MUA to chop off everything
> before the scissors.

Interesting to know. I have intentionally _not_ been including them, because I assumed you marked up _after_ git-am (i.e., via "git commit --amend) in which case you would have to delete it manually. I suppose it makes more sense to do so before git-am, though, since then it will respect From: fields and the like (which it would otherwise ignore, since they are blocked by all of the cover letter cruft that you will end up deleting).

So good to know, and I will start generating my patches differently.
-Peff
Johannes Schindelin· Jan 24, 2009, 00:34 UTC · re: Jeff King · lore

Re: how to force a commit date matching info from a mbox ?

Hi,
On Fri, 23 Jan 2009, Jeff King wrote:
Show 20 quoted lines
> On Fri, Jan 23, 2009 at 01:39:27AM -0800, Junio C Hamano wrote:
> 
> > > --->8---
> > > Subject: [PATCH] git-am: Add --ignore-date option
> > 
> > Good.
> > 
> > Leaving "Subject: " in saves me typing, because I do not have to insert it
> > manually when editing the submitted patch in my MUA to chop off everything
> > before the scissors.
> 
> Interesting to know. I have intentionally _not_ been including them,
> because I assumed you marked up _after_ git-am (i.e., via "git commit
> --amend) in which case you would have to delete it manually. I suppose
> it makes more sense to do so before git-am, though, since then it will
> respect From: fields and the like (which it would otherwise ignore,
> since they are blocked by all of the cover letter cruft that you will
> end up deleting).
> 
> So good to know, and I will start generating my patches differently.

Note that your patches will not be found using Pasky's "mail" link in gitweb, if you do not put the commit subject into the _real_ mail subject.

Dunno if I like that.

Ciao, Dscho

Jeff King· Jan 24, 2009, 00:52 UTC · re: Johannes Schindelin · lore

Re: how to force a commit date matching info from a mbox ?

On Sat, Jan 24, 2009 at 01:34:41AM +0100, Johannes Schindelin wrote:
Show 6 quoted lines
> > So good to know, and I will start generating my patches differently.
> 
> Note that your patches will not be found using Pasky's "mail" link in 
> gitweb, if you do not put the commit subject into the _real_ mail subject.
> 
> Dunno if I like that.

I think that is not a new problem. Quite a few patches are "how about this" patches in the middle of a thread, and leave the old subject. IMHO, that is a failing of the tool in not tracking common practice, not the other way around.

-Peff
Johannes Schindelin· Jan 24, 2009, 01:43 UTC · re: Jeff King · lore

Re: how to force a commit date matching info from a mbox ?

Hi,
On Fri, 23 Jan 2009, Jeff King wrote:
Show 13 quoted lines
> On Sat, Jan 24, 2009 at 01:34:41AM +0100, Johannes Schindelin wrote:
> 
> > > So good to know, and I will start generating my patches differently.
> > 
> > Note that your patches will not be found using Pasky's "mail" link in 
> > gitweb, if you do not put the commit subject into the _real_ mail subject.
> > 
> > Dunno if I like that.
> 
> I think that is not a new problem. Quite a few patches are "how about
> this" patches in the middle of a thread, and leave the old subject.
> IMHO, that is a failing of the tool in not tracking common practice, not
> the other way around.
You know exactly what "fixing the tool" would mean.

Ciao, Dscho

Jeff King· Jan 24, 2009, 02:35 UTC · re: Johannes Schindelin · lore

Re: how to force a commit date matching info from a mbox ?

On Sat, Jan 24, 2009 at 02:43:47AM +0100, Johannes Schindelin wrote:
Show 6 quoted lines
> > I think that is not a new problem. Quite a few patches are "how about
> > this" patches in the middle of a thread, and leave the old subject.
> > IMHO, that is a failing of the tool in not tracking common practice, not
> > the other way around.
> 
> You know exactly what "fixing the tool" would mean.

Yes, I know. I think Pasky's tool is a clever hack, but I never expected it to be comprehensive in its results. At the GitTogether, we discussed some interesting ideas for tracking the mailing list and showing a more patch-oriented view, but those would be a lot of work, and I am not volunteering to do it right now.

What I meant by my comment was that I am not too concerned with tweaking my workflow to help Pasky's tool.

-Peff
Nanako Shiraishi· Jan 23, 2009, 09:52 UTC · re: Nanako Shiraishi · lore

Re: how to force a commit date matching info from a mbox ?

Quoting Junio C Hamano <gitster@pobox.com>:
Show 8 quoted lines
>> --->8---
>> Subject: [PATCH] git-am: Add --ignore-date option
>
> Good.
>
> Leaving "Subject: " in saves me typing, because I do not have to insert it
> manually when editing the submitted patch in my MUA to chop off everything
> before the scissors.

I am sorry to ask you a stupid question, but do you mean you want to have "Subject: " there, or do you mean you want me to leave that word out?

> I think it would work equally well if you somehow manage to pass this
> through "git-rebase", but this won't work with "git-rebase --interactive".

I can try to change git-rebase if you want, but I do not think I can modify git-rebase --interactive. The script looked very scary last time I looked at it (^_^;;;).

Show 26 quoted lines
>> +test_expect_success 'am --ignore-date' '
>> +	git checkout first &&
>> +	test_tick &&
>> +	git am --ignore-date patch1 &&
>> +	git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
>> +	at=$(sed -ne "/^author /s/.*> //p" head1) &&
>> +	echo "$at" | grep "+0000"
>> +'
>
> This is a convoluted logic.
>
> The committer and author dates are set to -0700 timezone by test_tick,
> while TZ is set to UTC (+0000) by test-lib.sh, and you are taking
> advantage of them to see which one is being used.
>
> But I do not think of a better way to do this offhand, so I'll let it
> pass.
>
> Regarding the "date -R" thing, I think we can take advantage of the fact
> that an empty GIT_AUTHOR_DATE (and GIT_COMMITTER_DATE) means "do not use
> this environment variable, but use the current date instead".  Something
> like this patch on top of yours, whose first hunk reverts your change to
> use "date -R", and sets GIT_AUTHOR_DATE to empty when --ignore-date is
> asked for.
>
> No, I didn't test it.
I did, and it works.
Thank you very much.
-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
Junio C Hamano· Jan 23, 2009, 17:27 UTC · re: Nanako Shiraishi · lore

Re: how to force a commit date matching info from a mbox ?

Nanako Shiraishi <nanako3@lavabit.com> writes:
Show 13 quoted lines
> Quoting Junio C Hamano <gitster@pobox.com>:
>
>>> --->8---
>>> Subject: [PATCH] git-am: Add --ignore-date option
>>
>> Good.
>>
>> Leaving "Subject: " in saves me typing, because I do not have to insert it
>> manually when editing the submitted patch in my MUA to chop off everything
>> before the scissors.
>
> I am sorry to ask you a stupid question, but do you mean you want to have
> "Subject: " there, or do you mean you want me to leave that word out?

Sorry for poor use of the language. I want to see "Subject: " on the line after the scissors. That way, I can remove everything up to the scissors, and the resulting message body will start with a line that begins with "Subject: ", which overrides the subject of the e-mail.

Johannes Schindelin· Jan 23, 2009, 12:38 UTC · re: Nanako Shiraishi · lore

Re: [PATCH] git-am: Add --ignore-date option

Hi,
[if you would have given a new mail subject to your mail, gitweb would 
 stand a chance to find it]
On Fri, 23 Jan 2009, Nanako Shiraishi wrote:
Show 12 quoted lines
> Subject: [PATCH] git-am: Add --ignore-date option
> 
> This new option makes the command ignore the date header field recorded in
> the format-patch output.  The commits will have the timestamp when they
> are created instead.
> 
> You can work a lot in one day to accumulate many changes, but apply and
> push to the public repository only some of them at the end of the first
> day.  Then next day you can spend all your working hours reading comics or
> chatting with your coworkers, and apply your remaining patches from the
> previous day using this option to pretend that you have been working at
> the end of the day.
FWIW I have that problem in one of my workflows, and I do this:
	grep -v "^Date:" < $MBOX | git am

Of course, this assumes that none of my commit messages has the string "Date:" at the beginning of the line...

Ciao, Dscho

Adeodato Simó· Jan 23, 2009, 13:17 UTC · re: Johannes Schindelin · lore

Re: [PATCH] git-am: Add --ignore-date option

* Johannes Schindelin [Fri, 23 Jan 2009 13:38:34 +0100]:
> FWIW I have that problem in one of my workflows, and I do this:
> 	grep -v "^Date:" < $MBOX | git am
> Of course, this assumes that none of my commit messages has the string 
> "Date:" at the beginning of the line...
In case you're interested:
    % formail -I 'Date' -s < $MBOX | git am

is robust against your assumption being wrong. (I realize ^Date: is not very likely in commit messages, but I thought I'd mention nevertheless.)

Cheers,
-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
- Are you sure we're good?
- Always.
                -- Rory and Lorelai
Christian MICHON· Jan 23, 2009, 08:08 UTC · re: Junio C Hamano · lore

Re: how to force a commit date matching info from a mbox ?

On Fri, Jan 23, 2009 at 1:14 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Christian MICHON <christian.michon@gmail.com> writes:
>
>> I'd like to force the commit date to match the info/date from the time
>> I received the email (and therefore always get back the right
>> sha1sums).
>>
>> is this possible ?
>
> "am" being a tool to accept patches written in some past to faithfully
> record both author timestamp and committer timestamp, what you seem to
> want is outside of the current scope of the tool.
>
> A patch to butcher "git-am" to copy GIT_COMMITTER_DATE from
> GIT_AUTHOR_DATE and export it should be trivial to implement, though.
>
> Perhaps something like this totally untested patch.
>
I love this idea. I'll try to test it asap. Thanks!
-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !
Christian MICHON· Jan 23, 2009, 08:51 UTC · re: Christian MICHON · lore

Re: how to force a commit date matching info from a mbox ?

On Fri, Jan 23, 2009 at 9:08 AM, Christian MICHON <christian.michon@gmail.com> wrote:

Show 8 quoted lines
>> A patch to butcher "git-am" to copy GIT_COMMITTER_DATE from
>> GIT_AUTHOR_DATE and export it should be trivial to implement, though.
>>
>> Perhaps something like this totally untested patch.
>>
>
> I love this idea. I'll try to test it asap. Thanks!
>
working fine! I've predictable/reproducible commits with this patch!
many thanks and kudos!
-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !
Johannes Schindelin· Jan 23, 2009, 00:21 UTC · re: Christian MICHON · lore

Re: how to force a commit date matching info from a mbox ?

Hi,
On Thu, 22 Jan 2009, Christian MICHON wrote:
Show 10 quoted lines
> I've a big set of patches in a mbox file: there's sufficient info inside 
> for git-am to work.
> 
> Yet, each time I do import these, my sha1sums are changing because of 
> different commit dates.
> 
> I'd like to force the commit date to match the info/date from the time I 
> received the email (and therefore always get back the right sha1sums).
> 
> is this possible ?
Have you tried setting GIT_COMMITTER_DATE to the given date?

Alternatively, you can always use a commit-message filter with filter-branch to fix it up.

Ciao, Dscho

Christian MICHON· Jan 23, 2009, 08:07 UTC · re: Johannes Schindelin · lore

Re: how to force a commit date matching info from a mbox ?

On Fri, Jan 23, 2009 at 1:21 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 16 quoted lines
> Hi,
>
> On Thu, 22 Jan 2009, Christian MICHON wrote:
>
>> I've a big set of patches in a mbox file: there's sufficient info inside
>> for git-am to work.
>>
>> Yet, each time I do import these, my sha1sums are changing because of
>> different commit dates.
>>
>> I'd like to force the commit date to match the info/date from the time I
>> received the email (and therefore always get back the right sha1sums).
>>
>> is this possible ?
>
> Have you tried setting GIT_COMMITTER_DATE to the given date?
yes, I did. This is what I want to change: I can fix the same
GIT_COMMITTER_DATE for all patches in the mbox, but I really want +
                   GIT_COMMITTER_DATE=GIT_AUTHOR_DATE
Show 7 quoted lines
>
> Alternatively, you can always use a commit-message filter with
> filter-branch to fix it up.
>
> Ciao,
> Dscho
>

I'm curious if this could be done: the problem I quickly faced was that this approach would double the amount of commits.

So I'm eager to test Junio's patch :)
-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !

← back to recent threads