@@ -45,9 +45,11 @@ plugin.encryptrefname.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
4545plugin .decryptrefname .argtypes = [ctypes .c_void_p , ctypes .c_void_p ]
4646plugin .set_option .argtypes = [ctypes .c_char_p , ctypes .c_size_t ,
4747 ctypes .c_char_p ]
48+ plugin .geturl .restype = ctypes .c_char_p
4849plugin .hashdata .argtypes = [ctypes .c_void_p , ctypes .c_size_t , ctypes .c_void_p ]
4950plugin .hashdatahex .argtypes = [ctypes .c_void_p , ctypes .c_size_t ]
5051plugin .hashdatahex .restype = ctypes .c_char_p
52+ plugin .globalinit .argtypes = [ctypes .c_char_p ]
5153
5254if not hasattr (pygit2 .enums , 'FileMode' ):
5355 class FileMode (enum .IntFlag ):
@@ -160,21 +162,19 @@ class CryptRepo:
160162
161163 def __init__ (self , clearname , url , init = None , forcetrust = False ):
162164 assert clearname , 'This does not work yet outside a git repository'
163- plugin .globalinit ()
164- self .prefix = f'refs/incrypt/{ sha1hex (url .encode ("utf-8" ))} /'
165- self .url = url
165+ plugin .globalinit (url .encode ('utf-8' ))
166+ self .prefix = f'refs/incrypt/{ sha1hex (plugin .geturl ())} /'
166167 if init :
167168 self .repo = pygit2 .init_repository (clearname , bare = True )
168169 template = self ._mktemplate (init .name , init .email ,
169170 init .date , init .m )
170- self .meta = MetaData (self .repo , self .url , self . prefix + '1/' ).init (
171+ self .meta = MetaData (self .repo , self .prefix + '1/' ).init (
171172 init .keys , template , 'refs/heads/master' )
172173 self .trust (force = True , sign = True )
173174 else :
174175 self .repo = pygit2 .Repository (clearname )
175176 self ._fetch ('_' )
176- self .meta = MetaData (self .repo , self .url ,
177- self .prefix + '1/' ).read ()
177+ self .meta = MetaData (self .repo , self .prefix + '1/' ).read ()
178178 if forcetrust :
179179 self .trust (force = forcetrust )
180180
@@ -249,7 +249,7 @@ class CryptRepo:
249249 ['git' , 'fetch' ,
250250 CryptRepo .verbosityflags [plugin .getverbosity ()],
251251 '--progress' if plugin .getprogress () else '--no-progress' ,
252- '--no-write-fetch-head' , '-p' , self . url ,
252+ '--no-write-fetch-head' , '-p' , plugin . geturl (). decode ( 'utf-8' ) ,
253253 f'+refs/heads/{ pattern } :{ self .prefix } 1/{ pattern } ' ],
254254 cwd = self .repo .path , check = True , stdout = sys .stderr )
255255
@@ -392,7 +392,8 @@ class CryptRepo:
392392 ['--progress' if plugin .getprogress ()
393393 else '--no-progress' , '--porcelain' ] +
394394 (['--atomic' ] if plugin .getatomic () else []) +
395- [self .url , '+' + self .prefix + '1/_:' + MetaData .REFNAME ] +
395+ [plugin .geturl ().decode ('utf-8' ), '+' +
396+ self .prefix + '1/_:' + MetaData .REFNAME ] +
396397 [r [3 ] for r in xrefs ],
397398 cwd = self .repo .path , check = False , text = True ,
398399 stdout = subprocess .PIPE ,
@@ -469,9 +470,8 @@ class MetaData:
469470 KEYVER = b'AES-256-CBC+IV'
470471 REFNAME = 'refs/heads/_'
471472
472- def __init__ (self , repo , url , prefix ):
473+ def __init__ (self , repo , prefix ):
473474 self .repo = repo
474- self .url = url
475475 self .prefix = prefix
476476 self .files = None
477477 self .key = None
@@ -483,7 +483,7 @@ class MetaData:
483483 def _gpg (self , args , inp ):
484484 'run gpg'
485485 return subprocess .check_output (
486- [f'gpg@incrypt::{ self . url } ' ] + args ,
486+ [f'gpg@incrypt::{ plugin . geturl (). decode ( "utf-8" ) } ' ] + args ,
487487 executable = 'gpg' , input = inp )
488488
489489 def init (self , gpgkeys , template , defaultbranch ):
0 commit comments