OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
6 | 6 |
7 from __future__ import print_function | 7 from __future__ import print_function |
8 | 8 |
9 import errno | 9 import errno |
10 import logging | 10 import logging |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 if verbose: | 527 if verbose: |
528 self.Print(remote_output) | 528 self.Print(remote_output) |
529 | 529 |
530 self._UpdateBranchHeads(options, fetch=True) | 530 self._UpdateBranchHeads(options, fetch=True) |
531 | 531 |
532 # This is a big hammer, debatable if it should even be here... | 532 # This is a big hammer, debatable if it should even be here... |
533 if options.force or options.reset: | 533 if options.force or options.reset: |
534 target = 'HEAD' | 534 target = 'HEAD' |
535 if options.upstream and upstream_branch: | 535 if options.upstream and upstream_branch: |
536 target = upstream_branch | 536 target = upstream_branch |
| 537 |
| 538 # Builds can create hard links which update source files' ctimes, causing |
| 539 # git to become confused over what files are out-of-date. Calling |
| 540 # `git status` resynchronizes git and allows `git reset --hard` to not |
| 541 # re-checkout files (and thus forcing unnecessary rebuilds)". |
| 542 self._Run(['status'], options) |
| 543 |
537 self._Run(['reset', '--hard', target], options) | 544 self._Run(['reset', '--hard', target], options) |
538 | 545 |
539 if current_type == 'detached': | 546 if current_type == 'detached': |
540 # case 0 | 547 # case 0 |
541 self._CheckClean(revision) | 548 self._CheckClean(revision) |
542 self._CheckDetachedHead(revision, options) | 549 self._CheckDetachedHead(revision, options) |
543 if self._Capture(['rev-list', '-n', '1', 'HEAD']) == revision: | 550 if self._Capture(['rev-list', '-n', '1', 'HEAD']) == revision: |
544 self.Print('Up-to-date; skipping checkout.') | 551 self.Print('Up-to-date; skipping checkout.') |
545 else: | 552 else: |
546 # 'git checkout' may need to overwrite existing untracked files. Allow | 553 # 'git checkout' may need to overwrite existing untracked files. Allow |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 kwargs.setdefault('cwd', self.checkout_path) | 1182 kwargs.setdefault('cwd', self.checkout_path) |
1176 kwargs.setdefault('stdout', self.out_fh) | 1183 kwargs.setdefault('stdout', self.out_fh) |
1177 kwargs['filter_fn'] = self.filter | 1184 kwargs['filter_fn'] = self.filter |
1178 kwargs.setdefault('print_stdout', False) | 1185 kwargs.setdefault('print_stdout', False) |
1179 env = scm.GIT.ApplyEnvVars(kwargs) | 1186 env = scm.GIT.ApplyEnvVars(kwargs) |
1180 cmd = ['git'] + args | 1187 cmd = ['git'] + args |
1181 if show_header: | 1188 if show_header: |
1182 gclient_utils.CheckCallAndFilterAndHeader(cmd, env=env, **kwargs) | 1189 gclient_utils.CheckCallAndFilterAndHeader(cmd, env=env, **kwargs) |
1183 else: | 1190 else: |
1184 gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs) | 1191 gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs) |
OLD | NEW |