# HG changeset patch # User Augie Fackler # Date 2020-09-07 21:16:16 # Node ID d4cf803415892cb491057ea294a1cd364eb876e4 # Parent 601e3658216d720c7a31be1ba0508339746c08d5 git: fix index handling of removed files during commit (issue6398) Other changes in this series also changed the behavior here in positive ways, but this was the final step that actually fixed things. Differential Revision: https://phab.mercurial-scm.org/D8999 diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py --- a/hgext/git/dirstate.py +++ b/hgext/git/dirstate.py @@ -303,8 +303,10 @@ class gitdirstate(object): def drop(self, f): index = self.git.index index.read() - index.remove(pycompat.fsdecode(f)) - index.write() + fs = pycompat.fsdecode(f) + if fs in index: + index.remove(fs) + index.write() def remove(self, f): index = self.git.index diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t --- a/tests/test-git-interop.t +++ b/tests/test-git-interop.t @@ -270,3 +270,8 @@ This covers manifest.diff() +++ b/beta Mon Jan 01 00:00:11 2007 +0000 @@ -0,0 +1,1 @@ +beta + + +Deleting files should also work (this was issue6398) + $ hg rm beta + $ hg ci -m 'remove beta'