Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env bash | |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 | |
| 7 # This git extension converts a chromium commit number to its git commit hash. | |
| 8 # It accepts the following input formats: | |
| 9 # | |
| 10 # $ git crrev-parse Cr-Commit-Position: refs/heads/master@{#311769} | |
| 11 # $ git crrev-parse ' Cr-Commit-Position: refs/heads/master@{#311769}' | |
| 12 # $ git crrev-parse 'Cr-Commit-Position: refs/heads/master@{#311769}' | |
| 13 # $ git crrev-parse refs/heads/master@{#311769} | |
| 14 # | |
| 15 # It also works for branches (assuming you have branches in your local | |
| 16 # checkout): | |
| 17 # | |
| 18 # $ git crrev-parse refs/branch-heads/2278@{#2} | |
| 19 # | |
| 20 # If you don't specify a branch, refs/heads/master is assumed: | |
| 21 # | |
| 22 # $ git crrev-parse @{#311769} | |
| 23 # $ git crrev-parse #311769 | |
| 24 # $ git crrev-parse 311769 | |
| 25 | |
| 26 | |
| 27 while [ -n "$1" ]; do | |
| 28 if [[ "$1" = "Cr-Commit-Position:" ]] && [[ "$2" =~ .*@\{#[0-9][0-9]*\} ]]; th en | |
| 29 commit_pos="$2" | |
| 30 shift | |
| 31 else | |
| 32 commit_pos="${1#*Cr-Commit-Position: }" | |
| 33 fi | |
| 34 ref="${commit_pos%@\{#*\}}" | |
| 35 if [ "$ref" = "$commit_pos" -o -z "$ref" ]; then | |
| 36 ref="refs/heads/master" | |
| 37 fi | |
| 38 ref="${ref/refs\/heads/refs\/remotes\/origin}" | |
| 39 ref="${ref/refs\/branch-heads/refs\/remotes\/branch-heads}" | |
| 40 num="${commit_pos#*@\{\#}" | |
| 41 num="${num%\}}" | |
| 42 | |
| 43 if [ -z "$ref" -o -z "$num" ]; then | |
| 44 git rev-parse "$1" | |
| 45 else | |
| 46 git rev-list -n 1 --grep="$commit_pos" "$ref" | |
|
ghost stip (do not use)
2015/01/23 00:03:27
reconstruct commit_pos when grepping to reduce fal
szager1
2015/01/23 00:53:45
Done.
| |
| 47 fi | |
| 48 | |
| 49 shift | |
| 50 done | |
| OLD | NEW |