init: Configure .git/info/attributes to use git-annex as a smudge filter.
Note that this changes the default behavior of git add in a newly initialized repository; it will add files to the annex. Don't like that this could break workflows, but it's necessary in order for any pointer files in the repo to be handled by git-annex.
This commit is contained in:
parent
fb6ebdaae7
commit
2fe21d47c5
6 changed files with 60 additions and 21 deletions
13
Config.hs
13
Config.hs
|
@ -95,3 +95,16 @@ configureSmudgeFilter :: Annex ()
|
||||||
configureSmudgeFilter = do
|
configureSmudgeFilter = do
|
||||||
setConfig (ConfigKey "filter.annex.smudge") "git-annex smudge %f"
|
setConfig (ConfigKey "filter.annex.smudge") "git-annex smudge %f"
|
||||||
setConfig (ConfigKey "filter.annex.clean") "git-annex smudge --clean %f"
|
setConfig (ConfigKey "filter.annex.clean") "git-annex smudge --clean %f"
|
||||||
|
lf <- Annex.fromRepo Git.attributesLocal
|
||||||
|
gf <- Annex.fromRepo Git.attributes
|
||||||
|
lfs <- readattr lf
|
||||||
|
gfs <- readattr gf
|
||||||
|
liftIO $ unless ("filter=annex" `isInfixOf` (lfs ++ gfs)) $ do
|
||||||
|
createDirectoryIfMissing True (takeDirectory lf)
|
||||||
|
writeFile lf (lfs ++ "\n" ++ stdattr)
|
||||||
|
where
|
||||||
|
readattr = liftIO . catchDefaultIO "" . readFileStrictAnyEncoding
|
||||||
|
stdattr = unlines
|
||||||
|
[ "* filter=annex"
|
||||||
|
, ".* !filter"
|
||||||
|
]
|
||||||
|
|
8
Git.hs
8
Git.hs
|
@ -28,6 +28,7 @@ module Git (
|
||||||
repoPath,
|
repoPath,
|
||||||
localGitDir,
|
localGitDir,
|
||||||
attributes,
|
attributes,
|
||||||
|
attributesLocal,
|
||||||
hookPath,
|
hookPath,
|
||||||
assertLocal,
|
assertLocal,
|
||||||
adjustPath,
|
adjustPath,
|
||||||
|
@ -125,8 +126,11 @@ assertLocal repo action
|
||||||
{- Path to a repository's gitattributes file. -}
|
{- Path to a repository's gitattributes file. -}
|
||||||
attributes :: Repo -> FilePath
|
attributes :: Repo -> FilePath
|
||||||
attributes repo
|
attributes repo
|
||||||
| repoIsLocalBare repo = repoPath repo ++ "/info/.gitattributes"
|
| repoIsLocalBare repo = attributesLocal repo
|
||||||
| otherwise = repoPath repo ++ "/.gitattributes"
|
| otherwise = repoPath repo </> ".gitattributes"
|
||||||
|
|
||||||
|
attributesLocal :: Repo -> FilePath
|
||||||
|
attributesLocal repo = localGitDir repo </> "info" </> "attributes"
|
||||||
|
|
||||||
{- Path to a given hook script in a repository, only if the hook exists
|
{- Path to a given hook script in a repository, only if the hook exists
|
||||||
- and is executable. -}
|
- and is executable. -}
|
||||||
|
|
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -6,6 +6,9 @@ git-annex (6.20151117) UNRELEASED; urgency=medium
|
||||||
versions of git-annex from working in that repository.
|
versions of git-annex from working in that repository.
|
||||||
* smudge: New command, used for git smudge filter.
|
* smudge: New command, used for git smudge filter.
|
||||||
This will replace direct mode.
|
This will replace direct mode.
|
||||||
|
* init: Configure .git/info/attributes to use git-annex as a smudge
|
||||||
|
filter. Note that this changes the default behavior of git add in a
|
||||||
|
newly initialized repository; it will add files to the annex.
|
||||||
* Build with -j1 again to get reproducible build.
|
* Build with -j1 again to get reproducible build.
|
||||||
* Display progress meter in -J mode when copying from a local git repo,
|
* Display progress meter in -J mode when copying from a local git repo,
|
||||||
to a local git repo, and from a remote git repo.
|
to a local git repo, and from a remote git repo.
|
||||||
|
|
|
@ -12,24 +12,30 @@ This command lets git-annex be used as a git filter driver which lets
|
||||||
annexed files in the git repository to be unlocked at all times, instead
|
annexed files in the git repository to be unlocked at all times, instead
|
||||||
of being symlinks.
|
of being symlinks.
|
||||||
|
|
||||||
The git configuration to use this command as a filter driver is as follows,
|
When adding a file with `git add`, the annex.largefiles config is
|
||||||
but this is normally set up for you by git-annex init, so you should
|
consulted to decide if a given file should be added to git as-is,
|
||||||
not need to configure it manually:
|
or if its content are large enough to need to use git-annex. To force a
|
||||||
|
file that would normally be added to the annex to be added to git as-is,
|
||||||
|
this can be temporarily overridden. For example:
|
||||||
|
|
||||||
|
git -c annex.largefiles='exclude=*' add myfile
|
||||||
|
|
||||||
|
The git configuration to use this command as a filter driver is as follows.
|
||||||
|
This is normally set up for you by git-annex init, so you should
|
||||||
|
not need to configure it manually.
|
||||||
|
|
||||||
[filter "annex"]
|
[filter "annex"]
|
||||||
smudge = git-annex smudge %f
|
smudge = git-annex smudge %f
|
||||||
clean = git-annex smudge --clean %f
|
clean = git-annex smudge --clean %f
|
||||||
|
|
||||||
To make git use this filter on all files except for dotfiles, put something
|
To make git use that filter driver, it needs to be configured in
|
||||||
like the following in the .gitattributes file:
|
the .gitattributes file or in `.git/config/attributes`. The latter
|
||||||
|
is normally configured when a repository is initialized, with the following
|
||||||
|
contents:
|
||||||
|
|
||||||
* filter=annex
|
* filter=annex
|
||||||
.* !filter
|
.* !filter
|
||||||
|
|
||||||
When adding a file with `git add`, the annex.largefiles config is
|
|
||||||
consulted to decide if a given file should be added to git as-is,
|
|
||||||
or if its content are large enough to need to use git-annex.
|
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
||||||
[[git-annex]](1)
|
[[git-annex]](1)
|
||||||
|
|
|
@ -306,7 +306,9 @@ just look at the repo content in the first place..
|
||||||
|
|
||||||
annex.version changes to 6
|
annex.version changes to 6
|
||||||
|
|
||||||
On upgrade, update $GIT_DIR/info/attributes with a stock configuration,
|
git config for filter.annex.smudge and filter.annex.clean is set up.
|
||||||
|
|
||||||
|
.gitattributes is updated with a stock configuration,
|
||||||
unless it already mentions "filter=annex".
|
unless it already mentions "filter=annex".
|
||||||
|
|
||||||
Upgrading a direct mode repo needs to switch it out of bare mode, and
|
Upgrading a direct mode repo needs to switch it out of bare mode, and
|
||||||
|
|
|
@ -48,21 +48,32 @@ The upgrade events, so far:
|
||||||
The upgrade from v5 to v6 is handled manually. Run `git-annex upgrade`
|
The upgrade from v5 to v6 is handled manually. Run `git-annex upgrade`
|
||||||
perform the upgrade.
|
perform the upgrade.
|
||||||
|
|
||||||
|
This upgrade does away with the direct mode/indirect mode distinction.
|
||||||
|
A v6 git-annex repository can have some files locked and other files
|
||||||
|
unlocked, and all git and git-annex commands can be used on both locked and
|
||||||
|
unlocked files. (Although for locked files to work, the filesystem
|
||||||
|
must support symbolic links..)
|
||||||
|
|
||||||
|
The behavior of some commands changes in an upgraded repository:
|
||||||
|
|
||||||
|
* `git add` will add files to the annex, in unlocked mode, rather than
|
||||||
|
adding them directly to the git repository. To bypass that and add a file
|
||||||
|
directly to git, use:
|
||||||
|
|
||||||
|
git -c annex.largefiles='exclude=*' add myfile
|
||||||
|
|
||||||
|
* `git annex unlock` and `git annex lock` change how the pointer to
|
||||||
|
the annexed content is stored in git.
|
||||||
|
|
||||||
All places that a direct mode repository is cloned to should be
|
All places that a direct mode repository is cloned to should be
|
||||||
running git-annex version 6.x before you upgrade the repository.
|
running git-annex version 6.x before you upgrade the repository.
|
||||||
This is necessary because the contents of the repository are changed
|
This is necessary because the contents of the repository are changed
|
||||||
in the upgrade, and the old version of git-annex won't be able to
|
in the upgrade, and the old version of git-annex won't be able to
|
||||||
access files after the repo is upgraded.
|
access files after the repo is upgraded.
|
||||||
|
|
||||||
If a repository is only used in indirect mode, this upgrade will not
|
If a repository is only used in indirect mode, you can use git-annex
|
||||||
affect it significantly. You can use git-annex v5 and v6 in different
|
v5 and v6 in different clones of the same indirect mode repository without
|
||||||
clones of the same indirect mode repository without problems.
|
problems.
|
||||||
|
|
||||||
This upgrade does away with the direct mode/indirect mode distinction.
|
|
||||||
A v6 git-annex repository can have some files locked and other files
|
|
||||||
unlocked, and all git and git-annex commands can be used on both locked and
|
|
||||||
unlocked files. (Although for locked files to work, the filesystem
|
|
||||||
must support symbolic links..)
|
|
||||||
|
|
||||||
On upgrade, all files in a direct mode repository will be converted to
|
On upgrade, all files in a direct mode repository will be converted to
|
||||||
unlocked files. The upgrade will need to stage changes to all files in
|
unlocked files. The upgrade will need to stage changes to all files in
|
||||||
|
|
Loading…
Reference in a new issue