]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - bin/git-find-object
.vimrc: Eliminate .powerline_fonts_enabled stub file
[dotfiles.git] / bin / git-find-object
1 #!/bin/sh
2 #/ Usage: git-find-object <id> <repo>...
3 #/ Write first <repo> that includes object <id>. Useful when trying to locate a
4 #/ missing object in a list of repositories.
5 #/
6 #/ Ex: git-find-object deadbee /repos/*.git
7
8 # shift off the SHA1 object id to look for
9 sha="$1"
10 shift
11
12 # usage
13 [ "$sha" = "--help" ] && {
14 grep ^#/ |cut -c4-
15 exit 2
16 }
17
18 # run through each repo dir and write the path to the first one
19 # that includes the object
20 for dir in "$@"
21 do (cd "$dir" && git cat-file -e $sha 2>/dev/null) && {
22 echo "$dir"
23 exit 0
24 }
25 done
26
27 # if we make it here, the object wasn't found
28 exit 1