Subject: Re: How to sync changes in GIT to ClearCase or How to get the list of files changed in GIT for a specific branch

From: David Aguilar <[email-masked]>
Date: Thu, 23 Apr 2009 21:31:15 -0700

On  0, ask4thunder <[email-masked]> wrote:
> 
> I am intending to use ClearCase in the background and GIT in the front.
> For syncing files from ClearCase to GIT i 
> checkout the git branch
> use rsync command to get the changed files in ClearCase
> and then i do the 'git add' and 'git commit'

To handle files that have been removed make sure to use
	rsync --exclude=.git --delete ...

and
	git add -u

to remove any deleted files from git.

> This works out well, but i want to get a list of files changed in GIt so
> that i can bring that to ClearCase and checkout and checkin files.
> 
> Can someone provide me the commands to
> 
> 1. Get list of files changed in GIT, after i do commit?

One possibility:

move to the root of the clearcase project

set GIT_DIR to point to the .git directory
(which, presumably is outside the clearcase project)

and some combination of:
	git diff --name-only
	git diff-index --name-status HEAD

If clearcase wasn't so painful you would ideally just
run 'git checkout -f' to make clearcase match git,
but clearcase is horrible and you have to explicitly
'clearcase checkout' each file.

> 2. Get list of files changed in GIT after commit, but files changed after a
> tag (baseline).

	git diff --name-only <the-commit>^!

	git diff --name-only <the-tag>..HEAD

(or diff-index, etc)

> 3. Sync these files to ClearCase?

	clearcase checkout the <path>
	git checkout HEAD -- <path>

	(assuming you've set GIT_DIR accordingly
	 and are sitting at the root of the project)

> Hope you gurus can help me....am in desperate need of these commands. 
> Appreciate your help  in this.

If you get this stuff working with native clearcase commands,
then others could benefit from your work.

bi-directional git<->cc can be tricky (and importing all of
branches can be even trickier), but even being able to import
one branch is better than nothing, no?

The reason I replied is that I, too, once wrote a similar
tool to suck cc projects into git.  One project
was so huge (and cc sucks so bad) that it
literally took a few weeks for it to import.

Our organization also ran vob backups at 2am everynight,
so I couldn't just let it run continuously since clearcase
would lock the script out at 2am.

It ran incrementally, and lots of other site-specific
hacks.  I don't know clearcase at all (our site used a bunch
of in-house wrapper commands) so I never bothered to make
it work with raw cc commands. That's why I have nothing
to share.  It was also a total hack and once I got the stuff
I wanted out of it, you can bet that I never looked back
(which is why the bi-directional part was not important
 to me at all).

clearcase.. wow <shudders>

All it does is remind me of this horrible, horrible cc mvfs
kernel module bug that was going around deleting automounts...

okay.. enough scary thoughts.

kudos for fighting the good fight,

-- 

	David