git-rebase-scripton commit [PATCH] plug memory leak in diff.c::diff_free_filepair() (068eac9)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano.
   4#
   5
   6. git-sh-setup-script || die "Not a git archive."
   7
   8usage="usage: $0 "'<upstream> [<head>]
   9
  10Uses output from git-cherry to rebase local commits to the new head of
  11upstream tree.'
  12
  13case "$#,$1" in
  141,*..*)
  15    upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
  16    set x "$upstream" "$ours"
  17    shift ;;
  18esac
  19
  20case "$#" in
  211) upstream=`git-rev-parse --verify "$1"` &&
  22   ours=`git-rev-parse --verify HEAD` || exit
  23   ;;
  242) upstream=`git-rev-parse --verify "$1"` &&
  25   ours=`git-rev-parse --verify "$2"` || exit
  26   ;;
  27*) echo >&2 "$usage"; exit 1 ;;
  28esac
  29
  30git-read-tree -m -u $ours $upstream &&
  31echo "$upstream" >"$GIT_DIR/HEAD" || exit
  32
  33tmp=.rebase-tmp$$
  34fail=$tmp-fail
  35trap "rm -rf $tmp-*" 0 1 2 3 15
  36
  37>$fail
  38
  39git-cherry $upstream $ours |
  40while read sign commit
  41do
  42        case "$sign" in
  43        -) continue ;;
  44        esac
  45        S=`cat "$GIT_DIR/HEAD"` &&
  46        GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $commit &&
  47        git-commit-script -C "$commit" || {
  48                echo $commit >>$fail
  49                git-read-tree --reset -u $S
  50        }
  51done
  52if test -s $fail
  53then
  54        echo Some commits could not be rebased, check by hand:
  55        cat $fail
  56fi