开发者

Using git personally and SCCS project-wide

I'm working at a company that uses SCCS internally for developing it's main application. We currently have two development streams, called Stable and Experimental. Stable has changes currently being made to it that are mostly bug fixes, and may fix problems in Experimental as well. Experimental is adding a fairly large new feature.

The main problem I'm having is that developers working on Stable don't also put their changes in Experimental. As I'm working on Experimental, I have to merge both branches.

I've been using Git by myself for about a year, and it's worked great with one branch (Stable), as I can just:

git checkout master
<copy all Stable files over, which will add changes>
git commit -a -m "Updated files 06/19/2011"
git checkout New_Feature
git rebase master

This updates all my files with the changes from Stable. However, now that they are using two development branches, I'm getting a lot of merge conflicts. T开发者_运维技巧his stems from SCCS putting metadata at the top of source files, like this:

#pragma ident "@(#)file1.c   1.233 06/17/11 Company_Experimental"

Note the version number (1.233), date, and company/branch keywords. The date and version number change with every check-in, and the branch changes between updates in Stable and Experimental. I don't care what's at the top, as when I check in the files, it will discard the top and have new values depending on when and where I check it in.

With all that said, this line will always be at the top. Is there any way to ignore the top line, or somehow make this workflow a little more manageable such that I can merge development streams with my own work and not go through a lot of meaningless merge conflicts?

Note: I've already campaigned to change version control systems, but we have a lot of older programmers who are not about to change their ways. Please don't respond, "Your company should switch to X". Trust me, I'm with you 100%.


If you can simply delete the contents of the pragma ident lines in your git repo (which you probably can do, since SCCS will add them in for you), you can simply add:

* filter=skip-ident

to either .git/info/attributes (or $GIT_DIR/info/attributes) or .gitattributes (if you want to track the attributes file itself with git) and put something like:

[filter "skip-ident"]
        clean = "sed '/\(#pragma ident\).*/s//\1/'"

in .git/config. Whenever any file (files matching the pattern in the first column of .git/info/attributes, in this case '*') is added to git, the contents will be run through the clean script, which in this case just removes all the ident info.


You can use a custom smudge clean script. More can be found in the attributes chapter in the ProGit book. Also you could write a merge driver.

What does the first line of every file have to say once you are done your merge? I'm assuming nothing and you rely on SCCS to do it for you. This should make the smudge clean script easy.


The line

#pragma ident "@(#)file1.c   1.233 06/17/11 Company_Experimental"

is stored in SCCS with keywords like:

#pragma ident "%A%%M%   %I% %D% Company_Experimental"

(Forgive if I get some tokens wrong, I stopped using the old workhorse over a year ago).

When you do a commit using git, replace the fixed #pragma line with the tokens that sccs expects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