1

I'm trying to migrate from svn to git using git-svn package. All is fine, except one thing. After I launch git svn clone command, repository converts successfully, but all comments like this:

 * @version     $Id: source.java date time author name $

Are immediately converted to comments like this:

* @version     $Id$

Is there a way to avoid this? Here is the full command that I use:

git svn clone http://svn.server/svn/repository/folder_in_root --preserve-empty-dirs -A committers.txt --trunk=. new_folder

Any Help would be appreciated.

Peresvet
  • 19
  • 1
  • 1
    https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion – phd Dec 03 '19 at 14:19
  • 1
    https://git.wiki.kernel.org/index.php/GitFaq#Does_Git_have_keyword_expansion.3F – phd Dec 03 '19 at 14:22
  • https://stackoverflow.com/questions/62264/dealing-with-svn-keyword-expansion-with-git-svn – max630 Dec 04 '19 at 07:40

2 Answers2

0

Short answer

No, Git doesn't have keyword-substitution (contrary to SVN), and because it's pure client-side thing in SVN, you can do nothing on server

Longer answer

You can emulate this (somehow) with smudge|clean filters in Git, but:

  1. You'll have to rewrite all (?) keywords for Git
  2. Old keywords in old commits, thus, will not be expanded on checkout anyway
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • Did not understood answer till the end. No, this means I cannot stop git to rewrite comments in source files? This happens before I'm committing anything to new git repository. I don't need git to use comments in source code. I, just, need to stop git changing Java source code files. – Peresvet Dec 03 '19 at 14:07
0

git is not changing $Id: source.java date time author name $ into $Id$. In fact it's the very opposite: it's failing to change $Id$ into $Id: source.java date time author name $ because git doesn't support keyword expansion out of the box. In Subversion, the feature works by storing the raw unexpanded keyword in the repository ($Id$) and expanding it when you check out a working copy.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360