]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - bin/git-ls-object-refs
bin/ipaddr: Fix padding for UNAME=Linux
[dotfiles.git] / bin / git-ls-object-refs
1 #!/bin/sh
2 # Usage: git-ls-object-refs <object>
3 # Find references to <object> SHA1 in refs, commits, and trees. All of them.
4 o="$1"
5
6 # rawdawgn' it
7 set +e
8
9 # echo "refs:"
10 # git show-ref |grep "$o"
11 # echo
12
13 git log --all --pretty=oneline --decorate |grep "$o" |
14 sed 's|^\([0-9a-f]\{40\}\)|commit referenced from at least one ref: \1|'
15
16 for ref in $(git for-each-ref --format='%(refname)')
17 do
18 (git rev-list "$ref" | grep "$o") 2>&1 |
19 sed "s|^[0-9a-f]\{40\}$|commit referenced from $ref|"
20 done
21
22 for p in $(git rev-list --all)
23 do
24 (git ls-tree -r "$p" |grep "$o") 2>&1 |
25 sed "s|^|object referenced from tree of commit $p:\n|"
26 done
27 echo