blob: 3f1d80c485a7d8f62ec8e410139a3d0cfde05733 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/bash
# Support routines for git commands
commit_range_from_arg() {
local arg="$1"
if [ -z "${arg}" ]; then
# If we didn't get a commit range argument and this is a
# tracking branch, pick all the commits since this branch
# deviated.
base="$(git branch-remote 2>/dev/null)"
if [ -n "${base}" ]; then
echo "${base}..HEAD"
return 0
fi
return 1
fi
# If the argument already has a range in it, we're done.
if echo "${arg}" | grep -q '\.\.'; then
echo "${arg}"
return 0
fi
# If the argument is a tracking branch, pick all the commits since that
# branch deviated.
base="$(git branch-remote "${arg}" 2>/dev/null)"
if [ -n "${base}" ]; then
echo "${base}..${arg}"
return 0
fi
# If we didn't get something that looks like a range, only select one
# commit because git rev-list run against a non-range lists everything
# from whatever it finds all the way back to the beginning.
echo "${arg}^1..${arg}"
return 0
}
|