request-pull: modernize style
Make it a bit more conforming to Documentation/Codingstyle Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Sep 16, 2011 at 11:22 UTC
3c9f1e7c11186f4c7b39a0e966428587ab20fda5
1 file changed
+13
-16
git-request-pull.sh
+13
-16
@@ -35,27 +35,24 @@ do
35
shift
36
done
37
38
-base=$1
39
-url=$2
40
-head=${3-HEAD}
38
+base=$1 url=$2 head=${3-HEAD}
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
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) ||
45
die "fatal: No commits in common between $base and $head"
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")
53
url=$(git ls-remote --get-url "$url")
58
-if [ -z "$branch" ]; then
54
+if test -z "$branch"
55
+then
56
echo "warn: No branch of $url is at:" >&2
57
git log --max-count=1 --pretty='tformat:warn: %h: %s' $headrev >&2
58
echo "warn: Are you sure you pushed $head there?" >&2