On Sat, Sep 28, 2013 at 11:30 PM, Ramkumar Ramachandra
<artag...@gmail.com> wrote:
> Felipe Contreras wrote:
>> +test_expect_success 'argument passing' '
>> +       cat > script <<-"EOF" &&
>> +       p($0)
>> +       p(ARGV)
>> +       EOF
>> +       git ruby script foo bar > actual &&
>> +       cat > expected <<-EOF &&
>> +       "script"
>> +       ["foo", "bar"]
>> +       EOF
>> +       test_cmp expected actual
>> +'
>
> So, git-ruby is a new builtin that's just like a ruby interpreter,
> except that it has certain git-related functions defined: you pass it
> source code on stdin, and it returns the result on stdout. I wonder
> what the purpose of passing arguments to it is though.

git ruby is just like ruby, so you can pass the script from stdin, or
you can specify the script name.

>> +test_expect_success 'test for_each_ref()' '
>> +       test_commit foo &&
>> +       git ruby > actual <<-EOF &&
>> +       for_each_ref() do |name, sha1, flags|
>> +               puts "%s: %s" % [name, sha1_to_hex(sha1)]
>> +       end
>> +       EOF
>> +       git for-each-ref --format="%(refname): %(objectname)" > expected &&
>> +       test_cmp expected actual
>> +'
>
> I find it interesting that you chose to implement for-each-ref in the
> initial version. It currently takes no arguments, but we can always
> extend it to do ref-hierarchy filtering like f-e-r in the future.

It takes no arguments because for_each_ref()(refs.h) takes no
arguments (that Ruby would need). builtin/for-each-ref.c uses
for_each_rawref()(refs.h), which is basically the same.

-- 
Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to