sha1 of the repo excluding history ?

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

sha1 of the repo excluding history ?

From: Yakov Lerner <hidden>
Date: 2016-06-15 22:43:04

    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 ?

Yakov

Re: sha1 of the repo excluding history ?

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:04

Yakov Lerner [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help