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 GPLv2 or later (as parsecvs is published).
16 printf $
"Usage: %s REMOTENAME ... , where ... stands for parsecvs args.\n" "$0"
17 echo $
"A sensible value for REMOTENAME is refs/remotes/PREFIX/... ."
33 printf "%s will use %s as the ref to the new history.\n" "$0" "$REMOTE"
35 readonly WORK_DIR
="$(mktemp -d --tmpdir parsecvs-"$
(basename "$REMOTE")".XXXXXX)"
36 # -- basename is needed to make / possible in the branchnames.
37 # I'll remove the temp dir only if the script completes successfully;
38 # otherwise, let it stay for investigation.
40 printf $
"%s failed; investigate in %s.\n" "$0" "$WORK_DIR"
44 GIT_DIR
="$WORK_DIR"/.git parsecvs
"$@"
46 # Since I intend to use it multiple successive times for independent files (parseRCS-indep),
47 # I append the info about the fetched history to FETCH_HEAD.
48 # For cleanness, rm .git/FETCH_HEAD.
49 git fetch
--append "$WORK_DIR" refs
/heads
/*:"$REMOTE"/*
50 # Sensible are: refs/PREFIX/... (then it can be seen in gitk),
51 # refs/remotes/PREFIX/... (then "git branch -a" shows it);
52 # one of these variants will be used in the wrapper that makes a forest.
54 printf $
"The ref to the fetched history has been appended to FETCH_HEAD and stored as %s.\n" "$REMOTE"
57 rm -rf "$WORK_DIR" && printf $
"%s removed.\n" "$WORK_DIR"