From 24883e01cd487feb1be95146811d65e4f240465d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Oct 2017 12:02:18 -0400 Subject: [PATCH] Fix export of subdir of a branch. Seems I forgot to fully test that feature when documenting it. git rev-parse needs a colon after a branch to de-reference the tree it points to, rather than the commit. But that had it adding an extra colon when the user specified "branch:subdir". So, check if there is a colon before adding one. This commit was sponsored by Francois Marier on Patreon. --- CHANGELOG | 6 ++++++ Git/Ref.hs | 9 +++++++-- .../comment_5_3216edeefa99f484194d6de061283170._comment | 8 ++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 doc/tips/publishing_your_files_to_the_public/comment_5_3216edeefa99f484194d6de061283170._comment diff --git a/CHANGELOG b/CHANGELOG index 283f9597ef..cec9f6e01f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +git-annex (6.20171027) UNRELEASED; urgency=medium + + * Fix export of subdir of a branch. + + -- Joey Hess Mon, 30 Oct 2017 12:01:45 -0400 + git-annex (6.20171026) unstable; urgency=medium * Windows: Fix reversion that caused the path used to link diff --git a/Git/Ref.hs b/Git/Ref.hs index 06fc5dcd71..9a2e47c377 100644 --- a/Git/Ref.hs +++ b/Git/Ref.hs @@ -136,8 +136,13 @@ delete oldvalue ref = run {- Gets the sha of the tree a ref uses. -} tree :: Ref -> Repo -> IO (Maybe Sha) -tree ref = extractSha <$$> pipeReadStrict - [ Param "rev-parse", Param (fromRef ref ++ ":") ] +tree (Ref ref) = extractSha <$$> pipeReadStrict + [ Param "rev-parse", Param ref' ] + where + ref' = if ':' `isInfixOf` ref + then ref + -- de-reference commit objects to the tree + else ref ++ ":" {- Checks if a String is a legal git ref name. - diff --git a/doc/tips/publishing_your_files_to_the_public/comment_5_3216edeefa99f484194d6de061283170._comment b/doc/tips/publishing_your_files_to_the_public/comment_5_3216edeefa99f484194d6de061283170._comment new file mode 100644 index 0000000000..3d7d1196eb --- /dev/null +++ b/doc/tips/publishing_your_files_to_the_public/comment_5_3216edeefa99f484194d6de061283170._comment @@ -0,0 +1,8 @@ +[[!comment format=mdwn + username="joey" + subject="""Re: Problem with publishing subdir. Subdir does not exist, but it does.""" + date="2017-10-30T15:53:33Z" + content=""" +I reproduced export of master:subdir not working. It's a bug in git-annex, +now fixed! +"""]]