]> git.ipfire.org Git - thirdparty/git.git/blame - git-cherry.sh
show-branch: mark active branch with a '*' again
[thirdparty/git.git] / git-cherry.sh
CommitLineData
93c36dcd
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano.
4#
5
77f1055c 6USAGE='[-v] <upstream> [<head>] [<limit>]'
43a95cfb 7LONG_USAGE=' __*__*__*__*__> <upstream>
93c36dcd
JH
8 /
9 fork-point
10 \__+__+__+__+__+__+__+__> <head>
11
77f1055c
YD
12Each commit between the fork-point (or <limit> if given) and <head> is
13examined, and compared against the change each commit between the
14fork-point and <upstream> introduces. If the change seems to be in
15the upstream, it is shown on the standard output with prefix "+".
16Otherwise it is shown with prefix "-".'
43a95cfb 17. git-sh-setup
93c36dcd 18
185612b8
JH
19case "$1" in -v) verbose=t; shift ;; esac
20
4282c4fb
JH
21case "$#,$1" in
221,*..*)
f327dbce 23 upstream=$(expr "z$1" : 'z\(.*\)\.\.') ours=$(expr "z$1" : '.*\.\.\(.*\)$')
4282c4fb
JH
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
77f1055c 31 limit="$upstream"
93c36dcd 32 ;;
4282c4fb
JH
332) upstream=`git-rev-parse --verify "$1"` &&
34 ours=`git-rev-parse --verify "$2"` || exit
77f1055c
YD
35 limit="$upstream"
36 ;;
373) 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
42esac
43
44# Note that these list commits in reverse order;
45# not that the order in inup matters...
4282c4fb 46inup=`git-rev-list ^$ours $upstream` &&
77f1055c 47ours=`git-rev-list $ours ^$limit` || exit
93c36dcd
JH
48
49tmp=.cherry-tmp$$
50patch=$tmp-patch
51mkdir $patch
52trap "rm -rf $tmp-*" 0 1 2 3 15
53
93c36dcd
JH
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
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
87done
88case "$O" in
89'') ;;
90*) echo "$O" ;;
91esac