avoid crashing tilde expansion on user who does not exist
authorJoey Hess <joeyh@joeyh.name>
Wed, 13 Oct 2021 01:17:13 +0000 (21:17 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 13 Oct 2021 13:16:36 +0000 (09:16 -0400)
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
CHANGELOG
Git/Construct.hs

index a4ff6fb6185ebfaa1801a0d32d2e9e75284d5fdc..dfd6b555c81469978da817df310266363fb49696 100644 (file)
--- 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 <id@joeyh.name>  Mon, 11 Oct 2021 14:09:13 -0400
 
index c013eb246439da369c6e81afadb39e3af7020df5..a5e825e7c35e51dadc9adb65ba4e324725d2c6d3 100644 (file)
@@ -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