]>
Commit | Line | Data |
---|---|---|
93c36dcd JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano. | |
4 | # | |
5 | ||
ae2b0f15 | 6 | . git-sh-setup |
4282c4fb | 7 | |
185612b8 | 8 | usage="usage: $0 "'[-v] <upstream> [<head>] |
93c36dcd JH |
9 | |
10 | __*__*__*__*__> <upstream> | |
11 | / | |
12 | fork-point | |
13 | \__+__+__+__+__+__+__+__> <head> | |
14 | ||
15 | Each commit between the fork-point and <head> is examined, and | |
16 | compared against the change each commit between the fork-point and | |
e47e35ac JH |
17 | <upstream> introduces. If the change seems to be in the upstream, |
18 | it is shown on the standard output with prefix "+". Otherwise | |
19 | it is shown with prefix "-". | |
93c36dcd JH |
20 | ' |
21 | ||
185612b8 JH |
22 | case "$1" in -v) verbose=t; shift ;; esac |
23 | ||
4282c4fb JH |
24 | case "$#,$1" in |
25 | 1,*..*) | |
26 | upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$') | |
27 | set x "$upstream" "$ours" | |
28 | shift ;; | |
29 | esac | |
30 | ||
93c36dcd | 31 | case "$#" in |
4282c4fb JH |
32 | 1) upstream=`git-rev-parse --verify "$1"` && |
33 | ours=`git-rev-parse --verify HEAD` || exit | |
93c36dcd | 34 | ;; |
4282c4fb JH |
35 | 2) upstream=`git-rev-parse --verify "$1"` && |
36 | ours=`git-rev-parse --verify "$2"` || exit | |
93c36dcd JH |
37 | ;; |
38 | *) echo >&2 "$usage"; exit 1 ;; | |
39 | esac | |
40 | ||
41 | # Note that these list commits in reverse order; | |
42 | # not that the order in inup matters... | |
4282c4fb JH |
43 | inup=`git-rev-list ^$ours $upstream` && |
44 | ours=`git-rev-list $ours ^$upstream` || exit | |
93c36dcd JH |
45 | |
46 | tmp=.cherry-tmp$$ | |
47 | patch=$tmp-patch | |
48 | mkdir $patch | |
49 | trap "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 | ||
54 | for c in $inup | |
55 | do | |
56 | git-diff-tree -p $c | |
57 | done | git-patch-id | | |
58 | while read id name | |
59 | do | |
60 | echo $name >>$patch/$id | |
61 | done | |
62 | ||
63 | LF=' | |
64 | ' | |
65 | ||
66 | O= | |
67 | for c in $ours | |
68 | do | |
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 | |
185612b8 JH |
78 | case "$verbose" in |
79 | t) | |
80 | c=$(git-rev-list --pretty=oneline --max-count=1 $c) | |
81 | esac | |
93c36dcd JH |
82 | case "$O" in |
83 | '') O="$sign $c" ;; | |
84 | *) O="$sign $c$LF$O" ;; | |
85 | esac | |
86 | fi | |
87 | done | |
88 | case "$O" in | |
89 | '') ;; | |
90 | *) echo "$O" ;; | |
91 | esac |