use --no-abbrev instead of --abbrev=40

This avoids hardcoding the sha size, so when git uses sha256, it will
output the full sha256 and not a truncation to 40 characters.

I reviewed git's history, and while there have been some
bugs with commands not supporting --no-abbrev (eg git diff --no-index
--no-abbrev was broken in git 2.1), none of the commands git-annex
uses will be impacted by those old bugs.
This commit is contained in:
Joey Hess 2020-01-07 12:29:37 -04:00
parent 5e4deb3620
commit 6db4aee7df
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 4 additions and 4 deletions

View file

@ -215,7 +215,7 @@ getGitLog fs os = do
, Param "-z"
, Param "--pretty=format:%ct"
, Param "--raw"
, Param "--abbrev=40"
, Param "--no-abbrev"
] ++ os ++
[ Param $ Git.fromRef Annex.Branch.fullname
, Param "--"

View file

@ -260,7 +260,7 @@ reconcileStaged qh = do
, Param "--cached"
, Param "--raw"
, Param "-z"
, Param "--abbrev=40"
, Param "--no-abbrev"
-- Optimization: Only find pointer files. This is not
-- perfect. A file could start with this and not be a
-- pointer file. And a pointer file that is replaced with

View file

@ -77,14 +77,14 @@ diffFiles = getdiff (Param "diff-files")
- is adjusted to be the same as diff-tree --raw._-}
diffLog :: [CommandParam] -> Repo -> IO ([DiffTreeItem], IO Bool)
diffLog params = getdiff (Param "log")
(Param "-n1" : Param "--abbrev=40" : Param "--pretty=format:" : params)
(Param "-n1" : Param "--no-abbrev" : Param "--pretty=format:" : params)
{- Uses git show to get the changes made by a commit.
-
- Does not support merge commits, and will fail on them. -}
commitDiff :: Sha -> Repo -> IO ([DiffTreeItem], IO Bool)
commitDiff ref = getdiff (Param "show")
[ Param "--abbrev=40", Param "--pretty=", Param "--raw", Param (fromRef ref) ]
[ Param "--no-abbrev", Param "--pretty=", Param "--raw", Param (fromRef ref) ]
getdiff :: CommandParam -> [CommandParam] -> Repo -> IO ([DiffTreeItem], IO Bool)
getdiff command params repo = do