lookupkey: Allow using --ref in a bare repository.
authorJoey Hess <joeyh@joeyh.name>
Fri, 30 Aug 2024 14:48:10 +0000 (10:48 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 30 Aug 2024 14:55:48 +0000 (10:55 -0400)
CHANGELOG
Command/LookupKey.hs
doc/bugs/lookupkey_--ref_refuses_to_run_in_bare_repository.mdwn
doc/bugs/lookupkey_--ref_refuses_to_run_in_bare_repository/comment_3_d88061641439dd029939584cc5679a40._comment [new file with mode: 0644]

index 37b3688b86b1e31ec80361c453f385a6d9699ca0..db03e5af796e77ad84f09b96ffa5db03fdba76fb 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@ git-annex (10.20240831) UNRELEASED; urgency=medium
   * The config versioning=true is now reserved for use by versioned special
     remotes. External special remotes should not use that config for their
     own purposes.
+  * lookupkey: Allow using --ref in a bare repository.
 
  -- Joey Hess <id@joeyh.name>  Wed, 31 Jul 2024 15:52:03 -0400
 
index f191aa1e8b1c6193b7c6a4af5111d8c2df60354a..32df8865327429cba879fe9955a30324706b26e1 100644 (file)
@@ -15,7 +15,7 @@ import Utility.Terminal
 import Utility.SafeOutput
 
 cmd :: Command
-cmd = notBareRepo $ noCommit $ noMessages $
+cmd = noCommit $ noMessages $
        command "lookupkey" SectionPlumbing 
                "looks up key used for file"
                (paramRepeating paramFile)
@@ -35,9 +35,11 @@ optParser = LookupKeyOptions
 run :: LookupKeyOptions -> SeekInput -> String -> Annex Bool
 run o _ file
        | refOption o = catKey (Ref (toRawFilePath file)) >>= display
-       | otherwise = seekSingleGitFile file >>= \case
-               Nothing -> return False
-               Just file' -> catKeyFile file' >>= display
+       | otherwise = do
+               checkNotBareRepo
+               seekSingleGitFile file >>= \case
+                       Nothing -> return False
+                       Just file' -> catKeyFile file' >>= display
 
 display :: Maybe Key -> Annex Bool
 display (Just k) = do
index 7c11340b57cd20bc517a307ad11dd2d9109ca37a..b30487ec90d7a12f2dc63a17a60cd0c0c4c6a3ad 100644 (file)
@@ -37,3 +37,4 @@ git-annex: You cannot run this command in a bare repository.
 ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
 
 
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/lookupkey_--ref_refuses_to_run_in_bare_repository/comment_3_d88061641439dd029939584cc5679a40._comment b/doc/bugs/lookupkey_--ref_refuses_to_run_in_bare_repository/comment_3_d88061641439dd029939584cc5679a40._comment
new file mode 100644 (file)
index 0000000..e191890
--- /dev/null
@@ -0,0 +1,14 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 3"""
+ date="2024-08-30T14:47:41Z"
+ content="""
+Fixed that.
+
+It kind of seems like metadata could have an option to get the metadata for
+a specific ref as well, but since it already has --branch which takes a
+branch ref, adding a --ref which takes a file ref seems confusing. Maybe
+--fileref? There are a decent number of other commands that also use
+parseKeyOptions to support --branch/--key/--all that would also get the new
+option if it were implemented.
+"""]]