rugged icon indicating copy to clipboard operation
rugged copied to clipboard

Tree#diff: unexpected behavior of option :include_untracked_content

Open alexey-igrychev opened this issue 8 years ago • 0 comments

Commit#diff_workdir refers to Tree#diff_workdir.

Doc: 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.

Doc: Tree#diff

: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
=> ""

alexey-igrychev avatar Dec 29 '17 11:12 alexey-igrychev