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