Patchwork D8995: git: correctly handle "nothing changed" commits

login
register
mail settings
Submitter phabricator
Date Sept. 7, 2020, 9:31 p.m.
Message ID <differential-rev-PHID-DREV-hxstpuh4wwduzkeyxuie-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47103/
State Superseded
Headers show

Comments

phabricator - Sept. 7, 2020, 9:31 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I guess localrepo.commit() actually returns an Optional[node], which
  is a bit of a surprise to me.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8995

AFFECTED FILES
  hgext/git/__init__.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/git/__init__.py b/hgext/git/__init__.py
--- a/hgext/git/__init__.py
+++ b/hgext/git/__init__.py
@@ -297,6 +297,10 @@ 
 
             def commit(self, *args, **kwargs):
                 ret = orig.commit(self, *args, **kwargs)
+                if ret is None:
+                    # there was nothing to commit, so we should skip
+                    # the index fixup logic we'd otherwise do.
+                    return None
                 tid = self.store.git[gitutil.togitnode(ret)].tree.id
                 # DANGER! This will flush any writes staged to the
                 # index in Git, but we're sidestepping the index in a