Skip to content

Diffs stored in simulation output are useless if base commit doesn't exist #188

Description

@mcmehrtens

Increasing robustness of the metadata file

The metadata file stores the git hash that HEAD was pointing to when Alamo was compiled. When a simulation is run, a patch file generated from git diff is written if the working tree is "dirty" and has changes not tracked by the recorded commit. This, ostensibly, allows a user to go back and time and exactly recreate a simulation.

Often times, these simulations are run off a feature or investigation branch, not development or master. In these cases, it is possible a developer may rebase their branch before merging into development potentially "erasing" the commit hash that the metadata file points to and the corresponding diff.patch was based off.

Recommended solution

I recommend adding diff logic to do something like this:

git diff --patch --output development.patch --minimal --patch-with-stat --full-index --binary --find-copies-harder --merge-base origin/development

Additionally, the metadata file should store the common ancestor of HEAD with origin/development. This can be determined with: git merge-base origin/development HEAD.

In effect, this would write an additional .patch file that is based off the common ancestor of whatever branch HEAD points to and the development branch. Since development is unlikely to be rebased, this virtually eliminates the risk of losing record of git hashes.

To recreate the working tree as it was when the simulation was ran, one would check out the common ancestor commit (given by git merge-base origin/development HEAD) and then apply the patch.

Additional recommendations

I recommend adding the flags --patch --minimal --patch-with-stat --full-index --binary --find-copies-harder to the existing diff command that generates diff.patch. These flags

  • --minimal: optimize the diff
  • --patch-with-stat: write some human-readable output to the top of the diff
  • --full-index: record full index hashes
  • --binary: track any binary files (e.g., PNG files)
  • --find-copies-harder: optimize the diff

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions