warbo-utilities: b8916f0d5072ef507a36497a0e8cd1dce534c08c

     1: #!/usr/bin/env bash
     2: set -e
     3: 
     4: # Copies a file from one git repo to another, by making a patch containing that
     5: # file's history. Taken from https://stackoverflow.com/a/11426261/884682
     6: 
     7: [[ -d ".git" ]] ||
     8:     fail "git-migrate-file should run from source repo root, but no .git found"
     9: 
    10: TO="$2"
    11: FILE="$1"
    12: 
    13: [[ -n "$FILE" ]] ||
    14:     fail "First arg should be path to copy, none given (second should be dest)"
    15: 
    16: [[ -n "$TO" ]] ||
    17:     fail "Second arg should be destination, none given (first should be file)"
    18: 
    19: [[ -d "$TO/.git" ]] ||
    20:     fail "Destination '$TO' doesn't seem to be a git repo (no .git dir)"
    21: 
    22: echo "Copying '$FILE' from '$PWD' to '$TO'" 1>&2
    23: git log --pretty=email --patch-with-stat --reverse -- "$FILE" |
    24:     (cd "$TO" && git am)

Generated by git2html.