Explorar o código

add honor_filemode flag to build_index_from_tree

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Mark Mikofski %!s(int64=12) %!d(string=hai) anos
pai
achega
02aa43a6f8
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      dulwich/index.py

+ 6 - 2
dulwich/index.py

@@ -391,13 +391,16 @@ def index_entry_from_stat(stat_val, hex_sha, flags, mode=None):
             stat_val.st_gid, stat_val.st_size, hex_sha, flags)
 
 
-def build_index_from_tree(prefix, index_path, object_store, tree_id):
+def build_index_from_tree(prefix, index_path, object_store, tree_id,
+                          honor_filemode=True):
     """Generate and materialize index from a tree
 
     :param tree_id: Tree to materialize
     :param prefix: Target dir for materialized index files
     :param index_path: Target path for generated index
     :param object_store: Non-empty object store holding tree contents
+    :param honor_filemode: An optional flag to honor core.filemode setting in
+        config file, default is core.filemode=True, change executable bit
 
     :note:: existing index is wiped and contents are not merged
         in a working dir. Suiteable only for fresh clones.
@@ -423,7 +426,8 @@ def build_index_from_tree(prefix, index_path, object_store, tree_id):
             finally:
                 f.close()
 
-            os.chmod(full_path, entry.mode)
+            if honor_filemode:
+                os.chmod(full_path, entry.mode)
 
         # Add file to index
         st = os.lstat(full_path)