diff options
| author | Carlos Maiolino <[email protected]> | 2026-05-02 14:09:27 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2026-05-02 14:09:27 +0200 |
| commit | 296c6b9ee85209c0ce375717e30686545baea107 (patch) | |
| tree | f0da71650e8f58ca528589ad4e39476732fa5b88 /maintainer_old/djwong-git | |
| parent | b2e1a1cb259e482720430ff9898d2e564ee73d0f (diff) | |
Diffstat (limited to 'maintainer_old/djwong-git')
| -rwxr-xr-x | maintainer_old/djwong-git | 41 |
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 +} |
