From 04e7ca1a1bd05e733236734bd7078b4cde1f7ce5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 7 Nov 2005 15:15:34 -0800 Subject: git-lost+found This command helps you resurrect accidentally lost tags and commits. Signed-off-by: Junio C Hamano --- git-lost+found.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 git-lost+found.sh (limited to 'git-lost+found.sh') diff --git a/git-lost+found.sh b/git-lost+found.sh new file mode 100755 index 0000000000..b6b2616e45 --- /dev/null +++ b/git-lost+found.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +. git-sh-setup || die "Not a git archive." + +laf="$GIT_DIR/lost+found" +rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit + +git fsck-objects | +while read dangling type sha1 +do + case "$dangling" in + dangling) + if git-rev-parse --verify "$sha1^0" >/dev/null 2>/dev/null + then + dir="$laf/commit" + git-show-branch "$sha1" + else + dir="$laf/other" + fi + echo "$sha1" >"$dir/$sha1" + ;; + esac +done -- cgit v1.3 From 07203659d0dae619f78773d3caea6b58907a1ba5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 10 Nov 2005 19:16:26 -0800 Subject: Rename .git/lost+found to .git/lost-found. Just to avoid confusion that scripts poorly written by somebody else ;-) might mistake this as a mount point, or backup tools ignoring the directory. The latter is probably not a big loss, however, considering that this directory's contents are to be used while fresh anyway. Signed-off-by: Junio C Hamano --- Documentation/git-lost+found.txt | 8 ++++---- git-lost+found.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'git-lost+found.sh') diff --git a/Documentation/git-lost+found.txt b/Documentation/git-lost+found.txt index 0cb8e3bbfe..660e90b109 100644 --- a/Documentation/git-lost+found.txt +++ b/Documentation/git-lost+found.txt @@ -12,9 +12,9 @@ SYNOPSIS DESCRIPTION ----------- Finds dangling commits and tags from the object database, and -creates refs to them in .git/lost+found/ directory. Commits and -tags that dereference to commits go to .git/lost+found/commit -and others are stored in .git/lost+found/other directory. +creates refs to them in .git/lost-found/ directory. Commits and +tags that dereference to commits go to .git/lost-found/commit +and others are stored in .git/lost-found/other directory. OUTPUT @@ -40,7 +40,7 @@ Also you can use gitk to browse how they relate to each other and existing (probably old) tags. ------------ -$ gitk $(cd .git/lost+found/commit && echo ??*) +$ gitk $(cd .git/lost-found/commit && echo ??*) ------------ After making sure that it is the object you are looking for, you diff --git a/git-lost+found.sh b/git-lost+found.sh index b6b2616e45..3892f52005 100755 --- a/git-lost+found.sh +++ b/git-lost+found.sh @@ -2,7 +2,7 @@ . git-sh-setup || die "Not a git archive." -laf="$GIT_DIR/lost+found" +laf="$GIT_DIR/lost-found" rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit git fsck-objects | -- cgit v1.3