Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions commands/command_dedup.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func dedupTestCommand(*cobra.Command, []string) {
Exit("This system does not support deduplication. %s", err)
}

if len(cfg.Extensions()) > 0 {
Exit("This platform supports file de-duplication, however, Git LFS extensions are configured and therefore de-duplication can not be used.")
}

Print("OK: This platform and repository support file de-duplication.")
}

Expand All @@ -49,6 +53,10 @@ func dedupCommand(cmd *cobra.Command, args []string) {
Exit("This system does not support deduplication.")
}

if len(cfg.Extensions()) > 0 {
Exit("This platform supports file de-duplication, however, Git LFS extensions are configured and therefore de-duplication can not be used.")
}

if dirty, err := git.IsWorkingCopyDirty(); err != nil {
ExitWithError(err)
} else if dirty {
Expand Down
5 changes: 5 additions & 0 deletions docs/man/git-lfs-dedup.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ using the operating system's copy-on-write file creation functionality.

If the operating system or file system don't support copy-on-write file creation, this command exits unsuccessfully.

This command will also exit without success if any Git LFS extensions are
configured, as these will typically be used to alter the file contents
before they are written to the Git LFS storage directory, and therefore the
working tree files should not be copy-on-write clones of the LFS object files.

## SEE ALSO

Part of the git-lfs(1) suite.
Expand Down
32 changes: 28 additions & 4 deletions t/t-dedup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ begin_test "dedup"
git init $reponame
cd $reponame

# Confirm Git LFS extensions prevent de-duplication
git config lfs.extension.foo.clean "foo-clean %f"
git config lfs.extension.foo.smudge "foo-smudge %f"
git config lfs.extension.foo.priority 0

result=$(git lfs dedup 2>&1) && true
if ( echo $result | grep "This system does not support deduplication." ); then
exit
fi
echo "$result" | grep 'This platform supports file de-duplication, however, Git LFS extensions are configured and therefore de-duplication can not be used.'

git config --unset lfs.extension.foo.clean
git config --unset lfs.extension.foo.smudge
git config --unset lfs.extension.foo.priority

# Create a commit with some files tracked by git-lfs
git lfs track *.dat
echo "test data" > a.dat
Expand All @@ -25,9 +40,6 @@ begin_test "dedup"

# DO
result=$(git lfs dedup 2>&1) && true
if ( echo $result | grep "This system does not support deduplication." ); then
exit
fi

# VERIFY: Expected
# Success: a.dat
Expand All @@ -46,11 +58,23 @@ begin_test "dedup test"
git init $reponame
cd $reponame

# DO
# Confirm Git LFS extensions prevent de-duplication
git config lfs.extension.foo.clean "foo-clean %f"
git config lfs.extension.foo.smudge "foo-smudge %f"
git config lfs.extension.foo.priority 0

result=$(git lfs dedup --test 2>&1) && true
if ( echo $result | grep "This system does not support deduplication." ); then
exit
fi
echo "$result" | grep 'This platform supports file de-duplication, however, Git LFS extensions are configured and therefore de-duplication can not be used.'

git config --unset lfs.extension.foo.clean
git config --unset lfs.extension.foo.smudge
git config --unset lfs.extension.foo.priority

# DO
result=$(git lfs dedup --test 2>&1) && true

# Verify: This platform and repository support file de-duplication.
echo "$result" | grep 'This platform and repository support file de-duplication.'
Expand Down