Skip to content

Commit 8f64582

Browse files
committed
stage file after checkout
1 parent ad906ae commit 8f64582

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gitless/core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,15 @@ def checkout_file(self, path, commit):
891891
with io.open(full_path, mode='wb') as dst:
892892
dst.write(o.data)
893893

894+
# So as to not get confused with the status of the file we also add it.
895+
# This prevents getting into a situation in which the staged version is
896+
# different from the working version. In such a case, the file would
897+
# appear as modified to Gitless when it shouldn't. This is also consistent
898+
# with the behavior of `git checkout <commit> <file>` that also adds the
899+
# file to the staging area.
900+
with self._index as index:
901+
index.add(git_path)
902+
894903
elif o.type == pygit2.GIT_OBJ_TREE:
895904
raise PathIsDirectoryError(
896905
'Path {0} at {1} is a directory and not a file'.format(

0 commit comments

Comments
 (0)