{"thread":{"id":"25010","subject":"Better way to find commit from tarball?","startedAt":"2010-09-06T19:55:07Z","lastAt":"2010-09-06T20:05:08Z","messageCount":2,"participants":["Todd A. Jacobs","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"150115","messageId":"AANLkTi=ZnZppPu8tT3-sUG6zZM8YnonPwMG_XZhO03up@mail.gmail.com","threadId":"25010","inReplyTo":null,"subject":"Better way to find commit from tarball?","fromName":"Todd A. Jacobs","fromEmail":"tjacobs@si2services.com","sentAt":"2010-09-06T19:55:07Z","receivedAt":"2010-09-06T19:55:07Z","isPatch":false,"sender":{"key":"tjacobs@si2services.com","avatar":null},"body":"Someone handed me a tarball that represented an unknown release from a\nproject. Here's what I came up with to identify the commit:\n\n    cd $SOME_WORK_DIR\n    find . -path ./.git -prune -o -print0 | xargs -0 rm\n    tar xvfz $TARBALL\n    for commit in {0..100}; do\n        id=\"master~${commit}\"\n        if git diff --quiet --exit-code \"$id\"\n        then\n            echo \"Matched on commit $id\"\n            break\n        fi\n    done\n\nSomeone please tell me there's an easier way to find a matching tree\nwhen handed a tarball. This works, but seems cumbersome.\n"},{"id":"150118","messageId":"20100906200508.GA26371@burratino","threadId":"25010","inReplyTo":"AANLkTi=ZnZppPu8tT3-sUG6zZM8YnonPwMG_XZhO03up@mail.gmail.com","subject":"Re: Better way to find commit from tarball?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-06T20:05:08Z","receivedAt":"2010-09-06T20:05:08Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Todd A. Jacobs wrote:\n\n>     cd $SOME_WORK_DIR\n>     find . -path ./.git -prune -o -print0 | xargs -0 rm\n>     tar xvfz $TARBALL\n>     for commit in {0..100}; do\n>         id=\"master~${commit}\"\n>         if git diff --quiet --exit-code \"$id\"\n>         then\n>             echo \"Matched on commit $id\"\n>             break\n>         fi\n>     done\n> \n> Someone please tell me there's an easier way to find a matching tree\n> when handed a tarball. This works, but seems cumbersome.\n\nIf you are lucky and they used \"git archive\":\n\n\tgunzip <$TARBALL | git get-tar-commit-id\n\nOtherwise: maybe something like this[1] will work.\n\n\ttar_id=$(\n\t\tgit init tarball &&\n\t\tcd tarball &&\n\t\tperl /usr/share/doc/git/contrib/fast-import/import-tars.perl $TARBALL &&\n\t\tgit rev-parse --verify HEAD:\n\t) &&\n\trm -fr tarball &&\n\tgit rev-list --full-history --format='%h %T' HEAD |\n\tgrep \" $tar_id\\$\"\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/44750/focus=44849\n"}]}