[PATCH] D26287: clang-format: Use git-ls-tree to get file mode in diff mode
Stephen Hines via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 7 22:00:07 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286212: clang-format: Use git-ls-tree to get file mode in diff mode (authored by srhines).
Changed prior to commit:
https://reviews.llvm.org/D26287?vs=76878&id=77142#toc
Repository:
rL LLVM
https://reviews.llvm.org/D26287
Files:
cfe/trunk/tools/clang-format/git-clang-format
Index: cfe/trunk/tools/clang-format/git-clang-format
===================================================================
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -346,7 +346,16 @@
Returns the object ID (SHA-1) of the created tree."""
def index_info_generator():
for filename, line_ranges in changed_lines.iteritems():
- mode = oct(os.stat(filename).st_mode)
+ if revision:
+ git_metadata_cmd = ['git', 'ls-tree',
+ '%s:%s' % (revision, os.path.dirname(filename)),
+ os.path.basename(filename)]
+ git_metadata = subprocess.Popen(git_metadata_cmd, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+ stdout = git_metadata.communicate()[0]
+ mode = oct(int(stdout.split()[0], 8))
+ else:
+ mode = oct(os.stat(filename).st_mode)
blob_id = clang_format_to_blob(filename, line_ranges,
revision=revision,
binary=binary,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26287.77142.patch
Type: text/x-patch
Size: 1111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161108/edfec67f/attachment.bin>
More information about the cfe-commits
mailing list