|
15 | 15 | # See the License for the specific language governing permissions and |
16 | 16 | # limitations under the License. |
17 | 17 |
|
| 18 | +# For more information, see https://github.com/Reedbeta/git-partial-submodule |
| 19 | + |
18 | 20 | # Check Python version |
19 | 21 | import sys |
20 | 22 | if sys.hexversion < 0x03080000: |
|
24 | 26 |
|
25 | 27 | # Parse arguments |
26 | 28 |
|
27 | | -parser = argparse.ArgumentParser(description="Add or clone partial git submodules.") |
| 29 | +parser = argparse.ArgumentParser(description="Add or clone partial git submodules; save and restore sparse-checkout patterns.") |
28 | 30 | parser.add_argument('-n', '--dry-run', dest='dryRun', default=False, action='store_true', help='Dry run (display git commands without executing them)') |
29 | 31 | parser.add_argument('-v', '--verbose', dest='verbose', default=False, action='store_true', help='Verbose (display git commands being run, and other info)') |
30 | 32 | subparsers = parser.add_subparsers(dest='command', metavar='command') |
|
43 | 45 | help = "Clone partial submodules from .gitmodules.") |
44 | 46 | cloneCmdParser.add_argument('paths', nargs='*', default=[], help='Submodule path(s) to clone (if unspecified, all submodules)') |
45 | 47 |
|
46 | | -saveSparsePatternsCmdParser = subparsers.add_parser( |
47 | | - 'save-sparse-patterns', |
| 48 | +saveSparseCmdParser = subparsers.add_parser( |
| 49 | + 'save-sparse', |
48 | 50 | help = "Save sparse-checkout patterns to .gitmodules.") |
49 | | -saveSparsePatternsCmdParser.add_argument('paths', nargs='*', default=[], help='Submodule path(s) to save (if unspecified, all submodules)') |
| 51 | +saveSparseCmdParser.add_argument('paths', nargs='*', default=[], help='Submodule path(s) to save (if unspecified, all submodules)') |
50 | 52 |
|
51 | | -reapplySparsePatternsCmdParser = subparsers.add_parser( |
52 | | - 'reapply-sparse-patterns', |
53 | | - help = "Re-apply sparse-checkout patterns from .gitmodules.") |
54 | | -reapplySparsePatternsCmdParser.add_argument('paths', nargs='*', default=[], help='Submodule path(s) to reapply (if unspecified, all submodules)') |
| 53 | +restoreSparseCmdParser = subparsers.add_parser( |
| 54 | + 'restore-sparse', |
| 55 | + help = "Restore sparse-checkout patterns from .gitmodules.") |
| 56 | +restoreSparseCmdParser.add_argument('paths', nargs='*', default=[], help='Submodule path(s) to restore (if unspecified, all submodules)') |
55 | 57 |
|
56 | 58 | args = parser.parse_args() |
57 | 59 |
|
@@ -268,7 +270,7 @@ def ReadGitmodules(worktreeRoot): |
268 | 270 | (len(submoduleRelPathsToProcess) - submodulesSkipped, |
269 | 271 | submodulesSkipped)) |
270 | 272 |
|
271 | | -elif args.command == 'save-sparse-patterns': |
| 273 | +elif args.command == 'save-sparse': |
272 | 274 | # Load .gitmodules information |
273 | 275 | gitmodules = ReadGitmodules(worktreeRoot) |
274 | 276 |
|
@@ -310,7 +312,7 @@ def ReadGitmodules(worktreeRoot): |
310 | 312 | okReturnCodes=[0, 5]) # code 5 = "you try to unset an option which does not exist" |
311 | 313 | print("Sparse checkout not enabled for %s." % submodule['name']) |
312 | 314 |
|
313 | | -elif args.command == 'reapply-sparse-patterns': |
| 315 | +elif args.command == 'restore-sparse': |
314 | 316 | # Load .gitmodules information |
315 | 317 | gitmodules = ReadGitmodules(worktreeRoot) |
316 | 318 |
|
|
0 commit comments