]> git.madduck.net Git - code/myrepos.git/blobdiff - mr

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'madduck/master'
[code/myrepos.git] / mr
diff --git a/mr b/mr
index c0f3e836d330668bc7844ec5162b6e1630dabb25..0e14168e10a3d965d7b9054b742b2870e404df17 100755 (executable)
--- a/mr
+++ b/mr
@@ -936,6 +936,12 @@ lib =
                echo "mr: $@" >&2
                exit 1
        }
+       warning() {
+               echo "mr (warning): $@" >&2
+       }
+       info() {
+               echo "mr: $@" >&2
+       }
        hours_since() {
                if [ -z "$1" ] || [ -z "$2" ]; then
                        error "mr: usage: hours_since action num"
@@ -1077,7 +1083,7 @@ register =
        if [ -n "$1" ]; then
                cd "$1"
        fi
-       basedir="$(basename $PWD)"
+       basedir="${PWD##*/}"
        case "$(get_repo_type .)" in
        svn)
                url=$(LANG=C svn info . | grep -i ^URL: | cut -d ' ' -f 2)
@@ -1094,26 +1100,34 @@ register =
                        non-bare) config=.git/config;;
                        bare|fake-bare) config=config;;
                esac
-               url="$(LANG=C GIT_CONFIG="$config" git-config --get remote.origin.url)"
+               url="$(LANG=C GIT_CONFIG="$config" git-config --get remote.origin.url)" || :
                if [ -z "$url" ]; then
                        error "cannot determine git url"
                fi
+               local clone_opts add_cmd work_tree suffix
                case "$repo_type" in
-                       bare|fake-bare)
-                               # this seems like a bare repo as it has no
-                               # worktree.
-                               local work_tree
+                       fake-bare)
+                               # this seems like a fake bare repo and needs a worktree
                                work_tree="$(git-config --get core.worktree)" || :
+                               work_tree="${work_tree%%/}/"
                                if [ ! -d "$work_tree" ]; then
-                                       error "git worktree $work_tree does not exist"
+                                       error "git worktree '$work_tree' does not exist"
                                fi
+                               clone_opts=" --no-checkout"
+                               add_cmd="$add_cmd && cd $basedir"
+                               add_cmd="$add_cmd && git read-tree HEAD"
+                               add_cmd="$add_cmd && git checkout-index -a --prefix='$work_tree' || :"
+                               add_cmd="$add_cmd; git config core.worktree '$work_tree'"
+                               add_cmd="$add_cmd && mv .git/* . && rmdir .git"
                                suffix=" (with worktree $work_tree)"
-                               mr -c "$MR_CONFIG" config "$PWD" \
-                                       lib="GIT_WORK_TREE=$work_tree; export GIT_WORK_TREE"
+                               ;;
+                       bare)
+                               clone_opts=" --bare"
+                               suffix=" (bare repository)"
                                ;;
                esac
                echo "Registering git url: $url in $MR_CONFIG${suffix:-}"
-               mr -c "$MR_CONFIG" config "$PWD" checkout="git clone $url $basedir"
+               mr -c "$MR_CONFIG" config "$PWD" checkout="git clone${clone_opts:-} $url $basedir${add_cmd:-}"
                ;;
        bzr)
                url=$(cat .bzr/branch/parent)