Skip to content

Commit cacac90

Browse files
committed
move documentation to Ruby
1 parent e302808 commit cacac90

File tree

2 files changed

+122
-120
lines changed

2 files changed

+122
-120
lines changed

ext/rugged/rugged_tree.c

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -354,126 +354,6 @@ static VALUE rb_git_tree_path(VALUE self, VALUE rb_path)
354354
return rb_entry;
355355
}
356356

357-
/*
358-
* call-seq:
359-
* Tree.diff(repo, tree, diffable[, options]) -> diff
360-
*
361-
* Returns a diff between the `tree` and the diffable object that was given.
362-
* +diffable+ can either be a +Rugged::Commit+, a +Rugged::Tree+, a +Rugged::Index+,
363-
* or +nil+.
364-
*
365-
* The +tree+ object will be used as the "old file" side of the diff, while the
366-
* parent tree or the +diffable+ object will be used for the "new file" side.
367-
*
368-
* If +tree+ or +diffable+ are nil, they will be treated as an empty tree. Passing
369-
* both as `nil` will raise an exception.
370-
*
371-
* The following options can be passed in the +options+ Hash:
372-
*
373-
* :paths ::
374-
* An array of paths / fnmatch patterns to constrain the diff to a specific
375-
* set of files. Also see +:disable_pathspec_match+.
376-
*
377-
* :max_size ::
378-
* An integer specifying the maximum byte size of a file before a it will
379-
* be treated as binary. The default value is 512MB.
380-
*
381-
* :context_lines ::
382-
* The number of unchanged lines that define the boundary of a hunk (and
383-
* to display before and after the actual changes). The default is 3.
384-
*
385-
* :interhunk_lines ::
386-
* The maximum number of unchanged lines between hunk boundaries before the hunks
387-
* will be merged into a one. The default is 0.
388-
*
389-
* :old_prefix ::
390-
* The virtual "directory" to prefix to old filenames in hunk headers.
391-
* The default is "a".
392-
*
393-
* :new_prefix ::
394-
* The virtual "directory" to prefix to new filenames in hunk headers.
395-
* The default is "b".
396-
*
397-
* :reverse ::
398-
* If true, the sides of the diff will be reversed.
399-
*
400-
* :force_text ::
401-
* If true, all files will be treated as text, disabling binary attributes & detection.
402-
*
403-
* :ignore_whitespace ::
404-
* If true, all whitespace will be ignored.
405-
*
406-
* :ignore_whitespace_change ::
407-
* If true, changes in amount of whitespace will be ignored.
408-
*
409-
* :ignore_whitespace_eol ::
410-
* If true, whitespace at end of line will be ignored.
411-
*
412-
* :ignore_submodules ::
413-
* if true, submodules will be excluded from the diff completely.
414-
*
415-
* :patience ::
416-
* If true, the "patience diff" algorithm will be used (currenlty unimplemented).
417-
*
418-
* :include_ignored ::
419-
* If true, ignored files will be included in the diff.
420-
*
421-
* :include_untracked ::
422-
* If true, untracked files will be included in the diff.
423-
*
424-
* :include_unmodified ::
425-
* If true, unmodified files will be included in the diff.
426-
*
427-
* :recurse_untracked_dirs ::
428-
* Even if +:include_untracked+ is true, untracked directories will only be
429-
* marked with a single entry in the diff. If this flag is set to true,
430-
* all files under ignored directories will be included in the diff, too.
431-
*
432-
* :disable_pathspec_match ::
433-
* If true, the given +:paths+ will be applied as exact matches, instead of
434-
* as fnmatch patterns.
435-
*
436-
* :deltas_are_icase ::
437-
* If true, filename comparisons will be made with case-insensitivity.
438-
*
439-
* :include_untracked_content ::
440-
* if true, untracked content will be contained in the the diff patch text.
441-
*
442-
* :skip_binary_check ::
443-
* If true, diff deltas will be generated without spending time on binary
444-
* detection. This is useful to improve performance in cases where the actual
445-
* file content difference is not needed.
446-
*
447-
* :include_typechange ::
448-
* If true, type changes for files will not be interpreted as deletion of
449-
* the "old file" and addition of the "new file", but will generate
450-
* typechange records.
451-
*
452-
* :include_typechange_trees ::
453-
* Even if +:include_typechange+ is true, blob -> tree changes will still
454-
* usually be handled as a deletion of the blob. If this flag is set to true,
455-
* blob -> tree changes will be marked as typechanges.
456-
*
457-
* :ignore_filemode ::
458-
* If true, file mode changes will be ignored.
459-
*
460-
* :recurse_ignored_dirs ::
461-
* Even if +:include_ignored+ is true, ignored directories will only be
462-
* marked with a single entry in the diff. If this flag is set to true,
463-
* all files under ignored directories will be included in the diff, too.
464-
*
465-
* Examples:
466-
*
467-
* # Emulating `git diff <treeish>`
468-
* tree = Rugged::Tree.lookup(repo, "d70d245ed97ed2aa596dd1af6536e4bfdb047b69")
469-
* diff = tree.diff(repo.index)
470-
* diff.merge!(tree.diff)
471-
*
472-
* # Tree-to-Tree Diff
473-
* tree = Rugged::Tree.lookup(repo, "d70d245ed97ed2aa596dd1af6536e4bfdb047b69")
474-
* other_tree = Rugged::Tree.lookup(repo, "7a9e0b02e63179929fed24f0a3e0f19168114d10")
475-
* diff = tree.diff(other_tree)
476-
*/
477357
static VALUE rb_git_diff_tree_to_index(VALUE self, VALUE rb_repo, VALUE rb_self, VALUE rb_other, VALUE rb_options)
478358
{
479359
git_tree *tree = NULL;

lib/rugged/tree.rb

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,127 @@
11
module Rugged
22
class Tree
3+
4+
##
5+
# call-seq:
6+
# Tree.diff(repo, tree, diffable[, options]) -> diff
7+
#
8+
# Returns a diff between the `tree` and the diffable object that was given.
9+
# +diffable+ can either be a +Rugged::Commit+, a +Rugged::Tree+, a +Rugged::Index+,
10+
# or +nil+.
11+
#
12+
# The +tree+ object will be used as the "old file" side of the diff, while the
13+
# parent tree or the +diffable+ object will be used for the "new file" side.
14+
#
15+
# If +tree+ or +diffable+ are nil, they will be treated as an empty tree. Passing
16+
# both as `nil` will raise an exception.
17+
#
18+
# The following options can be passed in the +options+ Hash:
19+
#
20+
# :paths ::
21+
# An array of paths / fnmatch patterns to constrain the diff to a specific
22+
# set of files. Also see +:disable_pathspec_match+.
23+
#
24+
# :max_size ::
25+
# An integer specifying the maximum byte size of a file before a it will
26+
# be treated as binary. The default value is 512MB.
27+
#
28+
# :context_lines ::
29+
# The number of unchanged lines that define the boundary of a hunk (and
30+
# to display before and after the actual changes). The default is 3.
31+
#
32+
# :interhunk_lines ::
33+
# The maximum number of unchanged lines between hunk boundaries before the hunks
34+
# will be merged into a one. The default is 0.
35+
#
36+
# :old_prefix ::
37+
# The virtual "directory" to prefix to old filenames in hunk headers.
38+
# The default is "a".
39+
#
40+
# :new_prefix ::
41+
# The virtual "directory" to prefix to new filenames in hunk headers.
42+
# The default is "b".
43+
#
44+
# :reverse ::
45+
# If true, the sides of the diff will be reversed.
46+
#
47+
# :force_text ::
48+
# If true, all files will be treated as text, disabling binary attributes & detection.
49+
#
50+
# :ignore_whitespace ::
51+
# If true, all whitespace will be ignored.
52+
#
53+
# :ignore_whitespace_change ::
54+
# If true, changes in amount of whitespace will be ignored.
55+
#
56+
# :ignore_whitespace_eol ::
57+
# If true, whitespace at end of line will be ignored.
58+
#
59+
# :ignore_submodules ::
60+
# if true, submodules will be excluded from the diff completely.
61+
#
62+
# :patience ::
63+
# If true, the "patience diff" algorithm will be used (currenlty unimplemented).
64+
#
65+
# :include_ignored ::
66+
# If true, ignored files will be included in the diff.
67+
#
68+
# :include_untracked ::
69+
# If true, untracked files will be included in the diff.
70+
#
71+
# :include_unmodified ::
72+
# If true, unmodified files will be included in the diff.
73+
#
74+
# :recurse_untracked_dirs ::
75+
# Even if +:include_untracked+ is true, untracked directories will only be
76+
# marked with a single entry in the diff. If this flag is set to true,
77+
# all files under ignored directories will be included in the diff, too.
78+
#
79+
# :disable_pathspec_match ::
80+
# If true, the given +:paths+ will be applied as exact matches, instead of
81+
# as fnmatch patterns.
82+
#
83+
# :deltas_are_icase ::
84+
# If true, filename comparisons will be made with case-insensitivity.
85+
#
86+
# :include_untracked_content ::
87+
# if true, untracked content will be contained in the the diff patch text.
88+
#
89+
# :skip_binary_check ::
90+
# If true, diff deltas will be generated without spending time on binary
91+
# detection. This is useful to improve performance in cases where the actual
92+
# file content difference is not needed.
93+
#
94+
# :include_typechange ::
95+
# If true, type changes for files will not be interpreted as deletion of
96+
# the "old file" and addition of the "new file", but will generate
97+
# typechange records.
98+
#
99+
# :include_typechange_trees ::
100+
# Even if +:include_typechange+ is true, blob -> tree changes will still
101+
# usually be handled as a deletion of the blob. If this flag is set to true,
102+
# blob -> tree changes will be marked as typechanges.
103+
#
104+
# :ignore_filemode ::
105+
# If true, file mode changes will be ignored.
106+
#
107+
# :recurse_ignored_dirs ::
108+
# Even if +:include_ignored+ is true, ignored directories will only be
109+
# marked with a single entry in the diff. If this flag is set to true,
110+
# all files under ignored directories will be included in the diff, too.
111+
#
112+
# Examples:
113+
#
114+
# # Emulating `git diff <treeish>`
115+
# tree = Rugged::Tree.lookup(repo, "d70d245ed97ed2aa596dd1af6536e4bfdb047b69")
116+
# diff = tree.diff(repo.index)
117+
# diff.merge!(tree.diff)
118+
#
119+
# # Tree-to-Tree Diff
120+
# tree = Rugged::Tree.lookup(repo, "d70d245ed97ed2aa596dd1af6536e4bfdb047b69")
121+
# other_tree = Rugged::Tree.lookup(repo, "7a9e0b02e63179929fed24f0a3e0f19168114d10")
122+
# diff = tree.diff(other_tree)
123+
#
124+
3125
def self.diff(repo, _self, other = nil, options = {})
4126
if _self && !_self.is_a?(Rugged::Tree)
5127
raise TypeError, "At least a Rugged::Tree object is required for diffing"

0 commit comments

Comments
 (0)