Skip to content

[Feature request] Option to perform diff without tempfiles #123

Open
@davidbodow-st

Description

@davidbodow-st

Overview

When calling a diff of two large strings, a system that is low on disk space can fail with ENOSPC when attempting to write the strings to tempfiles.

Use Case

I would like to diff strings in memory, especially if the system has trimmed down the free disk substantially. For example, we use a large Sidekiq deployment, and having overprovisioned disk for 1000s of workers (only a few of which need to run disks) ends up costing a non-trivial amount. We could create a "high disk queue", but that seems more complex than adding a generally useful diffing option here.

Implementation Ideas

Bash process substitution can be used to avoid writing the tempfiles when calling diffbin:

❯ diff <(echo foo) <(echo bar)
1c1
< foo
---
> bar

We could handle passing the process substitution args instead of the usual args by implementing a new source in #diff: https://github.com/samg/diffy/blob/main/lib/diffy/diff.rb#L43

Other

I'd be happy to open a PR for this if there is interest in the feature, but no bandwidth otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions