Description
This feels like it's probably a regression, but I'm not sure. Problematic behavior I observe:
-
Open some version-controlled file in emacs. I'm using git; probably this doesn't matter
-
(vc-working-revision buffer-file-name) should return either HEAD or maybe the most recent revision of that one file. Either is fine
-
make a change to that file, commit it with commit-patch.
-
(vc-working-revision buffer-file-name) SHOULD now return the new revision but it doesn't for me. This being out-of-date makes vc-annotate and vc-log and others lie to you.
It looks like commit-patch tries to deal with this, but it's broken currently. I'm not patching it because I'd like to know what the intent was, and what you THINK it's doing.
Currently commit-patch-buffer-in-directory looks at the patch buffer, extracts a list of filenames in the patch, and tries to re-synchronize them with emacs. It does this by invoking "lsdiff" on the patch and parsing the output. Problem is, the patch often contains relative paths, so the patch-files variable ends up with strings like "a/file1.c", where "a" isn't a real directory, so the (find-buffer-visiting) call doesn't find the relevant buffer. The code is there. Did this ever work?
If we found a buffer, we'd do this for each one:
(vc-resynch-buffer (buffer-file-name buf) 'revert 'noquery)
;; stupid vc-revert-buffer1 doesn't call revert-buffer
;; with preserve-modes which means the CVS version doesn't
;; get updated, so we do it by hand.
(run-hooks 'find-file-hooks)))
The comment implies that only CVS is affected, but it's all VCSs I'm guessing. At least in this case (vc-resync-buffer) doesn't fix this, but the (run-hooks) call does. The specific call that we need is (vc-file-clearprops buffer-file-name). Maybe we don't need to run ALL the hooks, but you can decide that.
Maybe vc-resynch-buffer should do the vc-clearprops.