commit:     55aef9bf297ef8cbf29921acb454449d01313818
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 18 15:48:35 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 18 15:52:42 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=55aef9bf

GitSync.update: use git reset --merge instead of --hard (bug 552814)

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 <AT> gentoo.org>
Fixes 84413bb1dd9d ("GitSync.update: respect sync-depth (bug 552814)")

 pym/portage/sync/modules/git/git.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/sync/modules/git/git.py 
b/pym/portage/sync/modules/git/git.py
index 09257f3..c1028ab 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -89,7 +89,7 @@ class GitSync(NewBase):
                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}'],
@@ -110,7 +110,7 @@ class GitSync(NewBase):
                        **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,

Reply via email to