Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Both of the following scripts take the blob’s SHA1 as the first argument, and after it, optionally, any arguments that <a href="http://git-scm.com/docs/git-log" rel="noreferrer"><code>git log</code></a> will understand. E.g. <code>--all</code> to search in all branches instead of just the current one, or <code>-g</code> to search in the reflog, or whatever else you fancy.</p> <p>Here it is as a shell script – short and sweet, but slow:</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/sh obj_name="$1" shift git log "$@" --pretty=format:'%T %h %s' \ | while read tree commit subject ; do if git ls-tree -r $tree | grep -q "$obj_name" ; then echo $commit "$subject" fi done </code></pre> <p>And an optimised version in Perl, still quite short but much faster:</p> <pre class="lang-perl prettyprint-override"><code>#!/usr/bin/perl use 5.008; use strict; use Memoize; my $obj_name; sub check_tree { my ( $tree ) = @_; my @subtree; { open my $ls_tree, '-|', git =&gt; 'ls-tree' =&gt; $tree or die "Couldn't open pipe to git-ls-tree: $!\n"; while ( &lt;$ls_tree&gt; ) { /\A[0-7]{6} (\S+) (\S+)/ or die "unexpected git-ls-tree output"; return 1 if $2 eq $obj_name; push @subtree, $2 if $1 eq 'tree'; } } check_tree( $_ ) &amp;&amp; return 1 for @subtree; return; } memoize 'check_tree'; die "usage: git-find-blob &lt;blob&gt; [&lt;git-log arguments ...&gt;]\n" if not @ARGV; my $obj_short = shift @ARGV; $obj_name = do { local $ENV{'OBJ_NAME'} = $obj_short; `git rev-parse --verify \$OBJ_NAME`; } or die "Couldn't parse $obj_short: $!\n"; chomp $obj_name; open my $log, '-|', git =&gt; log =&gt; @ARGV, '--pretty=format:%T %h %s' or die "Couldn't open pipe to git-log: $!\n"; while ( &lt;$log&gt; ) { chomp; my ( $tree, $commit, $subject ) = split " ", $_, 3; print "$commit $subject\n" if check_tree( $tree ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload