Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 60565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:10:55+00:00 2026-05-10T18:10:55+00:00

Given the hash of a blob, is there a way to get a list

  • 0

Given the hash of a blob, is there a way to get a list of commits that have this blob in their tree?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:10:55+00:00Added an answer on May 10, 2026 at 6:10 pm

    Both of the following scripts take the blob’s SHA1 as the first argument, and after it, optionally, any arguments that git log will understand. E.g. --all to search in all branches instead of just the current one, or -g to search in the reflog, or whatever else you fancy.

    Here it is as a shell script – short and sweet, but slow:

    #!/bin/sh obj_name="$1" shift git log "$@" --pretty=tformat:'%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 

    And an optimised version in Perl, still quite short but much faster:

    #!/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 => 'ls-tree' => $tree             or die "Couldn't open pipe to git-ls-tree: $!\n";          while ( <$ls_tree> ) {             /\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( $_ ) && return 1 for @subtree;      return; }  memoize 'check_tree';  die "usage: git-find-blob <blob> [<git-log arguments ...>]\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 => log => @ARGV, '--pretty=format:%T %h %s'     or die "Couldn't open pipe to git-log: $!\n";  while ( <$log> ) {     chomp;     my ( $tree, $commit, $subject ) = split " ", $_, 3;     print "$commit $subject\n" if check_tree( $tree ); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Use something like this http://blog.eworldui.net/post/2008/04/ASPNET-MVC---Legacy-Url-Routing.aspx You don't have to use… May 11, 2026 at 11:29 am
  • added an answer Java2Html - Eclipse Plugin: Convert files: Select items in the… May 11, 2026 at 11:29 am
  • added an answer If you have a Visual Studio 2008 solution composed of… May 11, 2026 at 11:29 am

Related Questions

Given the hash of a blob, is there a way to get a list
Given a data structure (e.g. a hash of hashes), what's the clean/recommended way to
I thought I understood what the default method does to a hash... Give a
Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using
Given the following XML: <current> <login_name>jd</login_name> </current> <people> <person> <first>John</first> <last>Doe</last> <login_name>jd</login_name> </preson> <person>
Given the constraint of only using T-Sql in Sql Server 2005, is there a
Given the following: List<List<Option>> optionLists; what would be a quick way to determine the
Given the following example, why do I have to explicitly use the statement b->A::DoSomething()
Given the key for some registry value (e.g. HKEY_LOCAL_MACHINE\blah\blah\blah\foo) how can I: Safely determine
Given the case I made two independent changes in one file: eg. added a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.