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

Re: [PATCH 0/8] object_id part 2

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jun 11, 2015, 03:31 UTC
Message-ID
<20150611033107.GA789892@vauxhall.crustytoothpaste.net>
In-Reply-To
<xmqqpp53gkmq.fsf@gitster.dls.corp.google.com>
On Wed, Jun 10, 2015 at 05:21:33PM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
> > [0] https://github.com/bk2204/git.git object-id-part2
> 
> No approach other than just letting reviewers fetch from there and
> taking a look is reasonable, I would think.
> 
> Did you create this manually, or is it a mechanical scripted rewrite
> followed by manual clean-up?  If the latter, it may help people by
> posting the mechanical recipe _and_ a patch that shows the manual
> clean-up.  That is something we can reasonably review and discuss.

It's mostly manual, but some pieces (the is_null_sha1 and sha1_to_hex conversions) were scripted using the embedded Ruby interpreter in Vim. The script I used to do that is below.

  def refactor(s)
    methods = %w(is_null_sha1 sha1_to_hex).map do |m|
      [m, m.sub('sha1', 'oid')]
    end.to_h
    s.sub(/\A(.*)(is_null_sha1|sha1_to_hex)\(([^)]+)(\.|->)sha1\)(.*)\z/) do
      [$1, methods[$2], "(&#{$3}#{$4}oid)", $5].join('')
    end
  end
  
  def replace_line(method)
    func = Object.method(method)
    VIM::Buffer.current.line = func.call(VIM::Buffer.current.line)
  end

It was invoked as replace_line(:refactor), so it basically modified each relevant line by passing it through refactor.

Sorry for choosing a language that's less familiar to the list: if I had known you'd want to see it, I would have used Perl.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
Previous: Junio C HamanoNext: Junio C Hamano
Message 17 of 23 in “object_id part 2”
  1. 0/8 object_id part 2brian m. carlson, Jun 9, 2015
  2. 1/8 refs: convert some internal functions to use object_idbrian m. carlson, Jun 9, 2015
  3. 2/8 sha1_file: introduce has_object_file helper.brian m. carlson, Jun 9, 2015
  4. Duy NguyenJun 10, 2015
  5. brian m. carlsonJun 10, 2015
  6. 3/8 Convert struct ref to use object_id.brian m. carlson, Jun 9, 2015
  7. Michael HaggertyJun 11, 2015
  8. 4/8 Add a utility function to make parsing hex values easier.brian m. carlson, Jun 9, 2015
  9. Michael HaggertyJun 11, 2015
  10. 5/8 add_sought_entry_mem: convert to struct object_idbrian m. carlson, Jun 9, 2015
  11. 6/8 parse_fetch: convert to use struct object_idbrian m. carlson, Jun 9, 2015
  12. 7/8 ref_newer: convert to use struct object_idbrian m. carlson, Jun 9, 2015
  13. Junio C HamanoJun 10, 2015
  14. brian m. carlsonJun 10, 2015
  15. brian m. carlsonJun 11, 2015
  16. Junio C HamanoJun 11, 2015
  17. brian m. carlsonJun 11, 2015
  18. Junio C HamanoJun 11, 2015
  19. brian m. carlsonJun 12, 2015
  20. Junio C HamanoJun 12, 2015
  21. brian m. carlsonJun 12, 2015
  22. Michael HaggertyJun 13, 2015
  23. brian m. carlsonJun 13, 2015

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.