views:

68

answers:

3

Background: the current text editor i am using does not have built-in support for git. Nevertheless, it has support for user-created addons, so I made one for auto-commiting to the repository each time I save a file.

Although auto-saving to the repository is straightforward, the commit messages currently are not very useful, they just slap the current date and time with the text "auto saved" as the commit message.

In looking at this situation I thought it might be helpful to find out how text editors handle the issue of letting the user specify a different commit message each time they save a file (if wanted).

Question: How do text editors unobtrusively allow the user to specify a non-automated commit message? Does the user get presented with a pop-up dialog box? Does the editor provide a scratch buffer that does nothing but act as a temporary storage for the commit message? Is there a way this can be done without feeling like a "nag screen" after a while?

+1  A: 

That entirely depends on your editor obviously.

Visual Studio/TFS may not be the best environment for source control, but this one aspect is handled pretty well IMHO. They have a 'pending changes' window where you can write your commit message during your developments, and it remembers it over different sessions.

One strategy that might work in your situation is simply to keep a fixed 'commitmessage.txt' file somewhere, which your auto-commit command could use (and maybe clear after the commit).

jeroenh
+1  A: 

I think you can get the vast majority of what you are looking for without being too clever. How about two paths for the add-on, one auto-save as you currently have described with a generic auto save commit message.

A second "intentional" commit/save where you as the user are requesting the commit message screen for the commit entry. This would be an additional macro/hot-key/button from your add-on that you use for explicitly typing in the commit message where the "auto save" functionality is just that, auto save.

Keep track and only auto-save when changes between intentional saves and auto saves have occurred. Straightforward and gives you auto saves without nag screens with the flexibility to add explicit commit messages.

Best of luck.

another average joe
+1  A: 

Do you really need a different message each time you save a file?

Most of the save actions are reflex CTRL+S intermediate recording of the editing process.
If a certain task (bug fix, feature development, ...) is in progress, those intermediate saves are not meant to bring a lot of new information. If systematically committed, those commits should, from Git1.7 forward, only use the new fixup! action as a comment.

That way, once a given task has been completed, you could automatically squash all those commits keeping only the comment of the first one, and ignoring the comments of all the following commits for that file.

git rebase --interactive --autosquash

See Trimming GIT Checkins SO question.

VonC
thanks for the crossref, I should add that rebase is frowned upon in some camps
dreftymac