Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/crashpad/update.py

Issue 2743363003: Be shell-safe with git-filter-branch use in update.py (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # Copyright 2015 The Chromium Authors. All rights reserved. 4 # Copyright 2015 The Chromium Authors. All rights reserved.
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 import argparse 8 import argparse
9 import os 9 import os
10 import pipes
10 import re 11 import re
11 import subprocess 12 import subprocess
12 import sys 13 import sys
13 import tempfile 14 import tempfile
14 import textwrap 15 import textwrap
15 16
16 17
17 IS_WINDOWS = sys.platform.startswith('win') 18 IS_WINDOWS = sys.platform.startswith('win')
18 19
19 20
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 # missing. This points UPDATE_TO to the rewritten (filtered) version. 125 # missing. This points UPDATE_TO to the rewritten (filtered) version.
125 # git-filter-branch insists on running from the top level of the working 126 # git-filter-branch insists on running from the top level of the working
126 # tree. 127 # tree.
127 toplevel = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'], 128 toplevel = subprocess.check_output(['git', 'rev-parse', '--show-toplevel'],
128 shell=IS_WINDOWS).rstrip() 129 shell=IS_WINDOWS).rstrip()
129 subprocess.check_call( 130 subprocess.check_call(
130 ['git', 131 ['git',
131 'filter-branch', 132 'filter-branch',
132 '--force', 133 '--force',
133 '--index-filter', 134 '--index-filter',
134 'git rm --cached --ignore-unmatch ' + ' '.join(parsed.exclude), 135 'git rm --cached --ignore-unmatch ' +
136 ' '.join(pipes.quote(path) for path in parsed.exclude),
135 revision_old + '..UPDATE_TO'], 137 revision_old + '..UPDATE_TO'],
136 cwd=toplevel, 138 cwd=toplevel,
137 shell=IS_WINDOWS) 139 shell=IS_WINDOWS)
138 140
139 # git-filter-branch saved a copy of the original UPDATE_TO at 141 # git-filter-branch saved a copy of the original UPDATE_TO at
140 # original/UPDATE_TO, but this isn’t useful because it refers to the same 142 # original/UPDATE_TO, but this isn’t useful because it refers to the same
141 # thing as parsed.update_to, which is already known. 143 # thing as parsed.update_to, which is already known.
142 subprocess.check_call( 144 subprocess.check_call(
143 ['git', 'update-ref', '-d', 'refs/original/UPDATE_TO'], 145 ['git', 'update-ref', '-d', 'refs/original/UPDATE_TO'],
144 shell=IS_WINDOWS) 146 shell=IS_WINDOWS)
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if has_local_modifications: 284 if has_local_modifications:
283 print >>sys.stderr, ( 285 print >>sys.stderr, (
284 'Remember to check the Local Modifications section in ' + 286 'Remember to check the Local Modifications section in ' +
285 readme_path) 287 readme_path)
286 288
287 return 0 289 return 0
288 290
289 291
290 if __name__ == '__main__': 292 if __name__ == '__main__':
291 sys.exit(main(sys.argv[1:])) 293 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698