git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Yakov Lerner <iler.ml@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: sha1 of the repo excluding history ?
Date: Thu, 12 Apr 2007 19:40:32 -0400	[thread overview]
Message-ID: <20070412234032.GE12979@spearce.org> (raw)
In-Reply-To: <f36b08ee0704121626i6a27dcecp8b0b10e0f7db2ef7@mail.gmail.com>

Yakov Lerner <iler.ml@gmail.com> wrote:
>    Can I obtain from git the sha1 of the total last state of the
> repo excluding history ? This is a state that covers contents and
> names of all files and dirs, and x perm of files;
> but excludes history, timestamps, ownerhisp, and inode numbers.
> 
> That would be approximately like the slow method:
>          'find | egrep -v '/\.git(/|$)' | sort | Xcpio -o | sha1sum -'
> (imagining Xcpio that does not archive any ownership, timestamps,
> and inode numbers). Can I obtain this result immediately from git ?

	git rev-parse HEAD^{tree}

The trick here is ^{tree}; this operator takes a commit-ish (commit
or tag) and returns the SHA-1 of the tree that the commit-ish
points at.  That SHA-1 is the SHA-1 of the file contents, names,
and executable bits, but nothing else.  No history.

I use it sometimes after a rebase when I reorganize history:

	old=`git rev-parse HEAD^{tree}`
	.... do rebasing magick ...
	test $old = `git rev-parse HEAD^{tree}` && echo GOOD

If I don't get back GOOD then I know I somehow changed the files in
a way that isn't what I had before, and that wasn't what I wanted
if all I was doing was cleaning up commit messages.

-- 
Shawn.

  reply	other threads:[~2007-04-12 23:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-12 23:26 sha1 of the repo excluding history ? Yakov Lerner
2007-04-12 23:40 ` Shawn O. Pearce [this message]
2007-04-13  0:24 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070412234032.GE12979@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=iler.ml@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).