• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:porcelain

3 #===- git-clang-format - ClangFormat Git Integration ---------*- python -*--===#
10 #===------------------------------------------------------------------------===#
13 clang-format git integration
16 This file provides a clang-format integration for git. Put it somewhere in your
17 path and ensure that it is executable. Then, "git clang-format" will invoke
18 clang-format on the changes in current files or a specific commit.
21 git clang-format -h
35 usage = 'git clang-format [OPTIONS] [<commit>] [--] [<file>...]'
38 Run clang-format on all lines that differ between the working directory
42 The following git-config settings set the default of the corresponding option:
49 # Name of the temporary index file in which save the output of clang-format.
51 temp_index_basename = 'clang-format-index'
60 # In order to keep '--' yet allow options after positionals, we need to
61 # check for '--' ourselves. (Setting nargs='*' throws away the '--', while
65 idx = argv.index('--')
78 # Other languages that clang-format supports
87 p.add_argument('--binary',
88 default=config.get('clangformat.binary', 'clang-format'),
89 help='path to clang-format'),
90 p.add_argument('--commit',
93 p.add_argument('--diff', action='store_true',
95 p.add_argument('--extensions',
98 help=('comma-separated list of file extensions to format, '
99 'excluding the period and case-insensitive')),
100 p.add_argument('-f', '--force', action='store_true',
102 p.add_argument('-p', '--patch', action='store_true',
104 p.add_argument('-q', '--quiet', action='count', default=0,
106 p.add_argument('--style',
108 help='passed to clang-format'),
109 p.add_argument('-v', '--verbose', action='count', default=0,
120 opts.verbose -= opts.quiet
135 print 'Running clang-format on the following files:'
153 print 'clang-format did not modify any files'
169 is a dictionary mapping option name (in lower case) to either "--bool" or
170 "--int"."""
174 for entry in run('git', 'config', '--list', '--null').split('\0'):
184 """Interpret `args` as "[commit] [--] [files...]" and return (commit, files).
186 It is assumed that "--" and everything that follows has been removed from
189 If "--" is present (i.e., `dash_dash` is non-empty), the argument to its
224 run('git', 'rev-parse', value, verbose=False)
237 cmd = ['git', 'cat-file', '-t', value]
262 (if non-empty). Zero context lines are used in the patch."""
263 cmd = ['git', 'diff-index', '-p', '-U0', commit, '--']
276 The input must have been produced with ``-U0``, meaning unidiff format with
284 match = re.search(r'^@@ -[0-9,]+ \+(\d+)(,(\d+))?', line)
309 toplevel = run('git', 'rev-parse', '--show-toplevel')
316 Returns the object ID (SHA-1) of the created tree."""
317 return create_tree(filenames, '--stdin')
320 def run_clang_format_and_save_to_tree(changed_lines, binary='clang-format',
322 """Run clang-format on each file and save the result to a git tree.
324 Returns the object ID (SHA-1) of the created tree."""
331 return create_tree(index_info_generator(), '--index-info')
337 If mode is '--stdin', it must be a list of filenames. If mode is
338 '--index-info' is must be a list of values suitable for "git update-index
339 --index-info", such as "<mode> <SP> <sha1> <TAB> <filename>". Any other mode
341 assert mode in ('--stdin', '--index-info')
342 cmd = ['git', 'update-index', '--add', '-z', mode]
350 tree_id = run('git', 'write-tree')
354 def clang_format_to_blob(filename, line_ranges, binary='clang-format',
356 """Run clang-format on the given file and save the result to a git blob.
358 Returns the object ID (SHA-1) of the created blob."""
361 clang_format_cmd.extend(['-style='+style])
363 '-lines=%s:%s' % (start_line, start_line+line_count-1)
374 hash_object_cmd = ['git', 'hash-object', '-w', '--path='+filename, '--stdin']
408 gitdir = run('git', 'rev-parse', '--git-dir')
411 tree = '--empty'
412 run('git', 'read-tree', '--index-output='+path, tree)
418 # We use the porcelain 'diff' and not plumbing 'diff-tree' because the output
421 subprocess.check_call(['git', 'diff', old_tree, new_tree, '--'])
428 `patch_mode`, runs `git checkout --patch` to select hunks interactively."""
429 changed_files = run('git', 'diff-tree', '-r', '-z', '--name-only', old_tree,
432 unstaged_files = run('git', 'diff-files', '--name-status', *changed_files)
447 subprocess.check_call(['git', 'checkout', '--patch', new_tree])
451 run('git', 'checkout-index', '-a', '-f')