Skip to content

Add support for Git worktrees #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions git-gerrit
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/bash

# Determine .git directory location (needed for worktrees)
GITCOMMONDIR=$(cd $(git rev-parse --git-common-dir) && pwd)

# Where to store our private working information
DATADIR=.git/gerrit-submit
DATADIR=${GITCOMMONDIR}/gerrit-submit

usage()
{
@@ -14,7 +17,7 @@ usage()

cd_to_root()
{
cd `git rev-parse --git-dir`/..
cd $(git rev-parse --show-toplevel)
}

get_upstream()
@@ -171,12 +174,12 @@ gerrit_submit()
# Add hook - we could do this at "git gerrit init" time, but when using
# the "repo" tool the hooks directory gets reset on "repo sync" so this
# is safer
cat <<'EOF' > .git/hooks/prepare-commit-msg
cat <<'EOF' > ${GITCOMMONDIR}/hooks/prepare-commit-msg
#!/bin/sh
# Added automatically by git-gerrit
git gerrit prepare-commit-msg $1
EOF
chmod 755 .git/hooks/prepare-commit-msg
chmod 755 ${GITCOMMONDIR}/hooks/prepare-commit-msg

# Determine current working branch; save for prepare-commit-msg hook
branch=`git rev-parse --abbrev-ref HEAD`