git-cherryon commit [PATCH] Spell __attribute__ correctly in cache.h. (75ea691)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano.
   4#
   5
   6. git-sh-setup-script || die "Not a git archive."
   7
   8usage="usage: $0 "'[-v] <upstream> [<head>]
   9
  10             __*__*__*__*__> <upstream>
  11            /
  12  fork-point
  13            \__+__+__+__+__+__+__+__> <head>
  14
  15Each commit between the fork-point and <head> is examined, and
  16compared against the change each commit between the fork-point and
  17<upstream> introduces.  If the change does not seem to be in the
  18upstream, it is shown on the standard output.
  19
  20The output is intended to be used as:
  21
  22    OLD_HEAD=$(git-rev-parse HEAD)
  23    git-rev-parse upstream >${GIT_DIR-.}/HEAD
  24    git-cherry upstream $OLD_HEAD |
  25    while read commit
  26    do
  27        GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p "$commit" &&
  28        git-commit-script -C "$commit"
  29    done
  30'
  31
  32case "$1" in -v) verbose=t; shift ;; esac 
  33
  34case "$#,$1" in
  351,*..*)
  36    upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
  37    set x "$upstream" "$ours"
  38    shift ;;
  39esac
  40
  41case "$#" in
  421) upstream=`git-rev-parse --verify "$1"` &&
  43   ours=`git-rev-parse --verify HEAD` || exit
  44   ;;
  452) upstream=`git-rev-parse --verify "$1"` &&
  46   ours=`git-rev-parse --verify "$2"` || exit
  47   ;;
  48*) echo >&2 "$usage"; exit 1 ;;
  49esac
  50
  51# Note that these list commits in reverse order;
  52# not that the order in inup matters...
  53inup=`git-rev-list ^$ours $upstream` &&
  54ours=`git-rev-list $ours ^$upstream` || exit
  55
  56tmp=.cherry-tmp$$
  57patch=$tmp-patch
  58mkdir $patch
  59trap "rm -rf $tmp-*" 0 1 2 3 15
  60
  61_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
  62_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
  63
  64for c in $inup
  65do
  66        git-diff-tree -p $c
  67done | git-patch-id |
  68while read id name
  69do
  70        echo $name >>$patch/$id
  71done
  72
  73LF='
  74'
  75
  76O=
  77for c in $ours
  78do
  79        set x `git-diff-tree -p $c | git-patch-id`
  80        if test "$2" != ""
  81        then
  82                if test -f "$patch/$2"
  83                then
  84                        sign=-
  85                else
  86                        sign=+
  87                fi
  88                case "$verbose" in
  89                t)
  90                        c=$(git-rev-list --pretty=oneline --max-count=1 $c)
  91                esac
  92                case "$O" in
  93                '')     O="$sign $c" ;;
  94                *)      O="$sign $c$LF$O" ;;
  95                esac
  96        fi
  97done
  98case "$O" in
  99'') ;;
 100*)  echo "$O" ;;
 101esac