2

I typically use VIM for almost everything coding-related.

I have configured my environment so Subversion opens VIM to edit the commit message when I execute svn commit. If I close VIM without saving the commit message (eg: :qa!), it is discarded, and the commit operation is aborted.

If I save and close VIM, then the commit operation will commence.

If the commit fails, I have some SVN commit messages that appear to be saved in /tmp/ with file names like svn-**.tmp.

While writing the commit message in VIM, the commit message appears to have a file name of svn-commit.1.tmp. I would like to be able to recover this message for my next SVN commit. The typically use case is:

  1. I attempt to commit; complete writing message in VIM
  2. Commit fails
  3. I resolve the issue (eg: svn update)
  4. Now I want to attempt svn commit again with the previous message pre-loaded into VIM

Thank you for your help.

Cloud
  • 18,753
  • 15
  • 79
  • 153

4 Answers4

2

You could always use the -F option with svn commit, which uses a file to create the log message.

Whenever I commit with svn, I first create a log file:

vim log_file

Then I use the following to commit:

svn commit -F log_file --username blah

This has always worked great for me.

jahroy
  • 22,322
  • 9
  • 59
  • 108
1

You could try something like this: svn commit -F /tmp/svn-1.tmp You can read more there: http://svnbook.red-bean.com/en/1.0/re06.html

1

When in your vim session, just read the contents of the old log file. This permits you to adapt the old message if necessary, and doesn't change the workflow radically.

svn commit 

(opens vim session)

:r /tmp/svn-**.tmp

Another solution is to just do your commits from the command line with the -m flag. This typically has the last (failed) commit in the command history of the related shell.

svn commit -m "Here is my message"

(commit fails, and you resolve it)

(up arrow a few times, and rerun the commit)

Edwin Buck
  • 69,361
  • 7
  • 100
  • 138
0

Git will store a cached version of your commit message in .git/COMMIT_EDITMSG.

After a "failed" committing attempt, you could run the following to recover your commit message.

vim .git/COMMIT_EDITMSG
Michael Altfield
  • 2,083
  • 23
  • 39