Skip to content

Instantly share code, notes, and snippets.

@mdaniel
Created March 1, 2012 21:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdaniel/1953425 to your computer and use it in GitHub Desktop.
Save mdaniel/1953425 to your computer and use it in GitHub Desktop.
regenerate git-svn .rev_map file
#! /usr/bin/env gawk -f
# git --no-pager log | gawk -f this-script > revmap.txt
# xxd -c 24 -r revmap.txt \
# .git/svn/refs/remotes/trunk/.rev_map.cfe28804-0f27-0410-a406-dd0f0b0b656f
# 0000000: 0000 0001 cce6 285e 48e1 e3cc 0d7d 0617 beb0 4e88 a126 8634
# 0000018: 0000 0006 6e4f ada4 bed4 6660 c987 dc74 1243 8973 16cc c810
BEGIN {
FS=" "
# this number comes from ``git --no-pager log | grep ^commit | wc -l``
# and is ZERO-indexed because the last xxd will begin with 0000
# you might be tempted to think it is the highest r-number, but no,
# because evidently not every subversion commit made it to git
cnt=30554
}
/^commit / {
cmit=$2
}
/git-svn/ {
# remove everything except the r-number
sub(/[^@]+@/,"")
# remove the repository-id
sub(/ .*$/,"")
addr=cnt * 24
# thankfully, xxd is tolerant of not having
# any spaces, so we can just dump the commitish
# right into the file
printf "%08x: %08x%s \n", addr, $0, cmit
cnt = cnt - 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment