From: Ben Crocker bcrocker@redhat.com
This is a sample script providing a thin layer over the git command. It is meant to substitute in redhat/Makefile and Makefile.common via the GIT macro defined in Makefile.
Each git subcommand currently used by Makefile and Makefile.common is broken out into its own case. At the moment, the output of either 'git describe' or 'git merge-base' can be overridden by means of environment variables, EGIT_OVERRIDE_DESCRIBE and EGIT_OVERRIDE_MERGE_BASE respectively.
Use case: self test with test values for 'git describe' and/or 'git merge-base'.
Other git subcommands are simply passed through.
Signed-off-by: Ben Crocker bcrocker@redhat.com --- redhat/egit.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 redhat/egit.sh
diff --git a/redhat/egit.sh b/redhat/egit.sh new file mode 100755 index 000000000000..e8d7f7390d8a --- /dev/null +++ b/redhat/egit.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +arg=$1 +shift +case $arg in + add ) + git add "$@" + ;; + branch ) + git branch "$@" + ;; + commit ) + git commit "$@" + ;; + config ) + git config "$@" + ;; + describe ) + if [ -n "$EGIT_OVERRIDE_DESCRIBE" ] + then + # Should be a version, e.g. v5.9-rc8 or v5.9-rc7-1449-g57b6fb86b0ac + echo "$EGIT_OVERRIDE_DESCRIBE" + else + git describe "$@" + fi + ;; + diff ) + git diff "$@" + ;; + diff-index ) + git diff-index "$@" + ;; + log ) + git log "$@" + ;; + merge-base ) + if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ] + then + # This should be an SHA1: + echo "$EGIT_OVERRIDE_MERGE_BASE" + else + git merge-base "$@" + fi + ;; + rev-parse ) + git rev-parse "$@" + ;; + show ) + git show "$@" + ;; + tag ) + git tag "$@" + ;; + remote ) + git remote "$@" + ;; + * ) + git "$arg" "$@" + ;; +esac