make_patch () {
parent_sha1=$(git rev-parse --verify "$1"^) ||
die "Cannot get patch for $1^"
- git diff "$parent_sha1".."$1" > "$DOTEST"/patch
+ git diff-tree -p "$parent_sha1".."$1" > "$DOTEST"/patch
test -f "$DOTEST"/message ||
git cat-file commit "$1" | sed "1,/^$/d" > "$DOTEST"/message
test -f "$DOTEST"/author-script ||
parent_sha1=$(git rev-parse --verify $sha1^) ||
die "Could not get the parent of $sha1"
current_sha1=$(git rev-parse --verify HEAD)
- if test $no_ff$current_sha1 = $parent_sha1; then
+ if test "$no_ff$current_sha1" = "$parent_sha1"; then
output git reset --hard $sha1
test "a$1" = a-n && output git reset --soft $current_sha1
sha1=$(git rev-parse --short $sha1)
else
NEWHEAD=$(git rev-parse HEAD)
fi &&
- message="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)" &&
- git update-ref -m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
- git symbolic-ref HEAD $HEADNAME && {
+ case $HEADNAME in
+ refs/*)
+ message="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)" &&
+ git update-ref -m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
+ git symbolic-ref HEAD $HEADNAME
+ ;;
+ esac && {
test ! -f "$DOTEST"/verbose ||
- git diff --stat $(cat "$DOTEST"/head)..HEAD
+ git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
} &&
rm -rf "$DOTEST" &&
+ git gc --auto &&
warn "Successfully rebased and updated $HEADNAME."
- git gc --auto
-
exit
}
HEADNAME=$(cat "$DOTEST"/head-name)
HEAD=$(cat "$DOTEST"/head)
- git symbolic-ref HEAD $HEADNAME &&
+ case $HEADNAME in
+ refs/*)
+ git symbolic-ref HEAD $HEADNAME
+ ;;
+ esac &&
output git reset --hard $HEAD &&
rm -rf "$DOTEST"
exit
test -z "$ONTO" && ONTO=$UPSTREAM
: > "$DOTEST"/interactive || die "Could not mark as interactive"
- git symbolic-ref HEAD > "$DOTEST"/head-name ||
- die "Could not get HEAD"
+ git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
+ echo "detached HEAD" > "$DOTEST"/head-name
echo $HEAD > "$DOTEST"/head
echo $UPSTREAM > "$DOTEST"/upstream