Advertisement
eacousineau

Git Submodule Depth-First Stuff

Feb 13th, 2013
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.43 KB | None | 0 0
  1. for dir in a b c d; do
  2.     git init $dir
  3.     pushd $dir
  4.         touch test
  5.         echo $dir > bob
  6.         git add -A
  7.         git commit -m "Init"
  8.     popd
  9. done
  10.  
  11. pushd b;
  12.     git submodule add ../c
  13.     git commit -m "Subbed"
  14. popd
  15.  
  16. git-sfed () { git submodule foreach "git submodule foreach '$*' && $*"; }
  17.  
  18. pushd a;
  19.     git submodule add ../b
  20.     git submodule add ../d
  21.     git submodule update --init --recursive
  22.     # Three different methods for iteration
  23.     echo
  24.     git-sfed 'echo $path; git status'
  25.     echo
  26.     git submodule  foreach --recursive | tac | sed 's/Entering//' | xargs -I% bash -c 'cd %; echo %; git status'
  27.     echo
  28.     git submodule foreach --recursive | tac | sed 's/Entering //' | xargs -n 1 bash -c 'cd $1; echo $1; git status' _
  29.     echo
  30. popd
  31.  
  32. echo > /dev/null <<COMMENT
  33. Entering 'b'
  34. Entering 'c'
  35. c
  36. # Not currently on any branch.
  37. nothing to commit (working directory clean)
  38. b
  39. # On branch master
  40. nothing to commit (working directory clean)
  41. Entering 'd'
  42. d
  43. # On branch master
  44. nothing to commit (working directory clean)
  45.  
  46. d
  47. # On branch master
  48. nothing to commit (working directory clean)
  49. b/c
  50. # Not currently on any branch.
  51. nothing to commit (working directory clean)
  52. b
  53. # On branch master
  54. nothing to commit (working directory clean)
  55.  
  56. d
  57. # On branch master
  58. nothing to commit (working directory clean)
  59. b/c
  60. # Not currently on any branch.
  61. nothing to commit (working directory clean)
  62. b
  63. # On branch master
  64. nothing to commit (working directory clean)
  65. COMMENT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement