git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why 'git commit --amend' generates different HEAD sha1 each time when no content changes
@ 2007-12-30 10:56 Ping Yin
       [not found] ` <1199012360.15996.6.camel@futex>
  0 siblings, 1 reply; 3+ messages in thread
From: Ping Yin @ 2007-12-30 10:56 UTC (permalink / raw)
  To: Git Mailing List

AFAIK, commit sha1 is only determined by commit object content (say
parent commit, tree sha1 and so on). So why 'git commit --amend'
changes the commit sha1 when no content changes as following shows.

$ mkdir A && cd A && echo foo >foo

$ git init && git add foo && git commit -m 'add file foo'

Created initial commit 8626800: add file foo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo

$ git commit --amend
Created commit 3591035: add file foo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo

$ git commit --amend
Created commit 3927d9a: add file foo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo

-- 
Ping Yin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why 'git commit --amend' generates different HEAD sha1 each time when no content changes
       [not found] ` <1199012360.15996.6.camel@futex>
@ 2007-12-30 11:19   ` Ping Yin
  2007-12-30 11:20   ` Ping Yin
  1 sibling, 0 replies; 3+ messages in thread
From: Ping Yin @ 2007-12-30 11:19 UTC (permalink / raw)
  To: Matthias Kestenholz; +Cc: Git Mailing List

On Dec 30, 2007 6:59 PM, Matthias Kestenholz <mk@spinlock.ch> wrote:
>
> On Sun, 2007-12-30 at 18:56 +0800, Ping Yin wrote:
> > AFAIK, commit sha1 is only determined by commit object content (say
> > parent commit, tree sha1 and so on). So why 'git commit --amend'
> > changes the commit sha1 when no content changes as following shows.
> >
>
> The full commit includes a timestamp too, which changed. Try setting the
> GIT_AUTHOR_DATE and GIT_COMMITTER_DATE environment variables, you should
> get the same SHA-1 everytime.
>



-- 
Ping Yin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Why 'git commit --amend' generates different HEAD sha1 each time when no content changes
       [not found] ` <1199012360.15996.6.camel@futex>
  2007-12-30 11:19   ` Ping Yin
@ 2007-12-30 11:20   ` Ping Yin
  1 sibling, 0 replies; 3+ messages in thread
From: Ping Yin @ 2007-12-30 11:20 UTC (permalink / raw)
  To: Matthias Kestenholz; +Cc: Git Mailing List

On Dec 30, 2007 6:59 PM, Matthias Kestenholz <mk@spinlock.ch> wrote:
>
> On Sun, 2007-12-30 at 18:56 +0800, Ping Yin wrote:
> > AFAIK, commit sha1 is only determined by commit object content (say
> > parent commit, tree sha1 and so on). So why 'git commit --amend'
> > changes the commit sha1 when no content changes as following shows.
> >
> The full commit includes a timestamp too, which changed. Try setting the
> GIT_AUTHOR_DATE and GIT_COMMITTER_DATE environment variables, you should
> get the same SHA-1 everytime.
>

Thanks. With 'git show --pretty=fuller', I find that commit date
changes each time and that author date keeps the same.



-- 
Ping Yin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-12-30 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-30 10:56 Why 'git commit --amend' generates different HEAD sha1 each time when no content changes Ping Yin
     [not found] ` <1199012360.15996.6.camel@futex>
2007-12-30 11:19   ` Ping Yin
2007-12-30 11:20   ` Ping Yin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).