#!/bin/sh

###############################################################################
#                                                                             #
#           GNU Interactive Tools 4.3.5 per file type action script           #
#                               Local version                                 #
#        Copyright (c) 1993, 1994, 1995 Free Software Foundation, Inc.        #
#                   Written by Tudor Hulubei and Andrei Pitis.                #
#                                                                             #
###############################################################################

#
# This script executes a different action for each file type specified.
# The script tries to match (using gitmatch) the second parameter against
# the patterns given as command line arguments to gitmatch (see below).
# gitmatch returns 0 if the parameter doesn't match or the number in the
# list of the pattern that matched.
# If you want to add new file types & actions to this script, just add a
# new pattern after the last pattern in the list and a corresponding
# action to the 'case' statement.
#
# For grater flexibility, .gitaction's first parameter is the name of the
# directory where the file resides. So, you can get the complete file
# name appending the file base name to the file path just like that: $1/$2
#

name=`basename $0`

if test "$#" -ne 2 -o ! -d "$1" -o ! -f "$2"; then
    echo "$name: GIT internal script" >&2
    exit 255
fi

gitmatch $2 "*.foo" "*.bar"

type=$?

case $type in
1)      $GIT_PAGER $2;;                                 # *.foo
2)      $GIT_PAGER $2;;                                 # *.bar
esac

if test $type != 0; then
    echo
    echo "Press any key ..."
fi

exit $type
