Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Index#workdir_path_modified? #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/rugged_adapter/git_layer_rugged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,18 @@ def initialize(index, repo)
@treemap = {}
end

# Determines whether a path in the working directory has been modified compared to the index: i.e., is new, or has new content.
# The purpose of this method is to determine whether it is safe to overwrite a path with information from the index.
# Hence, when path does not exist in the workdir (:worktree_deleted), this method returns false.
def workdir_path_modified?(path)
return false if @rugged_repo.bare?
begin
!(@rugged_repo.status(path) & [:worktree_modified, :worktree_new]).empty?
rescue Rugged::InvalidError
return false
end
end

def delete(path)
@index.remove_all(path)
update_treemap(path, false)
Expand Down
Loading