From: Joey Hess Date: Wed, 13 Oct 2021 01:17:13 +0000 (-0400) Subject: avoid crashing tilde expansion on user who does not exist X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~79^2~151 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b36cc0320ecc4c328ba8bdbb8c9d15879ab52ff9;p=git-annex.git avoid crashing tilde expansion on user who does not exist git does not crash when there's a remote configured for a user who does not exist, and this prevents git-annex from crashing too. Consider that a user might exist on one system but not another, and the git repo be moved between systems. So not crashing is desirable. Note that git fetch seems to mishandle a remote path like ~foo/bar when the user does not exist. While it does access ./~foo/bar, and gets as far as running git-upload-pack on the path, it then complains there is no such repo. So different parts of git seem to be doing different things in that edge case. Anyway, git-annex does not need to be bug-for-bug compatible with git. Sponsored-by: Jack Hill on Patreon --- diff --git a/CHANGELOG b/CHANGELOG index a4ff6fb618..dfd6b555c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ git-annex (8.20211012) UNRELEASED; urgency=medium by versions of git-annex older than 6.20180312. * test: Put gpg temp home directory in system temp directory, not filesystem being tested. + * Avoid crashing tilde expansion on user who does not exist. -- Joey Hess Mon, 11 Oct 2021 14:09:13 -0400 diff --git a/Git/Construct.hs b/Git/Construct.hs index c013eb2464..a5e825e7c3 100644 --- a/Git/Construct.hs +++ b/Git/Construct.hs @@ -184,7 +184,10 @@ expandTilde :: FilePath -> IO FilePath #ifdef mingw32_HOST_OS expandTilde = return #else -expandTilde = expandt True +expandTilde p = expandt True p + -- If unable to expand a tilde, eg due to a user not existing, + -- use the path as given. + `catchNonAsync` (const (return p)) where expandt _ [] = return "" expandt _ ('/':cs) = do