Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Can't add to index twice in a row in 3.1.25 (PermissionError) #1395

Copy link
Copy link
@zhiltsov-max

Description

@zhiltsov-max
Issue body actions

Hi, we've observed a regression in 3.1.25 (it doesn't happen in 3.1.24).

Running the following script (Python 3.8.6, Windows 10):

import git

repo = git.Repo.init('test_git')
with open('test_git/f.txt', 'w') as f:
    f.write('aa')
with open('test_git/g.txt', 'w') as f:
    f.write('bb')
repo.index.add('f.txt')
repo.index.add('g.txt') # < fails here
repo.index.commit('initial commit')
repo.close()

Produces:

(venv) PS C:\test> python .\test_git_close.py

Traceback (most recent call last):
  File ".\test_git_close.py", line 9, in <module>
    repo.index.add('g.txt')
  File "venv\lib\site-packages\git\index\base.py", line 823, in add
    self.write(ignore_extension_data=not write_extension_data)
  File "venv\lib\site-packages\git\index\base.py", line 221, in write
    lfd.commit()
  File "venv\lib\site-packages\gitdb\util.py", line 359, in commit
    self._end_writing(successful=True)
  File "venv\lib\site-packages\gitdb\util.py", line 384, in _end_writing
    remove(self._filepath)
  File "venv\lib\site-packages\gitdb\util.py", line 83, in remove
    return _retry(os.remove, *args, **kwargs)
  File "venv\lib\site-packages\gitdb\util.py", line 77, in _retry
    return func(*args, **kwargs)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'test_git\\.git\\index'

Can be related to #1333

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.