diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/git-merge-ff | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/git-merge-ff b/bin/git-merge-ff index 3d58a662..a367573c 100755 --- a/bin/git-merge-ff +++ b/bin/git-merge-ff @@ -12,6 +12,8 @@ # which avoids an error when there is a filename and branch with the # same name +# modified by spwhitton to handle branches checked out in other worktrees + _usage() { echo "Usage: git merge-ff <branch> [<committish-to-merge>]" 1>&2 exit 1 @@ -33,8 +35,11 @@ _merge_ff() { _usage fi - if [ "$(git symbolic-ref HEAD)" = "refs/heads/$branch" ]; then - git merge $quiet --ff-only "$commit" + worktree=$(git worktree list --porcelain | perl -000 -wn \ + -e'm#^branch refs/heads/'"$branch"'$#m && m#^worktree (.+)$#m && print $1') + + if [ -n "$worktree" ]; then + git -C "$worktree" merge $quiet --ff-only "$commit" else if [ "$(git merge-base $branch_orig_hash $commit_orig_hash)" != "$branch_orig_hash" ]; then echo "Error: merging $commit into $branch would not be a fast-forward" 1>&2 |