Debian Codegraph @

etc/examples/662-submodules

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 REPO_ROOT=/tmp/submodule-diff-examplescip-shell filesystem . . `/tmp/submodule-diff-example`.
3 REPO_DATE_FMT=%H:%M:%S.%N
4 mkdirscip-shell system . . mkdir. ${REPO_ROOT} && gitscip-shell system . . git. -C ${REPO_ROOT} init && cd ${REPO_ROOT}
5 datescip-shell system . . date. +${REPO_DATE_FMT} >> baserepo && gitscip-shell system . . git. add baserepo && gitscip-shell system . . git. commit -m "Base repo commit 1"
6
7 for sub in A B C; do
8 gitscip-shell system . . git. init submodule${sub}
9 for iter in $(seqscip-shell system . . seq. 1 4); do
10 datescip-shell system . . date. +${REPO_DATE_FMT} >> submodule${sub}/subcontent
11 gitscip-shell system . . git. -C submodule${sub} add subcontent && gitscip-shell system . . git. -C submodule${sub} commit -m "Submodule ${sub} initial commit $iter"
12 done
13 # Add initial submodule, message of "Submodule submoduleX 0000000...xxxxxxx (new submodule)", no individual commits
14 gitscip-shell system . . git. submodule add ../bogus-url-${sub} submodule${sub} && \
15 git commit -m "Add submodule${sub}" # the diff handling for this is correct in delta
16
17 # Create additional submodule commits
18 for iter in $(seqscip-shell system . . seq. 1 2); do
19 datescip-shell system . . date. +${REPO_DATE_FMT} >> submodule${sub}/subcontent
20 gitscip-shell system . . git. -C submodule${sub} add subcontent && gitscip-shell system . . git. -C submodule${sub} commit -m "Submodule ${sub} extra change ${iter}"
21 done
22 gitscip-shell system . . git. add submodule${sub} && gitscip-shell system . . git. commit -m "Update submodule${sub}"
23 done
24
25 gitscip-shell system . . git. -C submoduleA reset --hard HEAD~4
26 gitscip-shell system . . git. -C submoduleC reset --hard HEAD~2
27
28 for sub in B C; do
29 for iter in $(seqscip-shell system . . seq. 1 3); do
30 datescip-shell system . . date. +${REPO_DATE_FMT} >> submodule${sub}/subcontent
31 gitscip-shell system . . git. -C submodule${sub} add subcontent && gitscip-shell system . . git. -C submodule${sub} commit -m "Submodule ${sub} stage change ${iter}"
32 done
33 done
34
35 # Add all submodule updates in single commit to test multiple submodule updates in single commit
36 gitscip-shell system . . git. add submodule[A-C] && gitscip-shell system . . git. commit -m "Update all submodules"
37
38 # submoduleA end state is only removed commits
39 # submoduleB end state is only added commits
40 # submoduleC is a mixture of removed and added commits (e.g. different branch)
41
42 # Manual, inspect superproject history via:
43 # "git -c diff.submodule=short log -p | delta --no-gitconfig"
44 # "git -c diff.submodule=log log -p | delta --no-gitconfig"
45 # "git -c diff.submodule=diff log -p | delta --no-gitconfig"