File tree Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Original file line number Diff line number Diff line change 35
35
shift
36
36
done
37
37
38
- base=$1
39
- url=$2
40
- head=${3-HEAD}
38
+ base=$1 url=$2 head=${3-HEAD}
41
39
42
- [ " $base " ] || usage
43
- [ " $url " ] || usage
40
+ test -n " $base " && test -n " $url " || usage
41
+ baserev=$( git rev-parse --verify " $base " ^0) &&
42
+ headrev=$( git rev-parse --verify " $head " ^0) || exit
44
43
45
- baserev=` git rev-parse --verify " $base " ^0` &&
46
- headrev=` git rev-parse --verify " $head " ^0` || exit
47
-
48
- merge_base=` git merge-base $baserev $headrev ` ||
44
+ merge_base=$( git merge-base $baserev $headrev ) ||
49
45
die " fatal: No commits in common between $base and $head "
50
46
51
- branch= $( git ls-remote " $url " \
52
- | sed -n -e " /^ $headrev refs. heads./{
53
- s/^.* refs.heads.//
54
- p
55
- q
56
- } " )
47
+ find_matching_branch= " /^ $headrev " ' refs\/heads\//{
48
+ s/^.* refs\/ heads\///
49
+ p
50
+ q
51
+ } '
52
+ branch= $( git ls-remote " $url " | sed -n -e " $find_matching_branch " )
57
53
url=$( git ls-remote --get-url " $url " )
58
- if [ -z " $branch " ]; then
54
+ if test -z " $branch "
55
+ then
59
56
echo " warn: No branch of $url is at:" >&2
60
57
git log --max-count=1 --pretty=' tformat:warn: %h: %s' $headrev >&2
61
58
echo " warn: Are you sure you pushed $head there?" >&2
You can’t perform that action at this time.
0 commit comments