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

Re: My custom cccmd

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 15, 2009, 20:09 UTC
Message-ID
<7vk4yw4dy3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<94a0d4530910150620g733bdf0aq88660053f869b0a9@mail.gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 11 quoted lines
> Hi,
>
> I love the new option to run a cccmd and how good it works on the
> linux kernel, but I couldn't find a generic script. So I decided to
> write my own.
>
> It's very simple, it just looks into the authors of the commits that
> modified the lines being overridden (git blame). It's not checking for
> s-o-b, or anything fancy.
>
> Comments?
Show 28 quoted lines
> #!/usr/bin/env ruby
>
> @commits = {} # keeps a count of commits per author
>
> ARGV.each do |filename|
>   File.open(filename) do |patch_file|
>     patch_file.each_line do |patch_line|
>       case patch_line
>       when /^---\s+(\S+)/
>         @source = $1[2..-1]
>       when /^@@\s-(\d+),(\d+)/
>         blame = `git blame -p -L #{$1},+#{$2} #{@source} | grep author`
>         blame.each_line do |al|
>           key, value = al.chomp.split(" ", 2)
>           case key
>           when "author"
>             @name = value
>           when "author-mail"
>             @mail = value
>             author = "\"#{@name}\" #{@mail}"
>             @commits[author] ||= 0
>             @commits[author] += 1
>           end
>         end
>       end
>     end
>   end
> end
Comments.
 #0. Gaahhh, my eyes, my eyes!!  Can't you do this ugly run of infinite
     number of "end"s?
 #1. You are not making sure that you start blaming from the commit the
     patch is based on, so your -La,b line numbers can be off.  If you can
     assume that you are always reading format-patch output, you can learn
     which commit to start from by reading the first "magic" line.
     
 #2. If you have two patch series that updates one file twice, some
     changes in your second patch could even be an update to the changes
     you introduced in your first patch.  After you fix issue #1, you
     would probably want to fix this by excluding the commits you have
     already sent the blames for.
 #3. Does the number of commits you keep per author have any significance?
     I know it doesn't in the implementation you posted, but should it,
     and if so how?
Show 10 quoted lines
> @commits.each_key do |a|
>   puts a
> end
>
> -- 
> Felipe Contreras
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Felipe ContrerasNext: Felipe Contreras
Message 2 of 8 in “My custom cccmd”
  1. Felipe ContrerasOct 15, 2009
  2. Junio C HamanoOct 15, 2009
  3. Felipe ContrerasOct 15, 2009
  4. Felipe ContrerasOct 25, 2009
  5. Junio C HamanoOct 27, 2009
  6. Felipe ContrerasOct 30, 2009
  7. Junio C HamanoOct 30, 2009
  8. Felipe ContrerasNov 2, 2009

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.