1#!/bin/sh 2# 3# Copyright (c) 2005 Junio C Hamano. 4# 5 6usage="usage:$0"'<upstream> [<head>] 7 8 __*__*__*__*__> <upstream> 9 / 10 fork-point 11 \__+__+__+__+__+__+__+__> <head> 12 13Each commit between the fork-point and <head> is examined, and 14compared against the change each commit between the fork-point and 15<upstream> introduces. If the change does not seem to be in the 16upstream, it is shown on the standard output. 17 18The output is intended to be used as: 19 20 OLD_HEAD=$(git-rev-parse HEAD) 21 git-rev-parse linus >${GIT_DIR-.}/HEAD 22 git-cherry linus OLD_HEAD | 23 while read commit 24 do 25 GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p "$commit" && 26 git-commit-script -m "$commit" 27 done 28' 29 30case"$#"in 311) linus=`git-rev-parse "$1"`&& 32 junio=`git-rev-parse HEAD`||exit 33;; 342) linus=`git-rev-parse "$1"`&& 35 junio=`git-rev-parse "$2"`||exit 36;; 37*)echo>&2"$usage";exit1;; 38esac 39 40# Note that these list commits in reverse order; 41# not that the order in inup matters... 42inup=`git-rev-list ^$junio$linus`&& 43ours=`git-rev-list$junio^$linus`||exit 44 45tmp=.cherry-tmp$$ 46patch=$tmp-patch 47mkdir$patch 48trap"rm -rf$tmp-*"0 1 2 3 15 49 50_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' 51_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" 52 53for c in$inup 54do 55 git-diff-tree -p$c 56done| git-patch-id| 57whileread id name 58do 59echo$name>>$patch/$id 60done 61 62LF=' 63' 64 65O= 66for c in$ours 67do 68set x `git-diff-tree -p$c| git-patch-id` 69iftest"$2"!="" 70then 71iftest -f"$patch/$2" 72then 73 sign=- 74else 75 sign=+ 76fi 77case"$O"in 78'') O="$sign$c";; 79*) O="$sign$c$LF$O";; 80esac 81fi 82done 83case"$O"in 84'') ;; 85*)echo"$O";; 86esac