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

[PATCH v5 13/15] contrib: related: add option to parse from committish

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 18, 2013, 11:46 UTC
Message-ID
<1368877615-9563-14-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1368877615-9563-1-git-send-email-felipe.contreras@gmail.com>
For example master..feature-a.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/related/git-related | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/contrib/related/git-related b/contrib/related/git-related
index aec156e..8394cdc 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -8,6 +8,8 @@ require 'optparse'
 $since = '5-years-ago'
 $min_percent = 10
 $show_commits = false
+$files = []
+$rev_args = []
 
 $mailmaps = {}
 $mailmaps_complex = {}
@@ -15,7 +17,7 @@ $mailmaps_complex = {}
 begin
   OptionParser.new do |opts|
     opts.program_name = 'git related'
-    opts.banner = 'usage: git related [options] <files>'
+    opts.banner = 'usage: git related [options] <files | rev-list options>'
 
     opts.on('-p', '--min-percent N', Integer, 'Minium percentage of role participation') do |v|
       $min_percent = v
@@ -228,10 +230,40 @@ class Commits
     end
   end
 
+  def from_rev_args(args)
+    return if args.empty?
+    source = nil
+    File.popen(%w[git rev-list --reverse] + args) do |p|
+      p.each do |e|
+        id = e.chomp
+        @main_commits[id] = true
+        File.popen(%w[git show -C --oneline] + [id]) do |p|
+          p.each do |e|
+            case e
+            when /^---\s+(\S+)/
+              source = $1 != '/dev/null' ? $1[2..-1] : nil
+            when /^@@ -(\d+)(?:,(\d+))?/
+              get_blame(source, $1, $2, id)
+            end
+          end
+        end
+      end
+    end
+  end
+
+end
+
+ARGV.each do |e|
+  if File.exists?(e)
+    $files << e
+  else
+    $rev_args << e
+  end
 end
 
 commits = Commits.new
-commits.from_patches(ARGV)
+commits.from_patches($files)
+commits.from_rev_args($rev_args)
 commits.import
 
 if $show_commits
-- 
1.8.3.rc2.542.g24820ba
Previous: Felipe ContrerasNext: Felipe Contreras
Message 26 of 28 in “New git-related helper”
  1. 00/15 New git-related helperFelipe Contreras, May 18, 2013
  2. 01/15 Add new git-related helper to contribFelipe Contreras, May 18, 2013
  3. Felipe ContrerasMay 18, 2013
  4. Junio C HamanoMay 19, 2013
  5. Felipe ContrerasMay 19, 2013
  6. Ramkumar RamachandraMay 19, 2013
  7. Felipe ContrerasMay 19, 2013
  8. Ramkumar RamachandraMay 19, 2013
  9. Felipe ContrerasMay 19, 2013
  10. David AguilarMay 19, 2013
  11. Ramkumar RamachandraMay 19, 2013
  12. Ramkumar RamachandraMay 19, 2013
  13. Felipe ContrerasMay 19, 2013
  14. Felipe ContrerasMay 19, 2013
  15. 02/15 contrib: related: add option parsingFelipe Contreras, May 18, 2013
  16. 03/15 contrib: related: sort by amount of involvementFelipe Contreras, May 18, 2013
  17. 04/15 contrib: related: print the amount of involvementFelipe Contreras, May 18, 2013
  18. 05/15 contrib: related: add helper Person classesFelipe Contreras, May 18, 2013
  19. 06/15 contrib: related: show role countFelipe Contreras, May 18, 2013
  20. 07/15 contrib: related: add support for more rolesFelipe Contreras, May 18, 2013
  21. 08/15 contrib: related: group persons with same emailFelipe Contreras, May 18, 2013
  22. 09/15 contrib: related: add mailmap supportFelipe Contreras, May 18, 2013
  23. 10/15 contrib: related: allow usage on other directoriesFelipe Contreras, May 18, 2013
  24. 11/15 contrib: related: add support for multiple patchesFelipe Contreras, May 18, 2013
  25. 12/15 contrib: related: add option to show commitsFelipe Contreras, May 18, 2013
  26. 13/15 contrib: related: add option to parse from committishFelipe Contreras, May 18, 2013
  27. 14/15 contrib: related: parse committish like format-patchFelipe Contreras, May 18, 2013
  28. 15/15 contrib: related: fix parsing of rev-list argsFelipe Contreras, May 18, 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.