Skip to content

Commit

Permalink
GitSync.update: use git reset --merge instead of --hard (bug 552814)
Browse files Browse the repository at this point in the history
Since `git reset --merge` gives the closest behavior to `git pull`,
use it instead of `-git reset --hard`. This will provide the following
advantages:

* git will not have to stat files that have not changed since the
  previous sync, which will allow for optimal performance

* git will abort if there are unstaged local changes to any files that
  have changed since the previous sync

Suggested-by: Michał Górny <mgorny@gentoo.org>
Fixes 84413bb ("GitSync.update: respect sync-depth (bug 552814)")
  • Loading branch information
zmedico committed Jul 18, 2016
1 parent 84413bb commit 55aef9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pym/portage/sync/modules/git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def update(self):
else:
# Since the default merge strategy typically fails when
# the depth is not unlimited, use `git fetch` followed by
# `git reset --hard`.
# `git reset --merge`.
remote_branch = portage._unicode_decode(
subprocess.check_output([self.bin_command, 'rev-parse',
'--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
Expand All @@ -110,7 +110,7 @@ def update(self):
**self.spawn_kwargs)

if exitcode == os.EX_OK and self.repo.sync_depth is not None:
reset_cmd = [self.bin_command, 'reset', '--hard', remote_branch]
reset_cmd = [self.bin_command, 'reset', '--merge', remote_branch]
if quiet:
reset_cmd.append('--quiet')
exitcode = subprocess.call(reset_cmd,
Expand Down

0 comments on commit 55aef9b

Please sign in to comment.