rugged
rugged copied to clipboard
Tree#diff: unexpected behavior of option :include_untracked_content
Commit#diff_workdir refers to Tree#diff_workdir.
Returns a diff between a tree and the current workdir.
The tree object will be used as the “old file” side of the diff, while the content of the current workdir will be used for the “new file” side.
See Rugged::Tree#diff for a list of options that can be passed.
| :include_untracked_content | if true, untracked content will be contained in the the diff patch text. |
|---|
Problem
repo = Rugged::Repository.new('.')
commit = repo.head.target_id
options = {
include_untracked: true,
include_untracked_content: true,
recurse_untracked_dirs: true
}
diff = repo.lookup(commit).diff_workdir(**options)
I have untracked files in diff but I cannot get context of ones.
patch = diff.patches.first
patch.delta
=> <Rugged::Diff::Delta:11857500 {old_file: {:oid=>"0000000000000000000000000000000000000000", :path=>"test", :size=>0, :flags=>6, :mode=>0}, new_file: {:oid=>"0000000000000000000000000000000000000000", :path=>"test", :size=>8, :flags=>10, :mode=>33188}, similarity: 0, status: :untracked>
patch.to_s
=> ""