git-auto-commit-mode icon indicating copy to clipboard operation
git-auto-commit-mode copied to clipboard

feature: select what will be committed

Open hrehfeld opened this issue 3 years ago • 3 comments

I see the following options here:

  • commit only single file (setq git-auto-commit-mode-context 'file)
  • commit all (staged and/or unstaged) commits in subtree (subdirectory) (setq git-auto-commit-mode-context 'subtree)
  • commit all (staged and/or unstaged) commits in repo (setq git-auto-commit-mode-context 'repository)
  • commit all (staged and/or unstaged) changes to file and its "companion files", e.g. gtd.org would add (setq git-auto-commit-mode-context '("gtd.archive.org" "inbox.org")

And then also (setq git-auto-commit-mode-staged-only t)

hrehfeld avatar May 29 '21 19:05 hrehfeld

Hey! Thanks for these suggestions! Does this mean the current situation isn't to your liking? If git-auto-commit-mode is enabled for all files in a repository every time you make a change you would get a new commit, so I'm not sure which files would be left to commit with it.

Can you elaborate on your situation perhaps?

ryuslash avatar Jul 01 '21 20:07 ryuslash

So, I took some notes in the last weeks. I notice the following use-cases/problems relating to single file commits:

  • I have two org-mode files. I move a headline from a.org to b.org, and save all org-mode buffers. Now I have two commits, one which removes the headline in a.org and one that adds it to b.org, which feels a lot like inconsistent history/information lost. On code this would be a broken commit.
  • I add a headline in a.org, which creates an entry in .org-id-locations. I save a.org, but only a.org is committed, not .org-id-locations.
  • I add a picture to the directory and link to it in a.org. I save the file, a.org is commited, but I have to manually add the picture file and commit, leaving me with a half-broken commit.

So, there are two problems:

  • how do we handle other files (indexed/not indexed) in the same working copy?
  • we don't actually want to commit on save, give the operation a chance to finish and/or wait for a slight idle time. (optional, ofc)

hrehfeld avatar Jul 14 '21 12:07 hrehfeld

Thank you, that helps a lot! Those are excellent points. For the first problem you mention I don't think there is currently anything that can help this, I'll have a look at implementing this when I have some time.

For the second problem you mention, I think this is what gac-debounce-interval should help with. You should be able to set this to the number of seconds that you want to wait before committing. But I think this only works for individual files at the moment.

ryuslash avatar Jul 21 '21 04:07 ryuslash