blob: aad2e6171f920c4ad6e83a521837f32d2402da68 [file] [log] [blame]
Junio C Hamano93c36dc2005-06-25 02:22:59 -07001#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano.
4#
5
Junio C Hamano215a7ad2005-09-07 17:26:23 -07006. git-sh-setup || die "Not a git archive."
Junio C Hamano4282c4f2005-08-07 15:51:09 -07007
Junio C Hamano185612b2005-08-09 23:58:35 -07008usage="usage: $0 "'[-v] <upstream> [<head>]
Junio C Hamano93c36dc2005-06-25 02:22:59 -07009
10 __*__*__*__*__> <upstream>
11 /
12 fork-point
13 \__+__+__+__+__+__+__+__> <head>
14
15Each commit between the fork-point and <head> is examined, and
16compared against the change each commit between the fork-point and
Junio C Hamanoe47e35a2005-08-26 17:27:07 -070017<upstream> introduces. If the change seems to be in the upstream,
18it is shown on the standard output with prefix "+". Otherwise
19it is shown with prefix "-".
Junio C Hamano93c36dc2005-06-25 02:22:59 -070020'
21
Junio C Hamano185612b2005-08-09 23:58:35 -070022case "$1" in -v) verbose=t; shift ;; esac
23
Junio C Hamano4282c4f2005-08-07 15:51:09 -070024case "$#,$1" in
251,*..*)
26 upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
27 set x "$upstream" "$ours"
28 shift ;;
29esac
30
Junio C Hamano93c36dc2005-06-25 02:22:59 -070031case "$#" in
Junio C Hamano4282c4f2005-08-07 15:51:09 -0700321) upstream=`git-rev-parse --verify "$1"` &&
33 ours=`git-rev-parse --verify HEAD` || exit
Junio C Hamano93c36dc2005-06-25 02:22:59 -070034 ;;
Junio C Hamano4282c4f2005-08-07 15:51:09 -0700352) upstream=`git-rev-parse --verify "$1"` &&
36 ours=`git-rev-parse --verify "$2"` || exit
Junio C Hamano93c36dc2005-06-25 02:22:59 -070037 ;;
38*) echo >&2 "$usage"; exit 1 ;;
39esac
40
41# Note that these list commits in reverse order;
42# not that the order in inup matters...
Junio C Hamano4282c4f2005-08-07 15:51:09 -070043inup=`git-rev-list ^$ours $upstream` &&
44ours=`git-rev-list $ours ^$upstream` || exit
Junio C Hamano93c36dc2005-06-25 02:22:59 -070045
46tmp=.cherry-tmp$$
47patch=$tmp-patch
48mkdir $patch
49trap "rm -rf $tmp-*" 0 1 2 3 15
50
51_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
52_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
53
54for c in $inup
55do
56 git-diff-tree -p $c
57done | git-patch-id |
58while read id name
59do
60 echo $name >>$patch/$id
61done
62
63LF='
64'
65
66O=
67for c in $ours
68do
69 set x `git-diff-tree -p $c | git-patch-id`
70 if test "$2" != ""
71 then
72 if test -f "$patch/$2"
73 then
74 sign=-
75 else
76 sign=+
77 fi
Junio C Hamano185612b2005-08-09 23:58:35 -070078 case "$verbose" in
79 t)
80 c=$(git-rev-list --pretty=oneline --max-count=1 $c)
81 esac
Junio C Hamano93c36dc2005-06-25 02:22:59 -070082 case "$O" in
83 '') O="$sign $c" ;;
84 *) O="$sign $c$LF$O" ;;
85 esac
86 fi
87done
88case "$O" in
89'') ;;
90*) echo "$O" ;;
91esac