pre-rebase hook update
This hook is what I have been using to manage topic branches in git.git, but have not been updated to the Real Thing for a while. Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
27d69a465d
commit
ba2d0f4f35
|
@ -1,7 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006 Junio C Hamano
|
# Copyright (c) 2006, 2008 Junio C Hamano
|
||||||
#
|
#
|
||||||
|
# The "pre-rebase" hook is run just before "git-rebase" starts doing
|
||||||
|
# its job, and can prevent the command from running by exiting with
|
||||||
|
# non-zero status.
|
||||||
|
#
|
||||||
|
# The hook is called with the following parameters:
|
||||||
|
#
|
||||||
|
# $1 -- the upstream the series was forked from.
|
||||||
|
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
||||||
|
#
|
||||||
|
# This sample shows how to prevent topic branches that are already
|
||||||
|
# merged to 'next' branch from getting rebased, because allowing it
|
||||||
|
# would result in rebasing already published history.
|
||||||
|
|
||||||
publish=next
|
publish=next
|
||||||
basebranch="$1"
|
basebranch="$1"
|
||||||
|
@ -9,11 +21,12 @@ if test "$#" = 2
|
||||||
then
|
then
|
||||||
topic="refs/heads/$2"
|
topic="refs/heads/$2"
|
||||||
else
|
else
|
||||||
topic=`git symbolic-ref HEAD`
|
topic=`git symbolic-ref HEAD` ||
|
||||||
|
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$basebranch,$topic" in
|
case "$topic" in
|
||||||
master,refs/heads/??/*)
|
refs/heads/??/*)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
exit 0 ;# we do not interrupt others.
|
exit 0 ;# we do not interrupt others.
|
||||||
|
@ -23,6 +36,12 @@ esac
|
||||||
# Now we are dealing with a topic branch being rebased
|
# Now we are dealing with a topic branch being rebased
|
||||||
# on top of master. Is it OK to rebase it?
|
# on top of master. Is it OK to rebase it?
|
||||||
|
|
||||||
|
# Does the topic really exist?
|
||||||
|
git show-ref -q "$topic" || {
|
||||||
|
echo >&2 "No such branch $topic"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Is topic fully merged to master?
|
# Is topic fully merged to master?
|
||||||
not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
|
not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
|
||||||
if test -z "$not_in_master"
|
if test -z "$not_in_master"
|
||||||
|
|
Loading…
Reference in New Issue