Search code examples
gitubuntugrepresponse

Git grep: Sometimes empty result even when the word exists in a file


I was looking for this before but I couldn't find it. Using: Ubuntu 11.10 64-bit

I want to find a source file a made a time ago, but couldn't find it. So I used git grep to find it:

git rev-list --all | (
    while read revision; do
        git grep -F 'leaderboard' $revision
    done
)

But the result is an empty response! Which is really weird, because 'leaderboard' actually IS in the repository, it's in the current revision, but also in older ones (in an XML file):

<query name="leaderboard.getById">

Other searches gives results, like messages or something will work.


Solution

  • Your syntax leads to an ambiguous redirect in the shell. This should work for you:

    git grep -F 'leaderboard' $(git rev-list --all)