Method: Rugged::Blame.new

Defined in:
ext/rugged/rugged_blame.c

.new(repo, path, options = {}) ⇒ Object

Get blame data for the file at path in repo.

The following options can be passed in the options Hash:

:newest_commit

The ID of the newest commit to consider in the blame. Defaults to HEAD. This can either be a Rugged::Object instance, or a full or abbreviated SHA1 id.

:oldest_commit

The id of the oldest commit to consider. Defaults to the first commit encountered with a NULL parent. This can either be a Rugged::Object instance, or a full or abbreviated SHA1 id.

:min_line

The first line in the file to blame. Line numbers start with 1. Defaults to 1.

:max_line

The last line in the file to blame. Defaults to the last line in the file.

:track_copies_same_file

If this value is true, lines that have moved within a file will be tracked (like ‘git blame -M`).

:track_copies_same_commit_moves

If this value is true, lines that have moved across files in the same commit will be tracked (like ‘git blame -C`).

:track_copies_same_commit_copies

If this value is true, lines that have been copied from another file that exists in the same commit will be tracked (like ‘git blame -CC`).

:track_copies_any_commit_copies

If this value is true, lines that have been copied from another file that exists in any commit will be tracked (like ‘git blame -CCC`).

[View source]

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'ext/rugged/rugged_blame.c', line 128

static VALUE rb_git_blame_new(int argc, VALUE *argv, VALUE klass)
{
  VALUE rb_repo, rb_path, rb_options;
  git_repository *repo;
  git_blame *blame;
  git_blame_options opts = GIT_BLAME_OPTIONS_INIT;

  rb_scan_args(argc, argv, "20:", &rb_repo, &rb_path, &rb_options);

  rugged_check_repo(rb_repo);
  Data_Get_Struct(rb_repo, git_repository, repo);

  Check_Type(rb_path, T_STRING);

  rugged_parse_blame_options(&opts, repo, rb_options);

  rugged_exception_check(git_blame_file(
    &blame, repo, StringValueCStr(rb_path), &opts
  ));

  return Data_Wrap_Struct(klass, NULL, &git_blame_free, blame);
}