{"thread":{"id":"26466","subject":"Unknown software revision","startedAt":"2011-02-10T22:33:47Z","lastAt":"2011-02-10T23:22:35Z","messageCount":2,"participants":["Jason Brooks","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"160845","messageId":"733D558A-0935-42A8-BA5B-7B97703656F6@gmail.com","threadId":"26466","inReplyTo":null,"subject":"Unknown software revision","fromName":"Jason Brooks","fromEmail":"jasonbbrooks@gmail.com","sentAt":"2011-02-10T22:33:47Z","receivedAt":"2011-02-10T22:33:47Z","isPatch":false,"sender":{"key":"jasonbbrooks@gmail.com","avatar":null},"body":"Hello,\n\nI am not sure what I am asking, so I thought I would start here.  If I\nknew the name of this operation, I would look for it.  :)\n\nI have also posted to the git-users google group, but signs there tell  \nme this is the better place.\n\nI have a software deployment that was copied out of a git repository\nbut without the .git directories.  Thus, I have no idea what revision\nthis deployment is, so I don't know how to upgrade from git.  Is there a\nmethod, or script out there that can help me?\n\nThe trouble is, I should have made a branch or tag when I deployed it  \nto at\nleast freeze that version.  At the very least so I can rebase and re-\ndeploy it again.  (I could be wrong about this last statement: I am  \ndefinitely new to git)\n\nI appreciate any assistance you all can give me...\n\n--jason\n"},{"id":"160852","messageId":"20110210232235.GC21335@sigill.intra.peff.net","threadId":"26466","inReplyTo":"733D558A-0935-42A8-BA5B-7B97703656F6@gmail.com","subject":"Re: Unknown software revision","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-02-10T23:22:35Z","receivedAt":"2011-02-10T23:22:35Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 10, 2011 at 02:33:47PM -0800, Jason Brooks wrote:\n\n> I have a software deployment that was copied out of a git repository\n> but without the .git directories.  Thus, I have no idea what revision\n> this deployment is, so I don't know how to upgrade from git.  Is there a\n> method, or script out there that can help me?\n\nDoes your set of files match what was in the git tree _exactly_? Or\nmight there be minor changes, new files, etc?\n\nIf it should match exactly, you can figure out what tree git would have\nmade out of this content:\n\n  git init\n  git add .\n  git commit -m foo\n  tree=`git rev-parse HEAD^{tree}`\n\nAnd now you can search in the actual git repository for that tree:\n\n  $ git log --pretty=raw -z | perl -0lne 'print $_, \"\\n\" if /^tree '$tree'$/m'\n\nBut obviously that is all based on the hashes of the content, so if even\na single byte is missing, added, or different in your deployed copy, you\nwon't find a match.\n\nIn that case, your best bet is probably to script a bunch of diffs and\nsee which commit ends up closest. I would do something like:\n\n  1. From the deployed version, prepare your best guess about what the\n     git directory would have looked like. Put it in a directory\n     \"deployed\".\n\n  2. Now make a git commit from the deployed state:\n\n       cd deployed\n       git init\n       git add .\n       git commit -m 'deployed version'\n\n  3. In the original git repo, fetch the deployed version in so you\n     can diff against it.\n\n       cd /path/to/real/git/repo\n       git fetch /path/to/deployed master:deployed\n\n  4. Now you can try diffing \"deployed\" against every commit in the real\n     repo and see what comes closest. Here I'll just count up changed\n     lines to assign a score to each commit and show the one with the\n     fewest changes:\n\n       git rev-list HEAD | while read commit; do\n         git diff-tree --numstat $commit deployed |\n         perl -ane '$total += $F[0] + $F[1];\n                    END { print $total }'\n         echo \" $commit\"\n       done | sort -n\n\nThe top of the resulting list is the closest commit. Check it out with\n\"git show\" to see if it makes sense.\n\nHope that helps.\n\n-Peff\n"}]}