@@ -130,6 +130,8 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
130130 index directly before operating on it using the git command.
131131 """
132132
133+ unsafe_git_checkout_index_options = ["--prefix" ]
134+
133135 __slots__ = ("repo" , "version" , "entries" , "_extension_data" , "_file_path" )
134136
135137 _VERSION = 2
@@ -1212,6 +1214,7 @@ def checkout(
12121214 paths : Union [None , Iterable [PathLike ]] = None ,
12131215 force : bool = False ,
12141216 fprogress : Callable = lambda * args : None ,
1217+ allow_unsafe_options : bool = False ,
12151218 ** kwargs : Any ,
12161219 ) -> Union [None , Iterator [PathLike ], Sequence [PathLike ]]:
12171220 """Check out the given paths or all files from the version known to the index
@@ -1238,6 +1241,9 @@ def checkout(
12381241 no explicit paths are given. Otherwise progress information will be send
12391242 prior and after a file has been checked out.
12401243
1244+ :param allow_unsafe_options:
1245+ Allow unsafe options, such as ``--prefix``.
1246+
12411247 :param kwargs:
12421248 Additional arguments to be passed to :manpage:`git-checkout-index(1)`.
12431249
@@ -1261,6 +1267,12 @@ def checkout(
12611267 i.e. if you want :manpage:`git-checkout(1)`-like behaviour, use
12621268 ``head.checkout`` instead of ``index.checkout``.
12631269 """
1270+ if not allow_unsafe_options :
1271+ Git .check_unsafe_options (
1272+ options = Git ._option_candidates ([], kwargs ),
1273+ unsafe_options = self .unsafe_git_checkout_index_options ,
1274+ )
1275+
12641276 args = ["--index" ]
12651277 if force :
12661278 args .append ("--force" )
0 commit comments