From: martin f. krafft Date: Mon, 3 Mar 2008 19:10:55 +0000 (+0100) Subject: factor out extracting the worktree to a function X-Git-Url: https://git.madduck.net/code/myrepos.git/commitdiff_plain/a3ee557bc0c0e9dc6dfafdbf0c6c4103b4521099?ds=inline factor out extracting the worktree to a function (cherry picked from commit 8a8e85c5d8ca8fbddc6ac61de3c125cbe14d189a) --- diff --git a/lib/git-fake-bare b/lib/git-fake-bare index 0c33934..3ffcccc 100644 --- a/lib/git-fake-bare +++ b/lib/git-fake-bare @@ -28,6 +28,18 @@ lib = mv .git/* . rmdir .git } + git_get_worktree() { + local worktree + worktree="$(git config --get core.worktree)" || true + if [ -z "$worktree" ]; then + error "git worktree is not set" + fi + worktree="${worktree%%/}/" + if [ ! -d "$worktree" ]; then + error "git worktree $worktree does not exist" + fi + echo "$worktree" + } git_fake_bare_test = test -d "$MR_REPO"/refs/heads && test -d "$MR_REPO"/refs/tags && @@ -54,14 +66,7 @@ git_fake_bare_register = if [ -z "$url" ]; then error "cannot determine git url" fi - worktree="$(git config --get core.worktree)" || true - if [ -z "$worktree" ]; then - error "git worktree is not set" - fi - worktree="${worktree%%/}/" - if [ ! -d "$worktree" ]; then - error "git worktree $worktree does not exist" - fi + worktree="$(git_get_worktree)" echo "Registering git url: $url in $MR_CONFIG (with worktree $worktree)" mr -c "$MR_CONFIG" config "`pwd`" \ checkout="git_fake_bare_checkout '$url' '$MR_REPO' '$worktree'"