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

Re: My custom cccmd

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Oct 25, 2009, 15:04 UTC
Message-ID
<94a0d4530910250804w3a7da36eke10710eb1cbb03c1@mail.gmail.com>
In-Reply-To
<94a0d4530910151437s780bd96anca82d2b26ef99e0a@mail.gmail.com>

On Thu, Oct 15, 2009 at 11:37 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 10 quoted lines
> On Thu, Oct 15, 2009 at 11:09 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>  #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.
>
> How exactly? By looking at the commit from 'git blame' and discarding
> it? That would be a bit tricky since each instance of 'cccmd' is not
> aware of the previous ones.

I explored this a bit more and I've come to the conclusion that we actually don't wand to discard the previous commits in the patch series. Let's think about this example: 0001 <- John 0002 <- Me overriding some changes from John

In this case we want John to appear in the CC list of 0002, because we are changing his code. If it turns out that the whole patch series was written by me, it's still ok for me to appear on the CC list, which would essentially be "discarding" those commits.

So all we need to do is pick @from^ as the base of the git blame:
@@ -17,11 +17,12 @@ end
 ARGV.each do |filename|
   patch_file = File.open(filename)
   patch_file.each_line do |patch_line|
+    @from ||= patch_line[/From (\w+)/, 1]
     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 = `git blame --incremental -L #{$1},+#{$2} #{@source}
#{@from}^ | grep author`
       blame.each_line { |l| parse_blame(l.chomp) }
     end
   end

You can find the whole script here:
http://gist.github.com/218093

Cheers.
-- 
Felipe Contreras
Previous: Felipe ContrerasNext: Junio C Hamano
Message 4 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.