git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 00/44] Ruby support

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Sep 28, 2013, 22:03 UTC
Message-ID
<1380405849-13000-1-git-send-email-felipe.contreras@gmail.com>
This is a different patch series that tries a different approach.

First, this series allows external scripts to also access libgit through Ruby bindings:

  git ruby <<EOF
  for_each_ref() do |name, sha1, flags|
    puts "%s: %s" % [name, sha1_to_hex(sha1)]
  end
  EOF

This way third party script writers can write Ruby code that resembles Git's internal C code, but in a much simpler way.

Since the importance of the contrib area is fading, and it's important to move all Git commands to C, it's helpful to have tools that allows third parties to rewrite scripts that are easier to rewrite to C.

In addition, this would help Git developers to create quick prototypes and test new code.

Finally, and perhaps most importantly, Ruby scripts can be intermediaries between perl/shell scripts, and the final desired C code.

I already argued this, but here is a clear demonstration.

I took git-request-pull.sh, converted it to Ruby and incrementally moodified it until the resulting code was essentially what the code would look like in C, and then, finally, the rewrite to C, which follows the exact same logic of the Ruby script.

In the progress of doing this, it was clear the shell script was buggy, so it was fixed, and the C code needed fixes as well.

If we are serious about converting *all scripts* to C, clearly a powerful tool is needed, and Ruby bindings fit the bill.

Ruby scripts could be provided alongside the perl/shell alternatives, so people that build with NO_RUBY=y don't loose any functionality. And eventually the Ruby scripts (and originals) get removed once the conversion to C is completed.

Even if Ruby is not used as an intermediary tool, and no official Git scripts are converted to C this way, the bindings would still be useful to third parties.

Who wouldn't benefit from adding this support?
Felipe Contreras (44):
  Add support for ruby commands
  ruby: add support for internal ruby programs
  request-pull: fix annotated tag check
  request-pull: fix for specific branch
  request-pull: use appropriate ref
  request-pull: fix exact match checking
  request-pull: trivial simplification
  request-pull: t: trivial whitespace style fixes
  request-pull: t: add missing cat
  ruby: rewrite 'request-pull'
  ruby: request-pull: rewrite perl script
  ruby: request-pull: trivial simplifications
  ruby: bind setup_git_directory()
  ruby: bind dwim_ref()
  ruby: request-pull: use native dwim_ref()
  ruby: bind git_config()
  ruby: request-pull: use native git_config()
  ruby: bind read_ref()/peel_ref()
  ruby: bind get_sha1()
  ruby: request-pull: simplify tag fetching
  ruby: request-pull: use get_sha1()
  ruby: add Commit class
  ruby: bind get_merge_bases()
  ruby: request-pull: use get_merge_bases()
  ruby: request-pull: trivial cleanups
  ruby: bind remote and transport stuff
  ruby: request-pull: use native remote and transport
  ruby: bind find_unique_abbrev()
  ruby: request-pull: use native commit info
  ruby: bind read_sha1_file()
  ruby: request-pull: use read_sha1_file()
  revision: add missing include
  shortlog: add missing declaration
  shortlog: split builtin from common code
  ruby: add RevInfo and DiffOptions
  ruby: bind shortlog()
  ruby: request-pull: use shortlog()
  ruby: bind diff_tree_sha1()
  ruby: bind log_tree_diff_flush()
  ruby: request-pull: use native diff_tree stuff
  ruby: request-pull: remove rescue block
  ruby: remove GIT_PAGER from environment
  ruby: add simpler option parser
  request-pull: rewrite to C
 .gitignore              |   1 +
 Makefile                |  31 ++-
 builtin.h               |   1 +
 builtin/request-pull.c  | 275 +++++++++++++++++++++++
 builtin/shortlog.c      | 184 +--------------
 git-rb-setup.rb         | 109 +++++++++
 git-request-pull.sh     | 162 --------------
 git.c                   |   1 +
 revision.h              |   1 +
 ruby.c                  | 584 ++++++++++++++++++++++++++++++++++++++++++++++++
 shortlog.c              | 181 +++++++++++++++
 shortlog.h              |   8 +
 t/t10000-ruby.sh        | 233 +++++++++++++++++++
 t/t5150-request-pull.sh |  81 +++++--
 14 files changed, 1492 insertions(+), 360 deletions(-)
 create mode 100644 builtin/request-pull.c
 create mode 100644 git-rb-setup.rb
 delete mode 100755 git-request-pull.sh
 create mode 100644 ruby.c
 create mode 100644 shortlog.c
 create mode 100755 t/t10000-ruby.sh
