From: Yann Dirson Date: Sun, 08 Jan 2006 00:40:33 GMT Subject: [PATCH 5/7] Add an optional limit to git-cherry Message-ID: <20060108004033.GM1113@nowhere.earth> This allows to use another commit than the merge base as a limit for scanning patches. Signed-off-by: Yann Dirson --- git-cherry.sh | 20 +++++++++++++------- t/t3500-cherry.sh | 5 +++++ 2 files changed, 18 insertions(+), 7 deletions(-) b1e23bf60c069a1f6bd4b8d04afd1fb80005e4ee diff --git a/git-cherry.sh b/git-cherry.sh index 5e9bd0c..1a62320 100755 --- a/git-cherry.sh +++ b/git-cherry.sh @@ -3,17 +3,17 @@ # Copyright (c) 2005 Junio C Hamano. # -USAGE='[-v] []' +USAGE='[-v] [] []' LONG_USAGE=' __*__*__*__*__> / fork-point \__+__+__+__+__+__+__+__> -Each commit between the fork-point and is examined, and -compared against the change each commit between the fork-point and - introduces. If the change seems to be in the upstream, -it is shown on the standard output with prefix "+". Otherwise -it is shown with prefix "-".' +Each commit between the fork-point (or if given) and is +examined, and compared against the change each commit between the +fork-point and introduces. If the change seems to be in +the upstream, it is shown on the standard output with prefix "+". +Otherwise it is shown with prefix "-".' . git-sh-setup case "$1" in -v) verbose=t; shift ;; esac @@ -28,9 +28,15 @@ esac case "$#" in 1) upstream=`git-rev-parse --verify "$1"` && ours=`git-rev-parse --verify HEAD` || exit + limit="$upstream" ;; 2) upstream=`git-rev-parse --verify "$1"` && ours=`git-rev-parse --verify "$2"` || exit + limit="$upstream" + ;; +3) upstream=`git-rev-parse --verify "$1"` && + ours=`git-rev-parse --verify "$2"` && + limit=`git-rev-parse --verify "$3"` || exit ;; *) usage ;; esac @@ -38,7 +44,7 @@ esac # Note that these list commits in reverse order; # not that the order in inup matters... inup=`git-rev-list ^$ours $upstream` && -ours=`git-rev-list $ours ^$upstream` || exit +ours=`git-rev-list $ours ^$limit` || exit tmp=.cherry-tmp$$ patch=$tmp-patch diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh index f2f9109..7b81377 100755 --- a/t/t3500-cherry.sh +++ b/t/t3500-cherry.sh @@ -38,6 +38,11 @@ test_expect_success \ ' test_expect_success \ + 'check that cherry with limit returns only the top patch'\ + 'expr "$(echo $(git-cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*" +' + +test_expect_success \ 'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \ 'git-cherry-pick my-topic-branch^0 && echo $(git-cherry master my-topic-branch) && -- 1.0.6-g8ecb -- Yann Dirson | Debian-related: | Support Debian GNU/Linux: | Freedom, Power, Stability, Gratis http://ydirson.free.fr/ | Check