Skip to content

Add new command git lfs dedup for file system level de-duplication. - #3753

Merged
bk2204 merged 1 commit into
git-lfs:masterfrom
kazuki-ma:dedup
Aug 19, 2019
Merged

bk2204 merged 1 commit into
git-lfs:masterfrom
kazuki-ma:dedup

Conversation

@kazuki-ma

@kazuki-ma kazuki-ma commented Aug 2, 2019 •

Copy link
Copy Markdown
Contributor

Implements and closes #3740.
This PR depends #3745 (merged).

Formatted doc is here https://github.com/kazuki-ma/git-lfs/blob/dedup/docs/man/git-lfs-dedup.1.ronn

Request of information

  • I'm using lfs.NewGitScanner with ScanTree("HEAD"). Is it right?
    • Fixed.
  • canDedup condition.
    • Fixed. Using ! git.IsWorkingCopyDirty()
  • minor) after finished de-dup command, git checking all de-duped files due to file stat is changed.
    Can I skip it?

@kazuki-ma
kazuki-ma force-pushed the dedup branch 5 times, most recently from 0393dd3 to dff4c81 Compare August 2, 2019 01:11

@bk2204 bk2204 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think this is a great start. I've left some comments about directions I think we could go.

I'd also like to see some tests for this functionality in our integration test suite (say, a file called t-dedup.sh) that demonstrate success on macOS as well as an error case when we have modified files. If you implement the --test option, we should verify additionally that it succeeds on macOS and fails on Windows (and do something sane or skip it on Linux).

Comment thread commands/command_dedup.go Resolved
Comment thread commands/command_dedup.go Resolved
Comment thread commands/command_dedup.go Resolved
Comment thread commands/command_dedup.go Resolved
Comment thread commands/command_dedup.go Resolved
Comment thread commands/command_dedup.go Resolved
Comment thread docs/man/git-lfs-dedup.1.ronn Resolved
Comment thread docs/man/git-lfs-dedup.1.ronn Resolved
Comment thread tools/util_linux.go Resolved
Comment thread commands/command_dedup.go

func init() {
RegisterCommand("dedup", dedupCommand, func(cmd *cobra.Command) {
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most file systems on Linux are not going to support copy-on-write in the way we want them to for this feature. It would be nice if we had a --test option that would test using the LFS temporary directory and simply exit successfully or unsuccessfully depending on whether this feature could actually be supported on the system.

That would prevent the current status quo where someone tries to use this function on Linux, and then it errors out on the first file. It would also let users distinguish between the case that the feature is not really supported on their system and the case that the feature is functional but failed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

git lfs dedup --test added.

image

@kazuki-ma kazuki-ma changed the title Add new command git lfs dedup for file system level de-duplication. WIP: Add new command git lfs dedup for file system level de-duplication. Aug 4, 2019
@kazuki-ma

Copy link
Copy Markdown
Contributor Author

@bk2204 Sorry for late reply, I'm start update this PR.

Thank you for your detailed feedback. Please wait until update finished.

kazuki-ma added a commit to kazuki-ma/git-lfs that referenced this pull request Aug 18, 2019
@kazuki-ma
kazuki-ma force-pushed the dedup branch 5 times, most recently from aac820c to 06f3023 Compare August 18, 2019 12:00
kazuki-ma added a commit to kazuki-ma/git-lfs that referenced this pull request Aug 18, 2019
@kazuki-ma
kazuki-ma force-pushed the dedup branch 14 times, most recently from d33084d to 3528654 Compare August 18, 2019 16:07
@kazuki-ma
kazuki-ma force-pushed the dedup branch 6 times, most recently from ca02531 to f0de50e Compare August 19, 2019 01:44
@kazuki-ma kazuki-ma changed the title WIP: Add new command git lfs dedup for file system level de-duplication. Add new command git lfs dedup for file system level de-duplication. Aug 19, 2019
@kazuki-ma

Copy link
Copy Markdown
Contributor Author

@bk2204

Updated. Could you review again?

@bk2204 bk2204 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Thanks for working on it.

Comment thread t/t-dedup.sh

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach. It makes it really easy for this to work on any system that supports it without needing to hard-code a list of systems or file systems.

@bk2204
bk2204 merged commit 2db85b5 into git-lfs:master Aug 19, 2019
@kazuki-ma
kazuki-ma deleted the dedup branch August 27, 2019 17:07
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request May 15, 2025
Since the "git lfs dedup" command was introduced in PR git-lfs#3753 it has
accepted a --test option, which causes the command to check whether the
current operating system and file system support the copy-on-write
functionality the command uses to create clones or reflinks of Git LFS
files.

However, this option is not documented in our git-lfs-dedup(1) manual
page, so we now add an entry for it into the list of options supported
by the command.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Nov 27, 2025
Since the "git lfs dedup" command was introduced in PR git-lfs#3753 it has
accepted a --test option, which causes the command to check whether the
current operating system and file system support the copy-on-write
functionality the command uses to create clones or reflinks of Git LFS
files.

However, this option is not documented in our git-lfs-dedup(1) manual
page, so we now add an entry for it into the list of options supported
by the command.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Nov 27, 2025
Since the "git lfs dedup" command was introduced in PR git-lfs#3753 it has
accepted a --test option, which causes the command to check whether the
current operating system and file system support the copy-on-write
functionality the command uses to create clones or reflinks of Git LFS
files.

However, this option is not documented in our git-lfs-dedup(1) manual
page, so we now add an entry for it into the list of options supported
by the command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use clonefile system call on Mac OS X for faster & efficient object file copy

2 participants