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