Keeping GridEngine configuration information in git

If indeed “imitation is the highest form of flattery”, then Edward Dale should indeed be flattered since I’ve taken his idea about Keeping Grid Engine configuration information in Subversion that I noticed thanks to Chris’ blog entry and simply used git for the backend storage.

After seeing the simplicity of the solution and its usefulness, it looked to be a must have, except that I generally use git for almost everything and adding subversion to the mix would be annoying. The crux point thus seemed to be replacing (to import and update everything) with an equivalent git-load-dirs. Unfortunately, git-load-dirs would make the script dependent on a number of additional python modules.

Luckily, every now and then it pays to RTFM instead of just searching everywhere in the internet for a solution. Using git --help or man git reveals two obviously useful command-line options:

    Set the path to the repository. This can also be controlled by
    setting the GIT_DIR environment variable...

    Set the path to the working tree... This can also be controlled by
    setting the GIT_WORK_TREE environment variable...

The resulting GridEngine-git-config script is now part of the programs in flex-grid.

In the current long form it adds various error checking and intelligence to avoid creating unnecessary snapshots, but stripped of all that it essentially boils down to this:

# configuration variables

# GridEngine settings
. $SGE_ROOT/$SGE_CELL/common/

# Create a fresh empty directory
tmpDir=$(mktemp -d)
trap "rm -rf $tmpDir 2>/dev/null; exit 0" EXIT TERM INT

$SGE_ROOT/util/upgrade_modules/ $GIT_WORK_TREE

    cd $tmpDir || exit 1

    # use backup_date for the commit message
    msg=$(cat backup_date)

    # various cleanup of files, contents etc.
    # see full version for the detailed implementation

    if [ "$needsCommit" = true ]
        # register all new files
        git add .

        # commit everything
        git commit -a -m "$msg"
        echo "no changes to be committed $msg"

Stripped down to the essentials, the has been replaced by the tandem

git add .


git commit -a

both of which only rely on git being installed.

For convenience, the GridEngine-git-config script provides a pass-through for some common git commands:

  • GridEngine-git-config log
  • GridEngine-git-config ls-files
  • GridEngine-git-config show
  • GridEngine-git-config whatchanged

Under normal circumstances, the show and whatchanged would be the most useful means of seeing which changes have occurred.

The git instaweb or the gitweb.cgi can also be used to browse the changes.

05 Nov 2009 | gridengine, git