]>
Commit | Line | Data |
---|---|---|
93c36dcd JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano. | |
4 | # | |
5 | ||
6 | usage="usage: $0 "'<upstream> [<head>] | |
7 | ||
8 | __*__*__*__*__> <upstream> | |
9 | / | |
10 | fork-point | |
11 | \__+__+__+__+__+__+__+__> <head> | |
12 | ||
13 | Each commit between the fork-point and <head> is examined, and | |
14 | compared against the change each commit between the fork-point and | |
15 | <upstream> introduces. If the change does not seem to be in the | |
16 | upstream, it is shown on the standard output. | |
17 | ||
18 | The 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 | ||
30 | case "$#" in | |
31 | 1) linus=`git-rev-parse "$1"` && | |
32 | junio=`git-rev-parse HEAD` || exit | |
33 | ;; | |
34 | 2) linus=`git-rev-parse "$1"` && | |
35 | junio=`git-rev-parse "$2"` || exit | |
36 | ;; | |
37 | *) echo >&2 "$usage"; exit 1 ;; | |
38 | esac | |
39 | ||
40 | # Note that these list commits in reverse order; | |
41 | # not that the order in inup matters... | |
42 | inup=`git-rev-list ^$junio $linus` && | |
43 | ours=`git-rev-list $junio ^$linus` || exit | |
44 | ||
45 | tmp=.cherry-tmp$$ | |
46 | patch=$tmp-patch | |
47 | mkdir $patch | |
48 | trap "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 | ||
53 | for c in $inup | |
54 | do | |
55 | git-diff-tree -p $c | |
56 | done | git-patch-id | | |
57 | while read id name | |
58 | do | |
59 | echo $name >>$patch/$id | |
60 | done | |
61 | ||
62 | LF=' | |
63 | ' | |
64 | ||
65 | O= | |
66 | for c in $ours | |
67 | do | |
68 | set x `git-diff-tree -p $c | git-patch-id` | |
69 | if test "$2" != "" | |
70 | then | |
71 | if test -f "$patch/$2" | |
72 | then | |
73 | sign=- | |
74 | else | |
75 | sign=+ | |
76 | fi | |
77 | case "$O" in | |
78 | '') O="$sign $c" ;; | |
79 | *) O="$sign $c$LF$O" ;; | |
80 | esac | |
81 | fi | |
82 | done | |
83 | case "$O" in | |
84 | '') ;; | |
85 | *) echo "$O" ;; | |
86 | esac |