Skip to content

Instantly share code, notes, and snippets.

@lewiseason
Last active Aug 29, 2015
Embed
What would you like to do?
Move Tags when Rewriting History
while (<>) {
chomp($_);
($old, $tag, $message) = split("\0", $_);
# Escape double quotes
$message =~s/"/\\"/g;
@matches = split("\n", `git log --all --oneline --grep="^$message\$"`);
$count = @matches;
if ($count == 1){
($new, $dummy) = split(' ', $matches[0], 2);
print "$tag\t${old}->${new}\n";
`git tag -a "$tag" $new -f -m "$message"`;
} else {
print "* Problem with $tag. Hash was $old, message was: $message\n";
}
}
while (<>) {
chomp($_);
($hash, $tag) = split(' ', $_);
($short, $message) = split(' ', `git log -1 --oneline $hash`, 2);
chomp($message);
print "$short\0$tag\0$message\n";
`git tag -d $tag`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment