Mercurial > hg
changeset 45419:6739ef7c5fcf
git: correctly handle "nothing changed" commits
I guess localrepo.commit() actually returns an Optional[node], which
is a bit of a surprise to me.
Differential Revision: https://phab.mercurial-scm.org/D8995
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 07 Sep 2020 16:27:12 -0400 |
parents | 4111954cf86d |
children | c67529569643 |
files | hgext/git/__init__.py |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/git/__init__.py Mon Sep 07 16:25:16 2020 -0400 +++ b/hgext/git/__init__.py Mon Sep 07 16:27:12 2020 -0400 @@ -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