Skip to content

Commit

Permalink
repository: don't loose file mode on write_archive()
Browse files Browse the repository at this point in the history
Reference: libgit2#616
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
  • Loading branch information
Igor Gnatenko committed Apr 6, 2016
1 parent 51915dd commit 573ea98
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pygit2/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
else:
from io import BytesIO as StringIO

import os
import six

# Import from pygit2
Expand Down Expand Up @@ -795,13 +796,13 @@ def write_archive(self, treeish, archive, timestamp=None, prefix=''):
for entry in index:
content = self[entry.id].read_raw()
info = tarfile.TarInfo(prefix + entry.path)
info.mode = oct(os.stat(self[entry.id], follow_symlinks=False).st_mode & 0o777)
info.size = len(content)
info.mtime = timestamp
info.uname = info.gname = 'root' # just because git does this
if entry.mode == GIT_FILEMODE_LINK:
info.type = archive.SYMTYPE
info.linkname = content
info.mode = 0o777 # symlinks get placeholder
info.size = 0
archive.addfile(info)
else:
Expand Down

0 comments on commit 573ea98

Please sign in to comment.