Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zhiltsov-max opened this issue Jan 10, 2022 · 1 comment
Closed

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

zhiltsov-max opened this issue Jan 10, 2022 · 1 comment

Comments

@zhiltsov-max
Copy link

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

@Byron
Copy link
Member

Byron commented Jan 10, 2022

Thanks for reporting, and apologies for letting that slip. e16a004 implements a fix which hopefully is the right way to do this.

A new release was published and 3.1.26 should contain the fix.
Please reopen the issue or create a new one if the issue isn't solved.

@Byron Byron closed this as completed Jan 10, 2022
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Jan 17, 2022
Changelog:
=========
Fixes a leaked file descriptor when reading the index, which would cause make
writing a previously read index on windows impossible.
See gitpython-developers/GitPython#1395 for details.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
offa pushed a commit to jhnc-oss/poky that referenced this issue Jan 17, 2022
Changelog:
=========
Fixes a leaked file descriptor when reading the index, which would cause make
writing a previously read index on windows impossible.
See gitpython-developers/GitPython#1395 for details.

(From OE-Core rev: a47cef453c6c53161683f14ffc52ac9b36056174)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Jan 17, 2022
Changelog:
=========
Fixes a leaked file descriptor when reading the index, which would cause make
writing a previously read index on windows impossible.
See gitpython-developers/GitPython#1395 for details.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Jan 18, 2022
Changelog:
=========
Fixes a leaked file descriptor when reading the index, which would cause make
writing a previously read index on windows impossible.
See gitpython-developers/GitPython#1395 for details.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Aug 22, 2022
3.1.27
- Reduced startup time due to optimized imports.

See the following for all changes.
https://github.com/gitpython-developers/gitpython/milestone/57?closed=1


3.1.26
- Fixes a leaked file descriptor when reading the index, which would cause make writing a previously
  read index on windows impossible.
  See gitpython-developers/GitPython#1395 for details.

See the following for all changes.
https://github.com/gitpython-developers/gitpython/milestone/56?closed=1


3.1.25
See the following for all changes.
https://github.com/gitpython-developers/gitpython/milestone/55?closed=1


3.1.24
* Newly added timeout flag is not be enabled by default, and was renamed to kill_after_timeout
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
Changelog:
=========
Fixes a leaked file descriptor when reading the index, which would cause make
writing a previously read index on windows impossible.
See gitpython-developers/GitPython#1395 for details.

(From OE-Core rev: d0f3d4b0da85ee8d46c6aa069c9bcbceb4f4edf5)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
Changelog:
=========
Fixes a leaked file descriptor when reading the index, which would cause make
writing a previously read index on windows impossible.
See gitpython-developers/GitPython#1395 for details.

(From OE-Core rev: d0f3d4b0da85ee8d46c6aa069c9bcbceb4f4edf5)

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants