Re: [PATCH 0/8] object_id part 2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 10, 2015 at 05:21:33PM -0700, Junio C Hamano wrote:
> "brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> 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

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]