summaryrefslogtreecommitdiff
path: root/git-rebase.sh
blob: 2bc3a12995ec5f18cf666289a6691fa2e4d3fb47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano.
#
 
. git-sh-setup
 
# The other head is given
other=$(git-rev-parse --verify "$1^0") || exit
 
# The tree must be really really clean.
git-update-index --refresh || exit
diff=$(git-diff-index --cached --name-status -r HEAD)
case "$different" in
?*)	echo "$diff"
	exit 1
	;;
esac
 
# If the branch to rebase is given, first switch to it.
case "$#" in
2)
	git-checkout "$2" || exit
esac
 
# Rewind the head to "$other"
git-reset --hard "$other"
git-format-patch -k --stdout --full-index "$other" ORIG_HEAD |
git am --binary -3 -k