Removed /usr/local from CDPATH
[clearscm.git] / rc / git
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:        $RCSfile: git,v $
5 # Revision:    $Revision: 1.0 $ 
6 # Description: This script set up some useful environment variables and aliases
7 #              for git execution. File should be sourced (e.g . git) 
8 # Author:      Andrew@DeFaria.com
9 # Created:     Thu Nov  7 18:00:34 PST 2013
10 # Modified:    $Date: $
11 # Language:    bash
12 #
13 # (c) Copyright 2000-2013, ClearSCM, Inc., all rights reserved.
14 #
15 ################################################################################
16 function in_git_repo {
17   pwd=$PWD
18   
19   while [ "$pwd" != "/" -a "$pwd" != "//" ]; do
20     if [ -d "$pwd/.git" ]; then
21       true;
22       return;
23     fi
24
25     pwd=$(dirname "$pwd")
26   done
27   
28   false
29 } # in_git_repo
30
31 function git () {
32   # Need to reset title since we put the branch name in the titlebar
33   git=$(/usr/bin/which git)
34
35   if [ "${git:0:3}" != "no " ]; then
36     if [ "$1" = "checkout" -o "$1" = "co" ]; then
37       $git "$@"
38       set_title
39     elif [ "$1" = "files" ]; then
40       if [ -z "$2" ]; then
41         echo "Files in git commit HEAD"
42         $git show --pretty="" --name-only HEAD
43       else
44         echo "Files in git commit $2"
45         $git show --pretty="" --name-only $2
46       fi
47     else
48       $git "$@"
49     fi
50   fi
51 } # git