#!/bin/sh set -o errexit set -o nounset IFS=' ' if test "${IS_TEST_CASE:-1}" -eq '1' then DIR_TESTCASES="$(cd -- "$(dirname -- "$0")" && pwd -P)" DIR_TEST="$(dirname "${DIR_TESTCASES}")" else DIR_TEST="$(cd -- "$(dirname -- "$0")" && pwd -P)" DIR_TESTCASES="${DIR_TEST}/tests" fi DIR_ROOT="$(dirname "${DIR_TEST}")" DIR_BIN="${DIR_ROOT}/bin" DIR_TEMP="${DIR_TEST}/temp" DIR_SOURCE="${DIR_TEMP}/source" DIR_DESTINATION="${DIR_TEMP}/destination" BIN_MAIN="${DIR_BIN}/incremental-git-filterbranch" if test ! -f "${BIN_MAIN}" then echo 'Failed to detect environment'>&2 exit 1 fi BIN_MAIN_OPTIONS='' if ! command -v flock >/dev/null then BIN_MAIN_OPTIONS="${BIN_MAIN_OPTIONS} --no-lock" fi initializeRepositories () { rm -rf "${DIR_TEMP}" mkdir "${DIR_TEMP}" git init --quiet "${DIR_SOURCE}" git -C "${DIR_SOURCE}" config --local user.email 'email@example.com' git -C "${DIR_SOURCE}" config --local user.name 'John Doe' mkdir "${DIR_SOURCE}/subdir" touch "${DIR_SOURCE}/rootfile1" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #1' git -C "${DIR_SOURCE}" tag tag-01 touch "${DIR_SOURCE}/subdir/subfile1" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #2' touch "${DIR_SOURCE}/subdir/subfile2" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #3' git -C "${DIR_SOURCE}" tag tag-02 touch "${DIR_SOURCE}/subdir/subfile3" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4' touch "${DIR_SOURCE}/rootfile2" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #5' git -C "${DIR_SOURCE}" tag tag-03 touch "${DIR_SOURCE}/rootfile3" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #6' touch "${DIR_SOURCE}/subdir/subfile3b" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #4b' git -C "${DIR_SOURCE}" checkout --quiet -b slave tag-02 touch "${DIR_SOURCE}/in-root-2" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #7' git -C "${DIR_SOURCE}" tag tag-04 touch "${DIR_SOURCE}/in-root-3" git -C "${DIR_SOURCE}" add --all git -C "${DIR_SOURCE}" commit --quiet --message 'Commit #8' git init --bare --quiet "${DIR_DESTINATION}" } getTagList () { getTagList_multiline=$(git -C "${1}" show-ref --tags | sed -E 's:^.* refs/tags/::' || true) printf '%s' "${getTagList_multiline}" | sort -b | tr '\n' ' ' | sed -E 's:^ | $::g' } getBranchList () { getBranchList_multiline=$(git -C "${1}" show-ref --heads | sed -E 's:^.* refs/heads/::' || true) printf '%s' "${getBranchList_multiline}" | sort -b | tr '\n' ' ' | sed -E 's:^ | $::g' }