-- 
1.8.4-fc
Next: Felipe Contreras
Message 1 of 62 in “Ruby support”
  1. 00/44 Ruby supportFelipe Contreras, Sep 28, 2013
  2. 01/44 Add support for ruby commandsFelipe Contreras, Sep 28, 2013
  3. Ramkumar RamachandraSep 29, 2013
  4. Felipe ContrerasSep 29, 2013
  5. 02/44 ruby: add support for internal ruby programsFelipe Contreras, Sep 28, 2013
  6. Ramkumar RamachandraSep 29, 2013
  7. Felipe ContrerasSep 29, 2013
  8. Felipe ContrerasSep 29, 2013
  9. 03/44 request-pull: fix annotated tag checkFelipe Contreras, Sep 28, 2013
  10. Ramkumar RamachandraSep 29, 2013
  11. 04/44 request-pull: fix for specific branchFelipe Contreras, Sep 28, 2013
  12. 05/44 request-pull: use appropriate refFelipe Contreras, Sep 28, 2013
  13. 06/44 request-pull: fix exact match checkingFelipe Contreras, Sep 28, 2013
  14. 07/44 request-pull: trivial simplificationFelipe Contreras, Sep 28, 2013
  15. 08/44 request-pull: t: trivial whitespace style fixesFelipe Contreras, Sep 28, 2013
  16. 09/44 request-pull: t: add missing catFelipe Contreras, Sep 28, 2013
  17. 10/44 ruby: rewrite 'request-pull'Felipe Contreras, Sep 28, 2013
  18. Ramkumar RamachandraSep 29, 2013
  19. 11/44 ruby: request-pull: rewrite perl scriptFelipe Contreras, Sep 28, 2013
  20. Ramkumar RamachandraSep 29, 2013
  21. 12/44 ruby: request-pull: trivial simplificationsFelipe Contreras, Sep 28, 2013
  22. 13/44 ruby: bind setup_git_directory()Felipe Contreras, Sep 28, 2013
  23. Ramkumar RamachandraSep 29, 2013
  24. Felipe ContrerasSep 29, 2013
  25. 14/44 ruby: bind dwim_ref()Felipe Contreras, Sep 28, 2013
  26. Ramkumar RamachandraSep 29, 2013
  27. Felipe ContrerasSep 29, 2013
  28. 15/44 ruby: request-pull: use native dwim_ref()Felipe Contreras, Sep 28, 2013
  29. 16/44 ruby: bind git_config()Felipe Contreras, Sep 28, 2013
  30. 17/44 ruby: request-pull: use native git_config()Felipe Contreras, Sep 28, 2013
  31. 18/44 ruby: bind read_ref()/peel_ref()Felipe Contreras, Sep 28, 2013
  32. 19/44 ruby: bind get_sha1()Felipe Contreras, Sep 28, 2013
  33. 20/44 ruby: request-pull: simplify tag fetchingFelipe Contreras, Sep 28, 2013
  34. 21/44 ruby: request-pull: use get_sha1()Felipe Contreras, Sep 28, 2013
  35. 22/44 ruby: add Commit classFelipe Contreras, Sep 28, 2013
  36. 23/44 ruby: bind get_merge_bases()Felipe Contreras, Sep 28, 2013
  37. 24/44 ruby: request-pull: use get_merge_bases()Felipe Contreras, Sep 28, 2013
  38. 25/44 ruby: request-pull: trivial cleanupsFelipe Contreras, Sep 28, 2013
  39. 26/44 ruby: bind remote and transport stuffFelipe Contreras, Sep 28, 2013
  40. 27/44 ruby: request-pull: use native remote and transportFelipe Contreras, Sep 28, 2013
  41. 28/44 ruby: bind find_unique_abbrev()Felipe Contreras, Sep 28, 2013
  42. 29/44 ruby: request-pull: use native commit infoFelipe Contreras, Sep 28, 2013
  43. 30/44 ruby: bind read_sha1_file()Felipe Contreras, Sep 28, 2013
  44. 31/44 ruby: request-pull: use read_sha1_file()Felipe Contreras, Sep 28, 2013
  45. 32/44 revision: add missing includeFelipe Contreras, Sep 28, 2013
  46. 33/44 shortlog: add missing declarationFelipe Contreras, Sep 28, 2013
  47. 34/44 shortlog: split builtin from common codeFelipe Contreras, Sep 28, 2013
  48. 35/44 ruby: add RevInfo and DiffOptionsFelipe Contreras, Sep 28, 2013
  49. 36/44 ruby: bind shortlog()Felipe Contreras, Sep 28, 2013
  50. 37/44 ruby: request-pull: use shortlog()Felipe Contreras, Sep 28, 2013
  51. 38/44 ruby: bind diff_tree_sha1()Felipe Contreras, Sep 28, 2013
  52. 39/44 ruby: bind log_tree_diff_flush()Felipe Contreras, Sep 28, 2013
  53. 40/44 ruby: request-pull: use native diff_tree stuffFelipe Contreras, Sep 28, 2013
  54. 41/44 ruby: request-pull: remove rescue blockFelipe Contreras, Sep 28, 2013
  55. 42/44 ruby: remove GIT_PAGER from environmentFelipe Contreras, Sep 28, 2013
  56. Stefan BellerSep 28, 2013
  57. Felipe ContrerasSep 28, 2013
  58. 43/44 ruby: add simpler option parserFelipe Contreras, Sep 28, 2013
  59. 44/44 request-pull: rewrite to CFelipe Contreras, Sep 28, 2013
  60. Ramkumar RamachandraSep 29, 2013
  61. Ramkumar RamachandraSep 29, 2013
  62. Felipe ContrerasSep 29, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.