{"thread":{"id":"38366","subject":"Bulk dump of git metadata / getting git metadata into a database","startedAt":"2015-01-15T02:08:18Z","lastAt":"2015-01-15T02:08:18Z","messageCount":1,"participants":["Daniel J Clark UNMONITORED EMAIL ADDRESS"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"254719","messageId":"CAJJ6HBC+VWL+DN5P2zMtd6v_+pO8q9DZRfj3AbwdQBk_=fFYGA@mail.gmail.com","threadId":"38366","inReplyTo":null,"subject":"Bulk dump of git metadata / getting git metadata into a database","fromName":"Daniel J Clark UNMONITORED EMAIL ADDRESS","fromEmail":"noreply@danjcla.com","sentAt":"2015-01-15T02:08:18Z","receivedAt":"2015-01-15T02:08:18Z","isPatch":false,"sender":{"key":"noreply@danjcla.com","avatar":null},"body":"I'm wondering if anyone happens to know of software to dump all a git\nrepo's metadata, both stored and derived, to a format - sql, xml, csv,\nwhatever - that is easily importable into a database / manipulated\nprogrammatically.\n\n\n\nBackground, for the interested:\n\nThere is git repo HAPPY and and a separate git repo with branch SAD.\n\nRepo HAPPY is canonical; branch SAD is in a separate fork repo. Files\nfrom HAPPY have been copied over on an irregular basis to SAD. So SAD\nhas a mixture of files that are exactly the same as (the one in some\ncommit to) HAPPY, and files that have diverged since the initial copy\nover from HAPPY as per the needs of the SAD fork.\n\nThe end goal is to get a diff that shows only fork-specific changes.\nIdentify the common file ancestor, and then diff the most recent\nfork'ed file against that. Or put another way:\n\n(a) Remove any files from SAD's most recent commit that are exactly\nthe same as any commit to HAPPY.\n\n(b) For each file still in SAD's most recent commit, walk backwards in\nSAD until a version is found that exists in HAPPY.\n\nFor (a) the below two git commands plus a little scripting look like enough:\n\n# HAPPY: Get all file hases for a repo\ngit verify-pack -v .git/objects/pack/*.idx > HAPPY.hashes\ngrep ' blob   ' git.hashes | awk '{print $1}' > HAPPY.blobs\n\n# SAD: Get hases and paths from current checkout\ngit ls-files --full-name -s | awk '{print $2\" \"$4}' > SAD.blobs\n\nI haven't looked into (b) as much yet, but at the moment I'm thinking\nof using git log to get a chronological list of commit hashes, then\nwalk backwards, at each checkout using git ls-files to dump the tree's\nhashes to a separate file.\n\n-- \nDaniel J Clark - off-list: djc @ first initial last name . us\n"}]}