mrb_value
mrb_Git_BlameOptions_initialize(mrb_state* mrb, mrb_value self) {
    git_blame_options* native_object = (git_blame_options*)calloc(1, sizeof(git_blame_options));
    mruby_gift_git_blame_options_data_ptr(self, native_object);
    git_blame_init_options(native_object, GIT_BLAME_OPTIONS_VERSION);
    return self;
}
Example #2
0
static emacs_value extract_options(emacs_env *env, emacs_value eopts, git_blame_options *opts)
{
    int retval = git_blame_init_options(opts, GIT_BLAME_OPTIONS_VERSION);
    EGIT_CHECK_ERROR(retval);

    {
        emacs_value car, cdr;
        EM_DOLIST(option, eopts, loop);
        EM_ASSERT_CONS(option);

        car = em_car(env, option);
        cdr = em_cdr(env, option);

        if (EM_EQ(car, em_first_parent))
            EGIT_SET_BIT(opts->flags, GIT_BLAME_FIRST_PARENT, cdr);

        /* According to libgit2 documentation, the min_match_characters
         * setting only takes effect if GIT_BLAME_TRACK_COPIES_* flags
         * are set, but all of those are marked as not implemented in
         * the source code.
        else if (EM_EQ(car, em_min_match_characters)) {
            EM_ASSERT_INTEGER(cdr);
            opts->min_match_characters = EM_EXTRACT_INTEGER(cdr);
        }
        */

        else if (EM_EQ(car, em_newest_commit)) {
            EM_ASSERT_STRING(cdr);
            EGIT_EXTRACT_OID(cdr, opts->newest_commit);
        }
        else if (EM_EQ(car, em_oldest_commit)) {
            EM_ASSERT_STRING(cdr);
            EGIT_EXTRACT_OID(cdr, opts->oldest_commit);
        }
        else if (EM_EQ(car, em_min_line)) {
            EM_ASSERT_INTEGER(cdr);
            opts->min_line = EM_EXTRACT_INTEGER(cdr);
        }
        else if (EM_EQ(car, em_max_line)) {
            EM_ASSERT_INTEGER(cdr);
            opts->max_line = EM_EXTRACT_INTEGER(cdr);
        }
        else {
            em_signal_wrong_value(env, car);
            return em_nil;
        }

        EM_DOLIST_END(loop);
    }

    return em_t;
}