diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-07-20 16:18:01 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-07-20 16:18:01 +0200 |
commit | 192472f9673b18c91ce618e64e935f91769c50e7 (patch) | |
tree | 11fa568ea41d3856e6df605c8c8c8559fded3745 /lib/git/index/fun.py | |
parent | 89422841e46efa99bda49acfbe33ee1ca5122845 (diff) | |
download | gitpython-192472f9673b18c91ce618e64e935f91769c50e7.tar.gz |
BaseIndexEntry: Added to_blob method, refactored functionality sligthly
repo.clone: assured backslashes won't reach the remote configuration, as it can cause trouble when re-reading the file later on. Some git commands don't appear to be able to properly deal with backslashes, other's do
Diffstat (limited to 'lib/git/index/fun.py')
-rw-r--r-- | lib/git/index/fun.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/git/index/fun.py b/lib/git/index/fun.py index 4478228a..48c4fa74 100644 --- a/lib/git/index/fun.py +++ b/lib/git/index/fun.py @@ -2,7 +2,18 @@ Contains standalone functions to accompany the index implementation and make it more versatile """ -from stat import S_IFDIR +from stat import ( + S_IFDIR, + S_IFLNK, + S_ISLNK, + S_IFDIR, + S_ISDIR, + S_IFMT, + S_IFREG, + ) + +S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule + from cStringIO import StringIO from git.util import IndexFileSHA1Writer @@ -28,7 +39,19 @@ from util import ( from gitdb.base import IStream from gitdb.typ import str_tree_type -__all__ = ('write_cache', 'read_cache', 'write_tree_from_cache', 'entry_key' ) +__all__ = ('write_cache', 'read_cache', 'write_tree_from_cache', 'entry_key', + 'stat_mode_to_index_mode', 'S_IFGITLINK') + + +def stat_mode_to_index_mode(mode): + """Convert the given mode from a stat call to the corresponding index mode + and return it""" + if S_ISLNK(mode): # symlinks + return S_IFLNK + if S_ISDIR(mode) or S_IFMT(mode) == S_IFGITLINK: # submodules + return S_IFGITLINK + return S_IFREG | 0644 | (mode & 0100) # blobs with or without executable bit + def write_cache_entry(entry, stream): """Write the given entry to the stream""" |