{"thread":{"id":"7635","subject":"sha1 of the repo excluding history ?","startedAt":"2007-04-12T23:26:40Z","lastAt":"2007-04-13T00:24:15Z","messageCount":3,"participants":["Yakov Lerner","Shawn O. Pearce","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"39245","messageId":"f36b08ee0704121626i6a27dcecp8b0b10e0f7db2ef7@mail.gmail.com","threadId":"7635","inReplyTo":null,"subject":"sha1 of the repo excluding history ?","fromName":"Yakov Lerner","fromEmail":"iler.ml@gmail.com","sentAt":"2007-04-12T23:26:40Z","receivedAt":"2007-04-12T23:26:40Z","isPatch":false,"sender":{"key":"iler.ml@gmail.com","avatar":null},"body":"    Can I obtain from git the sha1 of the total last state of the\nrepo excluding history ? This is a state that covers contents and\nnames of all files and dirs, and x perm of files;\nbut excludes history, timestamps, ownerhisp, and inode numbers.\n\nThat would be approximately like the slow method:\n          'find | egrep -v '/\\.git(/|$)' | sort | Xcpio -o | sha1sum -'\n(imagining Xcpio that does not archive any ownership, timestamps,\nand inode numbers). Can I obtain this result immediately from git ?\n\nYakov\n"},{"id":"39246","messageId":"20070412234032.GE12979@spearce.org","threadId":"7635","inReplyTo":"f36b08ee0704121626i6a27dcecp8b0b10e0f7db2ef7@mail.gmail.com","subject":"Re: sha1 of the repo excluding history ?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-04-12T23:40:32Z","receivedAt":"2007-04-12T23:40:32Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Yakov Lerner <iler.ml@gmail.com> wrote:\n>    Can I obtain from git the sha1 of the total last state of the\n> repo excluding history ? This is a state that covers contents and\n> names of all files and dirs, and x perm of files;\n> but excludes history, timestamps, ownerhisp, and inode numbers.\n> \n> That would be approximately like the slow method:\n>          'find | egrep -v '/\\.git(/|$)' | sort | Xcpio -o | sha1sum -'\n> (imagining Xcpio that does not archive any ownership, timestamps,\n> and inode numbers). Can I obtain this result immediately from git ?\n\n\tgit rev-parse HEAD^{tree}\n\nThe trick here is ^{tree}; this operator takes a commit-ish (commit\nor tag) and returns the SHA-1 of the tree that the commit-ish\npoints at.  That SHA-1 is the SHA-1 of the file contents, names,\nand executable bits, but nothing else.  No history.\n\nI use it sometimes after a rebase when I reorganize history:\n\n\told=`git rev-parse HEAD^{tree}`\n\t.... do rebasing magick ...\n\ttest $old = `git rev-parse HEAD^{tree}` && echo GOOD\n\nIf I don't get back GOOD then I know I somehow changed the files in\na way that isn't what I had before, and that wasn't what I wanted\nif all I was doing was cleaning up commit messages.\n\n-- \nShawn.\n"},{"id":"39252","messageId":"7v7ishi0k0.fsf@assigned-by-dhcp.cox.net","threadId":"7635","inReplyTo":"f36b08ee0704121626i6a27dcecp8b0b10e0f7db2ef7@mail.gmail.com","subject":"Re: sha1 of the repo excluding history ?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-13T00:24:15Z","receivedAt":"2007-04-13T00:24:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Yakov Lerner\" <iler.ml@gmail.com> writes:\n\n>    Can I obtain from git the sha1 of the total last state of the\n> repo excluding history ? This is a state that covers contents and\n> names of all files and dirs, and x perm of files;\n> but excludes history, timestamps, ownerhisp, and inode numbers.\n>\n> That would be approximately like the slow method:\n>          'find | egrep -v '/\\.git(/|$)' | sort | Xcpio -o | sha1sum -'\n> (imagining Xcpio that does not archive any ownership, timestamps,\n> and inode numbers). Can I obtain this result immediately from git ?\n>\n> Yakov\n\nI think you are talking about tree object name.  git-cat-file\ncommit HEAD and look at \"tree xxx\" line.\n\nYou can use \"git tar-tree $tree_object_name\" to tar it up,\nand \"git ls-tree -r $tree_object_name\" to list all the blob\nobject names with their perms.\n"}]}