]> git.ipfire.org Git - thirdparty/git.git/blame - git-lost-found.sh
Merge branches 'jc/branch' and 'jc/rebase'
[thirdparty/git.git] / git-lost-found.sh
CommitLineData
04e7ca1a
JH
1#!/bin/sh
2
3. git-sh-setup || die "Not a git archive."
4
07203659 5laf="$GIT_DIR/lost-found"
04e7ca1a
JH
6rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
7
8git fsck-objects |
9while read dangling type sha1
10do
11 case "$dangling" in
12 dangling)
13 if git-rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null
14 then
15 dir="$laf/commit"
16 git-show-branch "$sha1"
17 else
18 dir="$laf/other"
19 fi
20 echo "$sha1" >"$dir/$sha1"
21 ;;
22 esac
23done