moving git-repair to its own package
This commit is contained in:
parent
3268f0395f
commit
b245aa40df
5 changed files with 4 additions and 92 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -15,8 +15,6 @@ git-annex.1
|
|||
git-annex-shell.1
|
||||
git-union-merge
|
||||
git-union-merge.1
|
||||
git-recover-repository
|
||||
git-recover-repository.1
|
||||
doc/.ikiwiki
|
||||
html
|
||||
*.tix
|
||||
|
|
|
@ -525,10 +525,10 @@ runRepairOf fsckresult forced referencerepo g = do
|
|||
unsuccessfulfinish stillmissing = do
|
||||
if repoIsLocalBare g
|
||||
then do
|
||||
putStrLn "If you have a clone of this bare repository, you should add it as a remote of this repository, and re-run git-recover-repository."
|
||||
putStrLn "If there are no clones of this repository, you can instead run git-recover-repository with the --force parameter to force recovery to a possibly usable state."
|
||||
putStrLn "If you have a clone of this bare repository, you should add it as a remote of this repository, and retry."
|
||||
putStrLn "If there are no clones of this repository, you can instead retry with the --force parameter to force recovery to a possibly usable state."
|
||||
return (False, stillmissing, [])
|
||||
else needforce stillmissing
|
||||
needforce stillmissing = do
|
||||
putStrLn "To force a recovery to a usable state, run this command again with the --force parameter."
|
||||
putStrLn "To force a recovery to a usable state, retry with the --force parameter."
|
||||
return (False, stillmissing, [])
|
||||
|
|
6
Makefile
6
Makefile
|
@ -30,12 +30,8 @@ git-annex-shell.1: doc/git-annex-shell.mdwn
|
|||
# These are not built normally.
|
||||
git-union-merge.1: doc/git-union-merge.mdwn
|
||||
./Build/mdwn2man git-union-merge 1 doc/git-union-merge.mdwn > git-union-merge.1
|
||||
git-recover-repository.1: doc/git-recover-repository.mdwn
|
||||
./Build/mdwn2man git-recover-repository 1 doc/git-recover-repository.mdwn > git-recover-repository.1
|
||||
git-union-merge:
|
||||
$(GHC) --make -threaded $@
|
||||
git-recover-repository:
|
||||
$(GHC) --make -threaded $@
|
||||
|
||||
install-mans: $(mans)
|
||||
install -d $(DESTDIR)$(PREFIX)/share/man/man1
|
||||
|
@ -82,7 +78,7 @@ clean:
|
|||
doc/.ikiwiki html dist tags Build/SysConfig.hs build-stamp \
|
||||
Setup Build/InstallDesktopFile Build/EvilSplicer \
|
||||
Build/Standalone Build/OSXMkLibs \
|
||||
git-union-merge git-recover-repository
|
||||
git-union-merge
|
||||
find . -name \*.o -exec rm {} \;
|
||||
find . -name \*.hi -exec rm {} \;
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
# NAME
|
||||
|
||||
git-recover-repository - Fix a broken git repository
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
git-recover-repository [--force]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
This can fix a corrupt or broken git repository, which git fsck would
|
||||
only complain has problems.
|
||||
|
||||
It does by deleting all corrupt objects, and retreiving all missing
|
||||
objects that it can from the remotes of the repository.
|
||||
|
||||
If that is not sufficient to fully recover the repository, it can also
|
||||
reset branches back to commits before the corruption happened, delete
|
||||
branches that are no longer available due to the lost data, and remove any
|
||||
missing files from the index. It will only do this if run with the
|
||||
`--force` option, since that rewrites history and throws out missing data.
|
||||
Note that the `--force` option never touches tags, even if they are no
|
||||
longer usable due to missing data.
|
||||
|
||||
After running this command, you will probably want to run `git fsck` to
|
||||
verify it fixed the repository. Note that fsck may still complain about
|
||||
objects referenced by the reflog, or the stash, if they were unable to be
|
||||
recovered. This command does not try to clean up either the reflog or the
|
||||
stash.
|
||||
|
||||
Since this command unpacks all packs in the repository, you may want to
|
||||
run `git gc` afterwards.
|
||||
|
||||
# AUTHOR
|
||||
|
||||
Joey Hess <joey@kitenet.net>
|
||||
|
||||
<http://git-annex.branchable.com/>
|
||||
|
||||
Warning: Automatically converted into a man page by mdwn2man. Edit with care
|
|
@ -1,42 +0,0 @@
|
|||
{- git-recover-repository program
|
||||
-
|
||||
- Copyright 2013 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
import System.Environment
|
||||
import qualified Data.Set as S
|
||||
import Data.Tuple.Utils
|
||||
|
||||
import Common
|
||||
import qualified Git
|
||||
import qualified Git.CurrentRepo
|
||||
import qualified Git.Fsck
|
||||
import qualified Git.Repair
|
||||
import qualified Git.Config
|
||||
import qualified Git.Branch
|
||||
|
||||
header :: String
|
||||
header = "Usage: git-recover-repository"
|
||||
|
||||
usage :: a
|
||||
usage = error $ "bad parameters\n\n" ++ header
|
||||
|
||||
parseArgs :: IO Bool
|
||||
parseArgs = do
|
||||
args <- getArgs
|
||||
return $ or $ map parse args
|
||||
where
|
||||
parse "--force" = True
|
||||
parse _ = usage
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
forced <- parseArgs
|
||||
|
||||
g <- Git.Config.read =<< Git.CurrentRepo.get
|
||||
ifM (fst3 <$> Git.Repair.runRepair forced g)
|
||||
( exitSuccess
|
||||
, exitFailure
|
||||
)
|
Loading…
Reference in a new issue