diff options
author | Barak A. Pearlmutter <barak+git@cs.nuim.ie> | 2012-07-12 12:50:58 +0100 |
---|---|---|
committer | Barak A. Pearlmutter <barak+git@cs.nuim.ie> | 2012-07-12 12:50:58 +0100 |
commit | 4a2dd3b83b40d7882987073f7f07fc573155ce0e (patch) | |
tree | 6dea995264c28fade0dc38c3cb7040fd6308ad21 | |
parent | 6dc88e1670387c90a59e6ff2de0b4aff37ca1688 (diff) | |
download | hg-fast-export-4a2dd3b83b40d7882987073f7f07fc573155ce0e.tar.gz |
Use approved git plumbing to locate git directory, instead of just .git/xxx.
-rwxr-xr-x[-rw-r--r--] | debian/git-hg | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/debian/git-hg b/debian/git-hg index 509d8c0..4b7bf1d 100644..100755 --- a/debian/git-hg +++ b/debian/git-hg @@ -36,6 +36,14 @@ function canonicalize { printf "%s/%s\n" "$cdir" "$file" } +function get-gitdir { + if [ -n "${GIT_DIR}" ]; then + echo "error: environment variable GIT_DIR must not be set" + exit 1 + fi + GITDIR="$(git rev-parse --git-dir)" +} + function git-current-branch { git branch | egrep '^[*]' | sed 's/^\* \(.\)/\1/' } @@ -81,18 +89,19 @@ function git-hg-clone { git init $CHECKOUT ( cd $CHECKOUT - hg clone -U $HG_REMOTE .git/hgcheckout - git init --bare .git/hgremote + get-gitdir + hg clone -U $HG_REMOTE ${GITDIR}/hgcheckout + git init --bare ${GITDIR}/hgremote ( - cd .git/hgremote + cd ${GITDIR}/hgremote $HG_FAST_EXPORT -r ../hgcheckout $FORCE ) - git remote add hg .git/hgremote + git remote add hg ${GITDIR}/hgremote git fetch hg if git branch -r | grep -q master; then local branch="master" else - local branch=$(cd .git/hgcheckout/ && hg tip | grep branch | awk '{print $2}') + local branch=$(cd ${GITDIR}/hgcheckout/ && hg tip | grep branch | awk '{print $2}') fi git config hg.tracking.master $branch git pull hg $branch @@ -105,9 +114,10 @@ function git-hg-fetch { FORCE="--force" shift fi - hg -R .git/hgcheckout pull + get-gitdir + hg -R ${GITDIR}/hgcheckout pull ( - cd .git/hgremote + cd ${GITDIR}/hgremote $HG_FAST_EXPORT $FORCE ) git fetch hg @@ -171,8 +181,9 @@ function git-hg-checkout { function git-hg-push { HG_REPO=$1 - hg convert . .git/hgcheckout - hg -R .git/hgcheckout push $HG_REPO + get-gitdir + hg convert . ${GITDIR}/hgcheckout + hg -R ${GITDIR}/hgcheckout push $HG_REPO } function usage { |