pre-commit: Update direct mode mappings.
Making the pre-commit hook look at git diff-index to find changed direct mode files and update the mappings works pretty well. One case where it does not work is when a file is git annex added, and then git rmed, and then this is committed. That's a no-op commit, so the hook probably doesn't even run, and it certianly never notices that the file was deleted, so the mapping will still have the original filename in it. For this and other reasons, it's important that the mappings still be treated as possibly inconsistent. Also, the assistant now allows the pre-commit hook to run when in direct mode, so the mappings also get updated there.
This commit is contained in:
		
					parent
					
						
							
								ceb732bea7
							
						
					
				
			
			
				commit
				
					
						547d7745fb
					
				
			
		
					 8 changed files with 75 additions and 33 deletions
				
			
		| 
						 | 
				
			
			@ -37,6 +37,13 @@ exists :: Ref -> Repo -> IO Bool
 | 
			
		|||
exists ref = runBool "show-ref" 
 | 
			
		||||
	[Param "--verify", Param "-q", Param $ show ref]
 | 
			
		||||
 | 
			
		||||
{- Checks if HEAD exists. It generally will, except for in a repository
 | 
			
		||||
 - that was just created. -}
 | 
			
		||||
headExists :: Repo -> IO Bool
 | 
			
		||||
headExists repo = do
 | 
			
		||||
	ls <- lines <$> pipeReadStrict [Param "show-ref", Param "--head"] repo
 | 
			
		||||
	return $ any (" HEAD" `isSuffixOf`) ls
 | 
			
		||||
 | 
			
		||||
{- Get the sha of a fully qualified git ref, if it exists. -}
 | 
			
		||||
sha :: Branch -> Repo -> IO (Maybe Sha)
 | 
			
		||||
sha branch repo = process <$> showref repo
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue