MCPcopy
hub / github.com/gitless-vcs/gitless / diff_file

Method diff_file

gitless/core.py:933–952  ·  view source on GitHub ↗

Diff the working version of path with its committed version.

(self, path)

Source from the content-addressed store, hash-verified

931 yield tree_entry_path
932
933 def diff_file(self, path):
934 """Diff the working version of path with its committed version."""
935 _check_path_is_repo_relative(path)
936
937 git_repo = self.gl_repo.git_repo
938 git_path = _get_git_path(path)
939 try:
940 blob_at_head = git_repo[git_repo.head.peel().tree[git_path].id]
941 except KeyError: # no blob at head
942 wt_blob = git_repo[git_repo.create_blob_fromworkdir(git_path)]
943 nil_blob = git_repo[git_repo.create_blob('')]
944 return nil_blob.diff(wt_blob, 0, git_path, git_path)
945
946 try:
947 wt_blob = git_repo[git_repo.create_blob_fromworkdir(git_path)]
948 except KeyError: # no blob at wd (the file was deleted)
949 nil_blob = git_repo[git_repo.create_blob('')]
950 return blob_at_head.diff(nil_blob, 0, git_path, git_path)
951
952 return blob_at_head.diff(wt_blob, 0, git_path, git_path)
953
954
955 # Merge-related methods

Callers 7

mainFunction · 0.80
test_diff_nontrackedMethod · 0.80
test_empty_diffMethod · 0.80
test_diff_basicMethod · 0.80
test_diff_appendMethod · 0.80
test_diff_new_fpMethod · 0.80
test_diff_non_asciiMethod · 0.80

Calls 2

_get_git_pathFunction · 0.85

Tested by 6

test_diff_nontrackedMethod · 0.64
test_empty_diffMethod · 0.64
test_diff_basicMethod · 0.64
test_diff_appendMethod · 0.64
test_diff_new_fpMethod · 0.64
test_diff_non_asciiMethod · 0.64