{"thread":{"id":"8333","subject":"[PATCH] Allow contrib new-workdir to link into bare repositories","startedAt":"2007-05-27T03:09:27Z","lastAt":"2007-05-27T03:09:27Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43388","messageId":"20070527030927.GA32530@spearce.org","threadId":"8333","inReplyTo":null,"subject":"[PATCH] Allow contrib new-workdir to link into bare repositories","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-27T03:09:27Z","receivedAt":"2007-05-27T03:09:27Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On one particular system I like to keep a cluster of bare Git\nrepositories and spawn new-workdirs off of them.  Since the bare\nrepositories don't have working directories associated with them\nthey don't have a .git/ subdirectory that hosts the repository we\nare linking to.\n\nUsing a bare repository as the backing repository for a workdir\ncreated by this script does require that the user delete core.bare\nfrom the repository's configuration file, so that Git auto-senses\nthe bareness of a repository based on pathname information, and\nnot based on the config file.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n contrib/workdir/git-new-workdir |   12 +++++++-----\n 1 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir\nindex 9877b98..f2a3615 100755\n--- a/contrib/workdir/git-new-workdir\n+++ b/contrib/workdir/git-new-workdir\n@@ -20,17 +20,19 @@ new_workdir=$2\n branch=$3\n \n # want to make sure that what is pointed to has a .git directory ...\n-test -d \"$orig_git/.git\" || die \"\\\"$orig_git\\\" is not a git repository!\"\n+git_dir=$(cd \"$orig_git\" 2>/dev/null &&\n+  git rev-parse --git-dir 2>/dev/null) ||\n+  die \"\\\"$orig_git\\\" is not a git repository!\"\n \n # don't link to a workdir\n-if test -L \"$orig_git/.git/config\"\n+if test -L \"$git_dir/config\"\n then\n \tdie \"\\\"$orig_git\\\" is a working directory only, please specify\" \\\n \t\t\"a complete repository.\"\n fi\n \n # make sure the the links use full paths\n-orig_git=$(cd \"$orig_git\"; pwd)\n+git_dir=$(cd \"$git_dir\"; pwd)\n \n # create the workdir\n mkdir -p \"$new_workdir/.git\" || die \"unable to create \\\"$new_workdir\\\"!\"\n@@ -45,13 +47,13 @@ do\n \t\tmkdir -p \"$(dirname \"$new_workdir/.git/$x\")\"\n \t\t;;\n \tesac\n-\tln -s \"$orig_git/.git/$x\" \"$new_workdir/.git/$x\"\n+\tln -s \"$git_dir/$x\" \"$new_workdir/.git/$x\"\n done\n \n # now setup the workdir\n cd \"$new_workdir\"\n # copy the HEAD from the original repository as a default branch\n-cp \"$orig_git/.git/HEAD\" .git/HEAD\n+cp \"$git_dir/HEAD\" .git/HEAD\n # checkout the branch (either the same as HEAD from the original repository, or\n # the one that was asked for)\n git checkout -f $branch\n-- \n1.5.2.789.g8ee1\n"}]}