Guest User

Untitled

a guest
Jul 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. In the superproject, right after a clone, run these commands:
  2.  
  3. #!/bin/sh
  4. #define the actions to take when running submodule update for each submodule
  5. repo_root=$(git rev-parse --show-toplevel)
  6. git config submodule.sub1.update '!'"${repo_root}/sparse1.sh"
  7. git config submodule.sub2.update '!'"${repo_root}/sparse2.sh"
  8.  
  9. In this example, we need two scripts because we want different dirs checked out in sub1 and sub2.
  10. See "dir/to/checkout" in script example below.
  11. These scripts will be run in lieu of the normal "git checkout <SHA1>" command that is run as part of the submodule update command.
  12.  
  13. Then, you can run the update with init command as usual:
  14.  
  15. git submodule update --init
  16.  
  17.  
  18. Contents of the the sparse checkout scripts (sparse1.sh / sparse2.sh):
  19.  
  20. #!/bin/sh
  21. #script is called with a single argument, the hash of the submodule commit recorded in the superproject,
  22. #and it runs in the submodule directory
  23. git config core.sparseCheckout true
  24. sub_git_dir=$(git rev-parse --git-dir)
  25. echo dir/to/checkout > ${sub_git_dir}/info/sparse-checkout
  26. git checkout --quiet $1
Add Comment
Please, Sign In to add comment