git-rebase-scripton commit Merge with gitk. (80bd6f3)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano.
   4#
   5
   6usage="usage: $0 "'<upstream> [<head>]
   7
   8Uses output from git-cherry to rebase local commits to the new head of
   9upstream tree.'
  10
  11: ${GIT_DIR=.git}
  12
  13case "$#" in
  141) linus=`git-rev-parse --verify "$1"` &&
  15   junio=`git-rev-parse --verify HEAD` || exit
  16   ;;
  172) linus=`git-rev-parse --verify "$1"` &&
  18   junio=`git-rev-parse --verify "$2"` || exit
  19   ;;
  20*) echo >&2 "$usage"; exit 1 ;;
  21esac
  22
  23git-read-tree -m -u $junio $linus &&
  24echo "$linus" >"$GIT_DIR/HEAD" || exit
  25
  26tmp=.rebase-tmp$$
  27fail=$tmp-fail
  28trap "rm -rf $tmp-*" 0 1 2 3 15
  29
  30>$fail
  31
  32git-cherry $linus $junio |
  33while read sign commit
  34do
  35        case "$sign" in
  36        -) continue ;;
  37        esac
  38        S=`cat "$GIT_DIR/HEAD"` &&
  39        GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $commit &&
  40        git-commit-script -m "$commit" || {
  41                echo $commit >>$fail
  42                git-read-tree --reset -u $S
  43        }
  44done
  45if test -s $fail
  46then
  47        echo Some commits could not be rebased, check by hand:
  48        cat $fail
  49fi