benthayer / git-gud

Wanna git gud? Then get git-gud, and git gud at git!
MIT License
401 stars 42 forks source link

Add Working Directory and Staging Area support to YAML files #284

Open benthayer opened 3 years ago

benthayer commented 3 years ago

Currently, YAML files can change the contents of commits, but we don't use them to change the contents of the WD or SA. We need a syntax for this and an implementation of this.

benthayer commented 3 years ago

One implementation:

'Working Directory':
  base: 'HEAD'
'Staging Area':
  base: 'Working Directory'

This one would set the contents of the working directory to be the same as commit 1

'Working Directory':
  base: '1'
  add-files:
# same as other directives
'Staging Area':
  files:

Base can be HEAD or any of the top level commit-ishs in the YAML

Staging Area defaults to Working Directory and Working Directory defaults to HEAD.

If base is specified, then we can use add-files and remove-files just like we can in commits, otherwise files should be specified.

With this, it might follow that merges and other commits can havie this same framework applied. For merges, you could base the commit off of either parent, and add-files/remove-files would could be used to set the files for the commit

benthayer commented 3 years ago

To start, implementing files for Working Directory and Staging Area would be the easiest.