diff options
| author | Michael Forney <mforney@mforney.org> | 2019-04-09 20:08:34 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2019-04-09 20:09:25 -0700 |
| commit | 86f67d71e02b84c5abc733a23cc4fb8bac1f3f48 (patch) | |
| tree | ddbd89030f99dba2198ec4e0585df5d48bb2fa22 /scripts/commit.sh | |
| parent | 728484ee05477e6adef752715c8e8ddf2413219a (diff) | |
scripts/commit.sh: Only commit if tree changed
Diffstat (limited to 'scripts/commit.sh')
| -rw-r--r-- | scripts/commit.sh | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/scripts/commit.sh b/scripts/commit.sh index b4959f48..7c5e3139 100644 --- a/scripts/commit.sh +++ b/scripts/commit.sh @@ -5,12 +5,19 @@ branch=$2 tag=$3 out=$4 -if git -C "$repo" show-ref -q --verify "refs/heads/$branch" ; then - set -- -p "$branch" +if commit=$(git -C "$repo" show-ref -s --verify "refs/heads/$branch" 2>/dev/null) ; then + oldtree=$(git -C "$repo" rev-parse --verify "$branch^{tree}") + newtree=$(git -C "$repo" rev-parse --verify "$tag^{tree}") + if [ "$oldtree" != "$newtree" ] ; then + set -- -p "$branch" + unset commit + fi else set -- fi -commit=$(git -C "$repo" commit-tree -m "oasis built by $(id -un)" "$@" "$tag") -git -C "$repo" update-ref "refs/heads/$branch" "$commit" +if [ -z "${commit+set}" ] ; then + commit=$(git -C "$repo" commit-tree -m "oasis built by $(id -un)" "$@" "$tag") + git -C "$repo" update-ref "refs/heads/$branch" "$commit" +fi echo "$commit" >"$out.tmp" && mv "$out.tmp" "$out" |
