3

I am writing some Elisp for a package. I was using vc-working-revision to identify the current revision. But it only returns the branch name, not the hash that name points to. Therefore, this information goes out of date quickly (master now is not master 20min from now).

(I was surprised. Branch names have little to do with revisions.)

I would like to (cross vc-system) get a unique identifier for the current head that is not time-sensitive with vc. How can I do this?

1

In case of Git you can call vc-git--rev-parse on return value of vc-working-revision. If you pass whatever what may or may not be SHA1, including branch names and "HEAD". It will also return valid SHA1's intact.

Unfortunately there isn't a guaranteed general solution that you're looking for. Interface we used is specific to Git and general API doesn't provide alternatives. This is knowledge that has to be introduced on per backend basis.

| improve this answer | |
  • I feared this, but (defadvice vc-git-working-revision (around use-hashes-only (file) activate) (setq ad-return-value (vc-git--rev-parse "HEAD"))) doesn't seem to work. I get different stale values from vc-working-revision (which differs from the results from vc-git-working-revision) – PythonNut Apr 5 '15 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.