Skip to content

Instantly share code, notes, and snippets.

@Gumnos
Forked from thwarted/rcs2git
Created February 12, 2012 03:51
Show Gist options
  • Select an option

  • Save Gumnos/1806119 to your computer and use it in GitHub Desktop.

Select an option

Save Gumnos/1806119 to your computer and use it in GitHub Desktop.

Revisions

  1. Gumnos revised this gist Feb 12, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rcs2git
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ for rcsfile in "$@" ; do
    rcsfile="$( echo "$rcsfile" | sed -e 's/,v$//;' )"
    echo "$rcsfile"

    for rev in $( rlog $rcsfile | grep '^revision ' | awk '{ print $2 }' | awk -F. '{print $2}' | sort -n ); do
    for rev in $( rlog $rcsfile | awk '/^revision/{ print $2 }' | awk -F. '{print $2}' | sort -n ); do
    loginfo="$( rlog -r1.$rev $rcsfile | grep '^date: ' | tr ';' '\n' | sed -e 's/^ \+//;' )"
    # 2010/03/05 16:09:26
    # 2005-04-07T22:13:13
  2. Gumnos revised this gist Feb 12, 2012. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions rcs2git
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,12 @@ fi
    set -e
    #set -x

    #rm -rf .git
    git init
    if [ -d .git ]; then
    echo ".git dir already exists! (cowardly bailing)"
    exit 0
    else
    git init
    fi

    # brute force, doesn't support tags or anything other than plain check-ins of individual files
    # kinda sloppy in general
  3. @thwarted thwarted created this gist Mar 23, 2010.
    53 changes: 53 additions & 0 deletions rcs2git
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    #!/bin/bash

    email_domain=example.com
    export email_domain

    # so nothing in the environment comes through
    unset GIT_AUTHOR_EMAIL
    unset GIT_AUTHOR_DATE
    unset GIT_AUTHOR_NAME
    unset GIT_COMMITTER_NAME
    unset GIT_COMMITTER_EMAIL
    export GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE GIT_AUTHOR_NAME GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL

    if [ -z "$*" ]; then
    echo "Usage: $0 *,v" >&2
    exit 0
    fi

    set -e
    #set -x

    #rm -rf .git
    git init

    # brute force, doesn't support tags or anything other than plain check-ins of individual files
    # kinda sloppy in general
    # first we get all the revisions and sort by edit date, then sort that to check them in the right order
    (
    for rcsfile in "$@" ; do
    rcsfile="$( echo "$rcsfile" | sed -e 's/,v$//;' )"
    echo "$rcsfile"

    for rev in $( rlog $rcsfile | grep '^revision ' | awk '{ print $2 }' | awk -F. '{print $2}' | sort -n ); do
    loginfo="$( rlog -r1.$rev $rcsfile | grep '^date: ' | tr ';' '\n' | sed -e 's/^ \+//;' )"
    # 2010/03/05 16:09:26
    # 2005-04-07T22:13:13
    commitdate="$( echo "$loginfo" | grep date: | sed -e 's/^[^:]\+: //;' | sed -e 's/^ //; s!/!-!g; s/ /T/g;' )"
    GIT_AUTHOR_DATE="$commitdate"
    commitauthor="$( echo "$loginfo" | grep author: | sed -e 's/^[^:]\+: //;' )"
    EMAIL="$commitauthor@$email_domain"
    GIT_AUTHOR_NAME="$commitauthor"
    /bin/echo -e "$GIT_AUTHOR_DATE\t$rev\t$EMAIL\t$GIT_AUTHOR_NAME\t$rcsfile"
    done
    done
    ) | sort | while read GIT_AUTHOR_DATE rev EMAIL GIT_AUTHOR_NAME rcsfile; do
    GIT_COMMITER_NAME=$GIT_AUTHOR_NAME
    export GIT_AUTHOR_DATE rev EMAIL GIT_AUTHOR_NAME rcsfile GIT_COMMITTER_NAME
    co -r1.$rev $rcsfile
    git add $rcsfile
    logmsg="$( rlog -r1.$rev $rcsfile | perl -e '$_=<> until (m/^date:.+author: /); while ($_=<>) { print $_ if !m/^=====/ }' )"
    git commit -m "$logmsg"
    echo "committed rev 1.$rev of $rcsfile" >&2
    done