Refer to the utility's name in the commit message.
[parsecvs/imz-RCS2git-use-cases.git] / parsecvs-as-sidehist
blob887fd01beaa555be17f0ac3b0cc34dbbae191200
1 #!/bin/bash
3 # $Id$
4 # Description:
5 # Adds the result of parsecvs as a side history (with the specified prefix) to the local existing Git repository.
6 # I intend to use it for translating RCS histories for individual files into Git as independent histories (parseRCS-indep).
7 # I will manually merge the results of parseRCS-indep to form a good Git history of the tree
8 # (manual merging can give better results than parsecvs in cases when CVS hasn't been used, but there are merely RCS histories).
10 # Author: Ivan Zakharyaschev imz at altlinux dot org, March 2009.
11 # I publish it under GPL (as parsecvs is published).
13 set -e
15 usage() {
16 printf $"Usage: %s REMOTENAME ... , where ... stands for parsecvs args.\n" "$0"
19 if [[ $# < 1 ]]; then
20 usage
21 exit 1
24 readonly REMOTE="$1"
25 shift
27 readonly WORK_DIR="$(mktemp -d --tmpdir parsecvs-"$(basename "$REMOTE")".XXXXXX)"
28 # -- basename is needed to make / possible in the branchnames.
29 # I'll remove the temp dir only if the script completes successfully;
30 # otherwise, let it stay for investigation.
31 failed() {
32 printf $"%s failed; investigate in %s.\n" "$0" "$WORK_DIR"
34 trap failed ERR
36 GIT_DIR="$WORK_DIR"/.git parsecvs "$@"
38 git fetch "$WORK_DIR" refs/heads/*:"$REMOTE"/*
39 # Sensible are: refs/PREFIX/... (then it can be seen in gitk),
40 # refs/remotes/PREFIX/... (then "git branch -a" shows it);
41 # one of these variants will be used in the wrapper that makes a forest.
43 echo $"Cleaning up:"
44 rm -rf "$WORK_DIR" && printf $"%s removed.\n" "$WORK_DIR"