File: sparse_checkout.sh

package info (click to toggle)
trilinos 12.14.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 752,372 kB
  • sloc: cpp: 3,241,095; ansic: 434,828; fortran: 169,554; xml: 54,886; python: 37,974; sh: 29,430; makefile: 27,828; javascript: 8,535; perl: 7,558; f90: 6,372; csh: 4,160; lex: 1,491; lisp: 810; yacc: 491; awk: 364; ml: 281; php: 145; sed: 3
file content (74 lines) | stat: -rwxr-xr-x 2,113 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash

# Run this script in the main Trilinos repo dir to do a sparse
# checkout of directories.  For example:
#
#   $ cd Trilinos
#   $ ./sparse_checkout.sh doc/ packages/
#   $ ls
#
# should return just 'sparse_checkout.sh',
# cmake/tribits/common_tools/git/sparse_checkout', 'doc' and 'packages'.
#
# After a sparse checkout, commands like 'git status' will run as fast
# as the size of the remaining checkout.
#
# A sparse checkout can be undone by calling this script with no arguments as:
#
#   $ cd Trilinos
#   $ ./sparse_checkout.sh
#
# NOTES:
#
# a) Make sure you run this script before you change any files or the 'git
# read-tree ...' command will blow away your changes (a lesson I learned the
# hard way).  In general, commit your work *before* you run this script.
#
# b) Git will keep directories not listed if there are symbolic links
# needed to support files in directories that are listed.
#
# c) Sparse checkout is only supported in git 1.7 and later.
#
# d) Early versions of git 1.7.x require that directory names end with '/'
# such as 'doc/' instead of 'doc'.  Later versions of git do not require the
# trailing '/'.

DIRS_FILES_LIST=$@

SC_FILE=.git/info/sparse-checkout

if [ "$DIRS_FILES_LIST" == "" ] ; then

  echo "Undoing sparse checkout"

  # Get the full tree back
  echo "*" > $SC_FILE
  git config core.sparsecheckout true
  git read-tree --reset -u HEAD

  # Wipe out all traces of sparse checkout support
  rm $SC_FILE
  git config core.sparsecheckout false
 
else

  # Tell Git to allow sparse checkout
  git config core.sparsecheckout true
  
  # Set up the list of dirs/files for sparse checkout to keep
  echo > $SC_FILE
  if [ -e cmake/tribits/common_tools/git/sparse_checkout.sh ] ; then
    echo cmake/tribits/common_tools/git/sparse_checkout.sh >> $SC_FILE
  fi
  if [ -e sparse_checkout.sh ] ; then
    echo sparse_checkout.sh >> $SC_FILE
  fi
  for dir_or_file in $DIRS_FILES_LIST ; do
    echo "File/directory to keep: $dir_or_file";
    echo $dir_or_file >> $SC_FILE
  done
  
  # Tell git to process the list of dirs/files
  git read-tree -m -u HEAD
 
fi