[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] OT: Question concerning vc-working-revision in git versus

From: David Maus
Subject: Re: [Orgmode] OT: Question concerning vc-working-revision in git versus svn
Date: Sun, 28 Nov 2010 21:38:19 +0100
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Goj┼Ź) APEL/10.8 Emacs/23.2 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

At Thu, 25 Nov 2010 14:38:29 +0100,
Rainer M Krug wrote:
> Hash: SHA1
> Hi
> I migrated from svn to git, but I have one problem: in some documents, I
> used
> src_emacs-lisp[:exports results]{(vc-working-revision (or
> (buffer-file-name) org-current-export-file))}
> to insert the revision of the document. In svn, this resulted in a
> number, through which I could identify the revision and retrieve it from
> svn when needed in the future.
> Under git, it simply tells me "master" - is there anything I can do to
> get something similar then the revision number in svn, which I can use
> to retrieve the version from git?

The problem is, that Git does not track revision of single files, but
only the entire work dir.  So from Git's point of view there is no
such thing like a revision number of a particular file.

You might use this function

(defun my/git-last-commit-id ()
  "Return last commit in current workdir."
  (let ((commit (shell-command-to-string "git log -1 --pretty=oneline")))
    (when (stringp commit)
       (substring commit 0 40)))))

To insert the ID of the last commit in the src_emacs_lisp[:exports
results] line.

Depending of the exact use of Git (e.g. explicitly committing changes
vs. auto-commits via cron) using rcs (which supports file revision
numbers) on top of Git.

I do this for some files and have this in my .emacs.d/init.el:

(setq vc-handled-backends
       (list 'RCS 'Git)
       (delq 'Git (delq 'RCS vc-handled-backends))))

What makes vc prefer RCS over Git, and Git over all other VCSs.  So
C-x v v by default uses RCS.

  -- David
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... address@hidden
Email..... address@hidden

Attachment: pgpViexHiSxIC.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]