-
Notifications
You must be signed in to change notification settings - Fork 0
/
darcs-to-git
executable file
·52 lines (45 loc) · 1.43 KB
/
darcs-to-git
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
set -e -o pipefail
GITBRANCH=master # sadly, no other banrch can be inported from darcs
GITDIR=$1
DARCSDIR=$PWD
MARKS=${GITBRANCH}-darcsmarks
test -z $GITDIR && echo "usage: $0 GITDIR [--push]" >&2
rm -f git.marks darcs.marks
if [[ ! -d $GITDIR/.git ]] || ! ( cd $GITDIR && git branch -a | grep -q $MARKS ); then
if [[ ! -d $GITDIR/.git ]]; then
mkdir -p $GITDIR
git init $GITDIR
fi
cd $GITDIR;
git checkout --orphan $MARKS
git reset --hard
touch {git,darcs}.marks
git stage {git,darcs}.marks
git commit -m "darcs: Initialize."
git checkout --orphan $GITBRANCH
git reset --hard
git branch
cd $DARCSDIR
touch git.marks
else
(cd $GITDIR; git checkout $MARKS; cp darcs.marks git.marks $DARCSDIR; git checkout $GITBRANCH)
fi
darcs convert export --read-marks darcs.marks --write-marks darcs.marks \
| (cd $GITDIR && git fast-import --import-marks=$DARCSDIR/git.marks --export-marks=$DARCSDIR/git.marks)
cd $GITDIR
git reset --hard # import sometimes deletes some files in local copy
git checkout $MARKS
cp $DARCSDIR/{git,darcs}.marks .
git stage {git,darcs}.marks
git commit -m "darcs: Import newest revision." || true
git checkout $GITBRANCH
cd $DARCSDIR
rm -f git.marks darcs.marks
if [[ $2 = '--push' ]]; then
cd $GITDIR
git checkout $MARKS
git push --set-upstream origin $MARKS
git checkout $GITBRANCH
git push --set-upstream origin master
fi