From 056bef208a5ebbff9864a9db328fdcfaa20a934b Mon Sep 17 00:00:00 2001 From: Jeff Carpenter Date: Wed, 25 Jan 2017 12:51:26 -0800 Subject: [PATCH] Fix git-crrev-parse returning reverted commits instead of original commits Also delete extraneous whitespace BUG=685326 Change-Id: If7f68346fd27edf9a5dca315cfcfbca0decc2da6 Reviewed-on: https://chromium-review.googlesource.com/433158 Reviewed-by: Dirk Pranke Commit-Queue: Dirk Pranke --- git-crrev-parse | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/git-crrev-parse b/git-crrev-parse index 77318fe6e0..3046998a75 100755 --- a/git-crrev-parse +++ b/git-crrev-parse @@ -6,19 +6,19 @@ # This git extension converts a chromium commit number to its git commit hash. # It accepts the following input formats: -# +# # $ git crrev-parse Cr-Commit-Position: refs/heads/master@{#311769} # $ git crrev-parse ' Cr-Commit-Position: refs/heads/master@{#311769}' # $ git crrev-parse 'Cr-Commit-Position: refs/heads/master@{#311769}' # $ git crrev-parse refs/heads/master@{#311769} -# +# # It also works for branches (assuming you have branches in your local # checkout): -# +# # $ git crrev-parse refs/branch-heads/2278@{#2} -# +# # If you don't specify a branch, refs/heads/master is assumed: -# +# # $ git crrev-parse @{#311769} # $ git crrev-parse 311769 @@ -41,11 +41,10 @@ while [ -n "$1" ]; do remote_ref="${remote_ref/refs\/branch-heads/refs\/remotes\/branch-heads}" num="${commit_pos#*@\{\#}" num="${num%\}}" - if [ -z "$ref" -o -z "$num" ]; then git rev-parse "$1" else - grep_str="Cr-Commit-Position: $ref@{#$num}" + grep_str="^Cr-Commit-Position: $ref@{#$num}" git rev-list -n 1 --grep="$grep_str" "$remote_ref" fi