Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 40001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:57:16+00:00 2026-05-10T14:57:16+00:00

I recently asked about keyword expansion in Git and I’m willing to accept the

  • 0

I recently asked about keyword expansion in Git and I’m willing to accept the design not to really support this idea in Git.

For better or worse, the project I’m working on at the moment requires SVN keyword expansion like this:

svn propset svn:keywords 'Id' expl3.dtx 

to keep this string up-to-date:

$Id: expl3.dtx 803 2008-09-11 14:01:58Z will $ 

But I would quite like to use Git to do my version control. Unfortunately, git-svn doesn’t support this, according to the docs:

‘We ignore all SVN properties except svn:executable’

But it doesn’t seem too tricky to have this keyword stuff emulated by a couple of pre/post commit hooks. Am I the first person to want this? Does anyone have some code to do this?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:57:17+00:00Added an answer on May 10, 2026 at 2:57 pm

    What’s going on here: Git is optimized to switch between branches as quickly as possible. In particular, git checkout is designed to not touch any files that are identical in both branches.

    Unfortunately, RCS keyword substitution breaks this. For example, using $Date$ would require git checkout to touch every file in the tree when switching branches. For a repository the size of the Linux kernel, this would bring everything to a screeching halt.

    In general, your best bet is to tag at least one version:

    $ git tag v0.5.whatever 

    …and then call the following command from your Makefile:

    $ git describe --tags v0.5.15.1-6-g61cde1d 

    Here, git is telling me that I’m working on an anonymous version 6 commits past v0.5.15.1, with an SHA1 hash beginning with g61cde1d. If you stick the output of this command into a *.h file somewhere, you’re in business, and will have no problem linking the released software back to the source code. This is the preferred way of doing things.

    If you can’t possibly avoid using RCS keywords, you may want to start with this explanation by Lars Hjemli. Basically, $Id$ is pretty easy, and you if you’re using git archive, you can also use $Format$.

    But, if you absolutely cannot avoid RCS keywords, the following should get you started:

    git config filter.rcs-keyword.clean 'perl -pe 's/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/'' git config filter.rcs-keyword.smudge 'perl -pe 's/\\\$Date[^\\\$]*\\\$/\\\$Date: `date`\\\$/''  echo '$Date$' > test.html echo 'test.html filter=rcs-keyword' >> .gitattributes git add test.html .gitattributes git commit -m 'Experimental RCS keyword support for git'  rm test.html git checkout test.html cat test.html 

    On my system, I get:

    $Date: Tue Sep 16 10:15:02 EDT 2008$ 

    If you have trouble getting the shell escapes in the smudge and clean commands to work, just write your own Perl scripts for expanding and removing RCS keywords, respectively, and use those scripts as your filter.

    Note that you really don’t want to do this for more files than absolutely necessary, or git will lose most of its speed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently asked about functional programs having no side effects, and learned what this
Note: I originally asked this question about an hour ago but only recently realized
I had an interview recently and he asked me about Singleton Design Patterns about
I recently asked this question about how to simulate type classes in D and
I recently asked just about the same question, but this one got a little
I recently asked a question about LAMP stack not allowing posting of <script> tag
This is related to another question I recently asked about storing a non-bare repository
I recently asked a question about formatting JavaScript code in Vim. And I've also
I've recently asked a question about clipping an image via path at view's drawRect
I was recently asked if I knew anything about Dynamic Assemblies in .Net. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.