Print this page
Add git support to which_scm utility

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/scripts/which_scm.sh
          +++ new/usr/src/tools/scripts/which_scm.sh
↓ open down ↓ 51 lines elided ↑ open up ↑
  52   52  
  53   53  # Check for well-known tree-type source code management (SCM) systems.
  54   54  function primary_type
  55   55  {
  56   56          typeset scmid
  57   57  
  58   58          [ -d "$1/Codemgr_wsdata" ] && scmid="$scmid teamware"
  59   59          [ -d "$1/.hg" ] && scmid="$scmid mercurial"
  60   60          [ -d "$1/CVS" ] && scmid="$scmid cvs"
  61   61          [ -d "$1/.svn" ] && scmid="$scmid subversion"
       62 +        [ -d "$1/.git" ] && scmid="$scmid git"
  62   63          echo $scmid
  63   64  }
  64   65  
  65   66  if [[ -n "$CODEMGR_WS" ]]; then
  66   67          if [[ ! -d "$CODEMGR_WS" ]]; then
  67   68                  print -u2 "which_scm: $CODEMGR_WS is not a directory."
  68   69                  exit 1
  69   70          fi
  70   71          set -- $(primary_type "$CODEMGR_WS")
  71   72          if [[ $# != 1 ]]; then
↓ open down ↓ 20 lines elided ↑ open up ↑
  92   93  SCM_TYPE=
  93   94  while [[ "$DIR" != / ]]; do
  94   95          set -- $(primary_type "$DIR")
  95   96          if [[ $# > 1 ]]; then
  96   97                  echo "unknown $ORIG_CWD"
  97   98                  exit 0
  98   99          fi
  99  100          SCM_TYPE="$1"
 100  101          # We're done searching if we hit either a change in type or the top
 101  102          # of a "third type" control system.
 102      -        if [[ "$SCM_TYPE" != "$CWD_TYPE" || "$SCM_TYPE" == mercurial || \
 103      -            "$SCM_TYPE" == teamware ]]; then
      103 +        if [[ "$SCM_TYPE" != "$CWD_TYPE" || "$SCM_TYPE" == git || \
      104 +            "$SCM_TYPE" == mercurial || "$SCM_TYPE" == teamware ]]; then
 104  105                  break
 105  106          fi
 106  107          PREVDIR="$DIR"
 107  108          DIR=$(dirname "$DIR")
 108  109  done
 109  110  
 110  111  # We assume here that the system root directory isn't the root of the SCM.
 111  112  
 112  113  # Check for the "second type" of repository.  In all cases, we started
 113  114  # out in the tree and stepped out on the last iteration, so we want
↓ open down ↓ 19 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX