summaryrefslogtreecommitdiff
path: root/maintainer_old/djwong-git
diff options
context:
space:
mode:
Diffstat (limited to 'maintainer_old/djwong-git')
-rwxr-xr-xmaintainer_old/djwong-git41
1 files changed, 41 insertions, 0 deletions
diff --git a/maintainer_old/djwong-git b/maintainer_old/djwong-git
new file mode 100755
index 0000000..3f1d80c
--- /dev/null
+++ b/maintainer_old/djwong-git
@@ -0,0 +1,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
+}