GithubHelp home page GithubHelp logo

git-cc's Introduction

git-cc

Simple bridge between base ClearCase or UCM and Git.

Warning

I wrote this purely for fun and to see if I could stop use ClearCase at work once and for all.

I will probably continue to hack away at it to suite my needs, but I would love to see it get some real-world polish. (Actually what I would love to see more is for ClearCase to die, but don't think that's going to happen any time soon).

Suggestions on anything I've done are more than welcome.

Also, I have made a change recently to support adding binary files which uses git-cat. Unfortunately git-cat doesn't handle end line conversions and so I have made gitcc init set core.autocrlf to false. This is only relevant for Windows users. Don't try changing this after your first commit either as it will only make matters worse. My apologies to anyone that is stung by this.

Installation

The easiest way to install git-cc, is to use the Python package installer pip and install it directly from its GitHub repo. Execute the following command on the command prompt to install the latest version:

C:\> pip install git+git://github.com/charleso/git-cc.git#egg=git_cc

If you installed Python from python.org, pip is included with Python 2 >= 2.7.9 and Python 3 >= 3.4. If you do not have pip, [this section] pip-installation from the Python Packaging User Guide describes how to install it.

In case pip or git cannot reach GitHub, for example when such access is not allowed in the place where you work, you can download the [zip file] zip-file with the latest version from the GitHub repo. Unzip it and use pip to execute the following command in the root of the directory tree:

C:\master> pip install .

Finally, if you cannot use pip, you can also use the old-skool approach to install Python packages:

C:\master> python setup.py install

Workflow

Initialise:

git init
gitcc init d:/view/xyz
gitcc rebase
# Get coffee
# Do some work
git add .
git commit -m "I don't actually drink coffee"
gitcc rebase
gitcc checkin

Initialise (fast):

Rebase can be quite slow initially, and if you just want to get a snapshot of ClearCase, without the history, then this is for you:

gitcc init d:/view/xyz
gitcc update "Initial commit"

Other:

These are two useful flags for rebase which is use quite frequently.

gitcc rebase --stash

Runs stash before the rebase, and pops it back on afterwards.

gitcc rebase --dry-run

Prints out the list of commits and modified files that are pending in ClearCase.

To synchronise just a portion of your git history (instead of from the very first commit to HEAD), mark the start point with the command:

gitcc tag <commit>

To specify an existing ClearCase label while checking in, in order to let your dynamic view show the version of the element(s) just checked in if your confspec is configured accordingly, use the command:

gitcc checkin --cclabel=YOUR_EXISTING_CC_LABEL

Note that the CC label will be moved to the new version of the element, if it is already used.

Configuration

The file .git/gitcc contains configuration options for gitcc. For example, it allows you to limit which branches and folders you import from:

[core]
include = FolderA|FolderB
exclude = FolderA/sub/folder|FolderB/other/file
users_module_path = users.py
ignore_private_files = False
debug = False
type = UCM
[master]
clearcase = D:\views\co4222_flex\rd_poc
branches = main|ji_dev|ji_*_dev|iteration_*_dev
[sup]
clearcase = D:\views\co4222_sup\rd_poc
branches = main|sup

In this case there are two separate git branches, master and sup, which correspond to different folders/branches in ClearCase.

You can add a mapping for each user in your ClearCase history. This is done via a separate Python module that you provide. An example users module looks like this:

users = {
    'charleso': "Charles O'Farrell",\
    'jki': 'Jan Kiszka <[email protected]>',\
}
 
mailSuffix = 'example.com'

You specify the path to the users module as the value of key 'users_module_path' in the gitcc config file. In the example above, the value specified is 'users.py'. If the path is relative, it is taken relative to the location of the config file. So in this example, gitcc will import users.py from directory .git. But you can also use an absolute users module path.

If you do not specify the users module path in the config file, the ClearCase user information will be used.

If you make a snapshot of a ClearCase VOB, you copy all the files that are visible in the view, including view-private files. This might not be what you want, for example if the VOB contains all kinds of build artifacts. To only copy the files that are actually under ClearCase control, set the key 'ignore_private_files' to True.

Notes

Can either work with static or dynamic views. I use dynamic at work because it's much faster not having to update. I've done an update in rebase anyway, just-in-case someone wants to use it that way.

Can also work with UCM, which requires the 'type' config to be set to 'UCM'. This is still a work in progress as I only recently switched to this at work. Note the the history is still retrieved via lshistory and not specifically from any activity information. This is largely for convenience for me so I don't have to rewrite everything. Therefore things like 'recommended' baselines are ignored. I don't know if this will cause any major dramas or not.

Troubleshooting

  1. WindowsError: [Error 2] The system cannot find the file specified

You're most likely running gitcc under Windows Cmd. At moment this isn't supported. Instead use Git Bash, which is a better console anyway. :-)

If you have both msysgit and Cygwin installed then it may also be this problem.

  1. cleartool: Error: Not an object in a vob: ".".

The ClearCase directory you've specified in init isn't correct. Please note that the directory must be inside a VOB, which might be one of the folders inside the view you've specified.

  1. fatal: ambiguous argument 'ClearCase': unknown revision or path not in the working tree.

If this is your first rebase then please ignore this. This is expected.

  1. pathspec 'master_cc' did not match any file(s) known to git

See Issue 8.

Behind the scenes

A smart person would have looked at other git bridge implementations for inspiration, such as git-svn and the like. I, on the other hand, decided to go cowboy and re-invent the wheel. I have no idea how those other scripts do their business and so I hope this isn't a completely stupid way of going about it.

I wanted to have it so that any point in history you could rebase on-top of the current working directory. I've done this by using the ClearCase commit time for git as well. In addition the last rebased commit is tagged and is used to limit the history query for any chances since. This tagged changeset is therefore also used to select which commits need to be checked into ClearCase.

Problems

It is worth nothing that when initially importing the history from ClearCase that files not currently in your view (ie deleted) cannot be reached without a config spec change. This is quite sad and means that the imported history is not a true one and so rolling back to older revisions will be somewhat limited as it is likely everything won't compile. Other ClearCase importers seem restricted by the same problem, but none-the-less it is most frustrating. Grr!

For developers

This section provides information for git-cc developers.

Required packages

To develop git-cc, several Python packages are required that are not part of the standard Python distribution and that you have to install separately. As these packages might conflict with your system Python environment, you are strongly advised to set up a virtualenv virtualenv for your work.

The file 'requirements.txt', which is in the root of the repo, lists the Python packages that are needed for development. To install these packages, use the following command:

git-cc $ pip install -r requirements.txt

Testing

git-cc comes with a small suite of unit tests, which you can find in subdirectory tests/. There are several ways to run the unit tests. For example, you can let Python search for the unit tests and run them in the current Python environment. To do so, execute the following command from the root of the repo:

git-cc $ python -m unittest discover tests/

This will result in output such as this:

........
----------------------------------------------------------------------
Ran 8 tests in 0.002s
 
OK

If you run the unit tests from the root of the repo, all unit tests will be able to import the git-cc package even when it is not installed. If you run the unit tests from another directory, you have to install git_cc first.

Another way to run the unit test is to use the Python tool tox tox. tox does more than just run the unit tests:

  • it creates a source distribution of your Python package for each Python interpreter that you specify,
  • it creates a virtualenv for each Python interpreter you specify, and
  • for each virtualenv, installs the package using the source distribution and runs the unit tests.

If you execute tox from the root of the repo, its output will look like this:

git-cc $ tox
GLOB sdist-make: /home/a-user/repos/github.com/git-cc/setup.py
py27 inst-nodeps: /home/a-user/repos/github.com/git-cc/.tox/dist/git_cc-1.0.0.dev0.zip
py27 installed: git-cc==1.0.0.dev0
py27 runtests: PYTHONHASHSEED='2322284388'
py27 runtests: commands[0] | python -m unittest discover tests/
........
----------------------------------------------------------------------
Ran 8 tests in 0.003s
 
OK
py34 inst-nodeps: /home/a-user/repos/github.com/git-cc/.tox/dist/git_cc-1.0.0.dev0.zip
py34 installed: git-cc==1.0.0.dev0
py34 runtests: PYTHONHASHSEED='2322284388'
py34 runtests: commands[0] | python -m unittest discover tests/
........
----------------------------------------------------------------------
Ran 8 tests in 0.002s
 
OK

As the output shows, tox runs the tests in virtualenvs for Python 2.7 and Python 3.4. This has been specified in file tox.ini, which you can find in the root of the repo:

[tox]
envlist = py27,py34
[testenv]
commands=python -m unittest discover tests/

This only works if you have both interpreters installed. If you want to support other Python versions, you have to update the ini file accordingly.

tox makes it easy to test your Python package in multiple Python environments. Running tox takes more time than just running the unit tests in your current environment. As such, developers run it less often, for example only before a new release or pull request.

Changes and versioning

The repo contains a CHANGES file that lists the changes for each git-cc release and for the version currently under development. This file has a specific format that best can be explained by an example. Assume the CHANGES file looks like this - note that the actual CHANGES file for git-cc looks different:

Changelog
=========

1.2.0 (unreleased)
------------------

- Fixes issue Z

1.1.0 (2016-02-03)
------------------

- Adds support for feature Y
- Updates documentation of feature X

1.0.0 (2016-01-03)
------------------
 
- Started versioning at 1.0.0

The file mentions that versions 1.0.0 and 1.1.0 have been released and that the next version will be 1.2.0.

The process of putting a new release out can be cumbersome and error prone: you have to update the CHANGES file and setup.py, create a tag, update the CHANGES file and setup.py again for the development version, etc. For git-cc, the process of creating a release is fully automated using tools provided by Python package [zest.releaser] zest-releaser.

To show how zest.releaser works, the following is the (sanitized) output of the zest.releaser command 'fullrelease' with the example CHANGES file:

# execute fullrelease on the command-line
git-cc $ fullrelease

# the command outputs the beginning of the CHANGES file 
Changelog entries for version 1.2.0:
 
1.2.0 (unreleased)
------------------
 
- Fixes issue Z
 
1.1.0 (2016-02-03)
------------------
# the command proposes to set the release version to 1.2.0
Enter version [1.2.0]:    
# pressed RETURN to accept the proposed release version
# the command automatically updates the CHANGES file and the version number used by setup.py

OK to commit this (Y/n)?
# pressed RETURN to commit the changes

Tag needed to proceed, you can use the following command:
git tag 1.2.0 -m "Tagging 1.2.0"
Run this command (Y/n)?
# pressed RETURN to tag the release

Check out the tag (for tweaks or pypi/distutils server upload) (Y/n)? n
# answered 'n' and pressed RETURN to not check out the tag

Current version is 1.2.0
# the command proposes to set the development version to 1.2.1dev0
Enter new development version ('.dev0' will be appended) [1.2.1]: 
# pressed RETURN to accept the proposed development version
# the command automatically updates the CHANGES file and the version number used by setup.py

OK to commit this (Y/n)? 
# pressed RETURN to commit the changes

OK to push commits to the server? (Y/n)? n
# answered 'n' and pressed RETURN to not push the latest commit yet

When the command is done, the beginning of the CHANGES file has changed to this:

Changelog
=========
 
1.2.1 (unreleased)
------------------
 
- Nothing changed yet.
 
 
1.2.0 (2016-07-01)
------------------
 
- Fixes issue Z

git-cc's People

Contributors

andreypavlenko avatar awarddev avatar charleso avatar dependabot[bot] avatar devnull42 avatar erikfjon avatar fape avatar hwcy avatar jan-kiszka avatar jslhcl avatar oplier avatar phts avatar strotz avatar swinkels avatar toroc avatar tunacici avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-cc's Issues

Include Activity name in Git Commit Comment

Would there be a way to include both the Activity name and Check-in comment from ClearCase in the commit comment in Git??

Even if this isn't desired for the main project, I would appreciate any help in implementing this in my own fork.

Error while trying to create the master_cc branch

It seems the script tries to do a
git branch -f master_cc

I guess it should be based on HEAD, but HEAD and/or master doesn't seem to exists and it seems to crash. Any pointer would help me ;)

> git ls-files --modified
> git log -n 1 --pretty=format:%ai master_cc
> cleartool ls -recurse -short .
> git branch
> cleartool diff -diff_format -pred /vob/daproject//src@@/main/1
> cleartool lshistory -fmt %o%m|%Nd|%Vn\n /vob/daproject//src/Makefile
> cleartool describe -fmt %Nd /vob/daproject//src@@/main/1
It appears that you may be missing a branch in the includes section of your gitcc config for file '/vob/daproject//src/Makefile'.
> cleartool diff -diff_format -pred /vob/daproject//JUNK/2011_and_before/README@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//src/apps@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//src/arith@@/main/1
> cleartool lshistory -fmt %o%m|%Nd|%Vn\n /vob/daproject//src/arith/Makefile
> cleartool describe -fmt %Nd /vob/daproject//src/arith@@/main/1
It appears that you may be missing a branch in the includes section of your gitcc config for file '/vob/daproject//src/arith/Makefile'.
> cleartool diff -diff_format -pred /vob/daproject//src/backoff@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//JUNK/2011_and_before/bin@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//src/common@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//src/db@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//src/f@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//src/libdbg@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//src/models@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//JUNK/2011_and_before/object.old@@/main/1
> cleartool diff -diff_format -pred /vob/daproject//src/risk@@/main/1
> git branch -f master_cc
Traceback (most recent call last):
  File "/infinity_tmpfs/ut1p40/git-cc/gitcc", line 51, in ?
    main()
  File "/infinity_tmpfs/ut1p40/git-cc/gitcc", line 14, in main
    return invoke(cmd, args)
  File "/infinity_tmpfs/ut1p40/git-cc/gitcc", line 41, in invoke
    cmd.main(*args)
  File "/infinity_tmpfs/ut1p40/git-cc/rebase.py", line 55, in main
    doStash(lambda: doCommit(cs), stash)
  File "/infinity_tmpfs/ut1p40/git-cc/common.py", line 38, in doStash
    f()
  File "/infinity_tmpfs/ut1p40/git-cc/rebase.py", line 55, in <lambda>
    doStash(lambda: doCommit(cs), stash)
  File "/infinity_tmpfs/ut1p40/git-cc/rebase.py", line 72, in doCommit
    git_exec(['branch', '-f', CC_TAG])
  File "/infinity_tmpfs/ut1p40/git-cc/common.py", line 47, in git_exec
    return popen('git', cmd, GIT_DIR, **args)
  File "/infinity_tmpfs/ut1p40/git-cc/common.py", line 66, in popen
    raise Exception((stderr + stdout).decode(ENCODING))
Exception: fatal: Not a valid object name: 'master'.

Subdirectory defect?

This may well be something I'm doing wrong, but, when files are synced (this is a new install), any file in the root directory gets copied over to my git directory correctly, but, the sync fails with the first file is a sub-directory. When the copy command is called, the directory name is being stripped off, so a file not found exception is raised.

This happens if I init with a Windows style or unix style path to the gitcc init call.

I'm using Cygwin on Windows.

Any ideas?

Multiple branches under one git repo

Hello Charles,

I'm trying to track 2 different branches of the same project in Clearcase under git-cc. I followed the documentation and I came up with this .git/gitcc file

[master]
clearcase = V:\clearcase-prod-branch-view\path\to\project-src
branches = prod_branch

[dev]
clearcase = V:\clearcase-dev-branch-view\path\to\project-src
branches = dev_branch

I initiated a gitcc rebase and loaded allt he history from prod branch to master. But there's no dev branch created to the git repository.

Did I understand the feature wrongly ?

Error running from git bash

I'm trying to set this up. But when I run the gitcc init command, I get the following error:


$ gitcc init
Traceback (most recent call last):
File "d:/tools/versionControl/charleso-git-cc-9f38cf0/gitcc", line 4, in
import rebase, checkin, init, sync, reset, update
File "d:\tools\versionControl\charleso-git-cc-9f38cf0\rebase.py", line 7, in
from users import users, mailSuffix
ImportError: No module named users


I'm running this in WindowsXP. I also have Cygwin installed but when I used Cygwin, I get the [Error 2] The system cannot find the file specified. So, trying it in git bash.

Also, one more question. Lets say, I have my snapshot in d:\viewstore\xyz and the view configuration in d:\viewstore\views\xyz, where do I run the gitcc init

Right now, I ran the git init and gitcc init from d:\viewstore\xyz but the gitcc init command issued was 'gitcc init /d/viewstore/views/xyz'. Please let me know if I'm running this correctly.

Setup User.py

So I have change the user.py.example to User.py. And I've also added the code from the README.md into the user.py.
[core]
include = FolderA|FolderB
exclude = FolderA/sub/folder|FolderB/other/file
debug = False
type = UCM
[master]
clearcase = D:\views\co4222_flex\rd_poc
branches = main|ji_dev|ji___dev|iteration___dev
[sup]
clearcase = D:\views\co4222_sup\rd_poc
branches = main|sup

Now in my users.py under users I have it blank some of the people that has added code and comments are not with the company anymore so they don't have a git account. Now to the mailSuffix so I have that all set up with my company mailSuffix = 'example.com'. Now going down to the core I'm wanting to have everything from the VOB. So I have the include and exclude commented out. Is that wrong or right? For the branches I have this code.
[DEV]
clearcase = c:\Users\RobBennett\Development_2
branches = main|development
[PROD]
clearcase = c:\Users\RobBennett\Production_2
branches = main
So I'm in the folder that I place the new .git from ClearCase. I run the git init, that works, then I run gitcc init c:/Users/RobBennett/Development_2 (which is were my clearcase is located at) after that I end up with this error
gitcc init c:/Users/RobBennett/Development_2
Traceback (most recent call last):
File "c:/Users/RobBennett/Documents/git-cc-master/git-cc-master/gitcc:, line 4, in
import rebase, checkin, init, sync, reset, tag, update
File "c:/Users/RobBennett/Documetns/git-cc-master/git-cc-master/rebase.py", line 7, in
from users import users, mailSuffix
File "c:/Users/RobBennett/Documents/git-cc-master/git-cc-master/users.py", line 14
cleasecase = C:/Users|RobBennett/Development_2
^
SyntaxError: invalid syntax

So the major question is how do you set this thing up or do I have it set up correctly in order to get this to run. Or even when you do the gitcc init what path are you suppose to go to?

pathspec 'master_cc' did not match any file(s) known to git

Hi,

trying to run gitcc rebase from cygwin bash gets me this:

$ gitcc rebase
Encoding=ISO8859-1

git branch
git ls-files --modified
git log -n 1 --pretty=format:%ai master_cc
cleartool lsh -fmt %o%m|%Nd|%u|%En|%Vn|%Nc\n -recurse .
git branch
git checkout master_cc
Traceback (most recent call last):
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 48, in
main()
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 14, in main
return invoke(cmd, args)
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 38, in invoke
cmd.main(_args)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 52, in main
doStash(lambda: doCommit(cs), stash)
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 39, in doStash
f()
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 52, in
doStash(lambda: doCommit(cs), stash)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 61, in doCommit
git_exec(['checkout', CC_TAG])
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 48, in git_exec
return popen('git', cmd, GIT_DIR, *_args)
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 61, in popen
raise Exception((stderr + stdout).decode(ENCODING))
Exception: error: pathspec 'master_cc' did not match any file(s) known to git.

Suggestions?

Note: Since I had to change the encoding part, lines are few off. I also tried this:

$ gitcc rebase --load .git/lshistory.bak
Encoding=ISO8859-1

git branch
git ls-files --modified
git log -n 1 --pretty=format:%ai master_cc
git branch
git checkout master_cc
Traceback (most recent call last):
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 48, in
main()
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 14, in main
return invoke(cmd, args)
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 38, in invoke
cmd.main(_args)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 52, in main
doStash(lambda: doCommit(cs), stash)
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 39, in doStash
f()
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 52, in
doStash(lambda: doCommit(cs), stash)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 61, in doCommit
git_exec(['checkout', CC_TAG])
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 48, in git_exec
return popen('git', cmd, GIT_DIR, *_args)
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 61, in popen
raise Exception((stderr + stdout).decode(ENCODING))
Exception: error: pathspec 'master_cc' did not match any file(s) known to git.

there is a 'main' branch on my clearcase view so that shouldn't be the case. I'm using a snapshot view.

Track ClearCase tags instead of branches

Hello,

That's merely a question but is gitcc able to track ClearCase tags instead of branches? When I initialise the .git/gitcc config file specifying the branch I like to track it like:

[master]
clearcase = V:/path/to/view
branches = branch_name

i see half of the files after the gitcc rebase of the project (only the ones changed on the branch_name branch.

So instead can I somehow specify the ClearCase tag name and fetch everything?

Thanks
Leonidas

Soft links not copied

When using gitcc update, the symbolic links are not copied from the Clearcase vob to the git repository.

Gitcc not compatible with python 3.4 ?

While running gitcc rebase I get the below. When used python 2.7 all worked fine. As I didn't find somewhere that the project is python 2 specific I open this ticket. Let me know if it's not suppose to work on python 3.

> git add .gitcc
> git branch -f master_cc
Traceback (most recent call last):
  File "x:\usr\git-cc-master\rebase.py", line 66, in doCommit
    commit(cs)
  File "x:\usr\git-cc-master\rebase.py", line 149, in commit
    cs.commit()
  File "x:\usr\git-cc-master\rebase.py", line 195, in commit
    git_exec(['commit', '-m', comment.encode(ENCODING)], env=env)
  File "x:\usr\git-cc-master\common.py", line 47, in git_exec
    return popen('git', cmd, GIT_DIR, encoding='UTF-8', **args)
  File "x:\usr\git-cc-master\common.py", line 56, in popen
    debug('> ' + ' '.join(map(f, cmd)))
  File "x:\usr\git-cc-master\common.py", line 55, in <lambda>
    f = lambda a: a if not a.count(' ') else '"%s"' % a
TypeError: Type str doesn't support the buffer API

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "x:\usr\git-cc-master\gitcc", line 48, in <module>
    main()
  File "x:\usr\git-cc-master\gitcc", line 14, in main
    return invoke(cmd, args)
  File "x:\usr\git-cc-master\gitcc", line 38, in invoke
    cmd.main(*args)
  File "x:\usr\git-cc-master\rebase.py", line 55, in main
    doStash(lambda: doCommit(cs), stash)
  File "x:\usr\git-cc-master\common.py", line 38, in doStash
    f()
  File "x:\usr\git-cc-master\rebase.py", line 55, in <lambda>
    doStash(lambda: doCommit(cs), stash)
  File "x:\usr\git-cc-master\rebase.py", line 72, in doCommit
    git_exec(['branch', '-f', CC_TAG])
  File "x:\usr\git-cc-master\common.py", line 47, in git_exec
    return popen('git', cmd, GIT_DIR, encoding='UTF-8', **args)
  File "x:\usr\git-cc-master\common.py", line 62, in popen
    raise Exception(decodeString(encoding, stderr + stdout))
Exception: fatal: Not a valid object name: 'master'.

Missing empty line in commit message after `gitcc rebase`

For example there is a commit made via git:

Refactor CSS

Change names according to coding style. Also remove redundant styles.
So on and so on...

Then do gitcc checkin and gitcc rebase. After that gitcc makes a commit with changes in .gitcc file only but this commit has a message without empty line:

Refactor CSS
Change names according to coding style. Also remove redundant styles.
So on and so on...

If I make gitcc rebase from scratch my commit will have the same message (without empty line).

ClearCase History Browser also shows the same message without empty line.

Is this ClearCase limitation? Is it possible to avoid this?

Dynamic view doesn't work anymore

Hello,

I've been using git-cc for almost 2 years working against dynamic views. The latest commits doesn't work. The exception is:
$ gitcc rebase
> git ls-files --modified
> cleartool update
Traceback (most recent call last):
File "d:/Tools/git-cc/gitcc", line 48, in
main()
File "d:/Tools/git-cc/gitcc", line 14, in main
return invoke(cmd, args)
File "d:/Tools/git-cc/gitcc", line 38, in invoke
cmd.main(_args)
File "d:\Tools\git-cc\rebase.py", line 35, in main
cc_exec(["update"])
File "d:\Tools\git-cc\common.py", line 50, in cc_exec
return popen('cleartool', cmd, CC_DIR, *_args)
File "d:\Tools\git-cc\common.py", line 60, in popen
raise Exception((stderr + stdout).decode(ENCODING))
Exception: cleartool: Error: 'V:\path\to\dynamic\view' is not a valid snapshot view path.
The latest working commit I used is 80c5e69. After that I've tested some commits after without success.

For reference my gitcc config is:
[master]
clearcase = V:\path\to\dynamic\view
branches = main|a_branch

Can anyone validate the Dynamic views are broken?

Thanks,
Leonidas

UnicodeEncodeError: 'ascii' codec can't encode characters

OS: Windows 7

git version 1.7.11.msysgit.0
cleartool version 7.1.2.0
Python version 2.7.1

config:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
    autocrlf = false
    debug = true
    cache = false

When I commit to git and use cyrillic in the commit message, then gitcc checkin fails:

sergey@ZAKUSOV /C/git-cc-test-repo (master)
$ gitcc checkin
> cleartool update .
> git log -z --reverse --pretty=format:%H%x01%s%n%b --first-parent master_ci..
> git diff --name-status -M -z --ignore-submodules 27492ee1c17c6be57c8b4112885573c71ffe9a8b^..27492ee1c17c6be57c8b4112885573c71ffe9a8b
> git ls-tree -z 27492ee1c17c6be57c8b4112885573c71ffe9a8b -- module1/test1.txt
> git merge-base master_ci HEAD
> cleartool co -reserved -nc module1/test1.txt
> git hash-object Z:project1\module1/test1.txt
> git ls-tree -z 779bb19196a306a58b5859c3ff8f3f7658649ab6 module1/test1.txt
> git ls-tree -z 27492ee1c17c6be57c8b4112885573c71ffe9a8b module1/test1.txt
> git cat-file blob 06f0ae4f6ea9ddfdfd960b54c34f0c85d2422ebd
> cleartool ci -identical -c "ยฆยฆยฆ-ยฆ-ยฆ-ยฆยฌTะ’ ยฆ- ยฆ-ยฆยฆTะ’ยฆยฆTะ“ feature1" module1/test1.txt
Traceback (most recent call last):
  File "c:/git-cc/gitcc", line 48, in <module>
    main()
  File "c:/git-cc/gitcc", line 14, in main
    return invoke(cmd, args)
  File "c:/git-cc/gitcc", line 38, in invoke
    cmd.main(*args)
  File "c:\git-cc\checkin.py", line 39, in main
    checkout(statuses, comment.strip(), initial)
  File "c:\git-cc\checkin.py", line 90, in checkout
    transaction.commit(comment);
  File "c:\git-cc\checkin.py", line 113, in commit
    cc_exec(['ci', '-identical', '-c', comment, file])
  File "c:\git-cc\common.py", line 50, in cc_exec
    return popen('cleartool', cmd, CC_DIR, **args)
  File "c:\git-cc\common.py", line 57, in popen
    pipe = Popen(cmd, cwd=cwd, stdout=PIPE, stderr=PIPE, env=env)
  File "c:\Python27\lib\subprocess.py", line 679, in __init__
    errread, errwrite)
  File "c:\Python27\lib\subprocess.py", line 896, in _execute_child
    startupinfo)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 28-39: ordinal not in range(128)

Variable ENCODING = cp866.

rebase.py fails under cygwin

python --version

Python 2.6.5

gitcc rebase --dry-run

git log -n 1 --pretty=format:%ai master_cc
cleartool ls -recurse -short .
cleartool lsh -fmt %o%m|%Nd|%u|%En|%Vn|%Nc\n -recurse .
Traceback (most recent call last):
File "/cygdrive/c/home/tmp/git-cc/gitcc", line 48, in
main()
File "/cygdrive/c/home/tmp/git-cc/gitcc", line 14, in main
return invoke(cmd, args)
File "/cygdrive/c/home/tmp/git-cc/gitcc", line 38, in invoke
cmd.main(*args)
File "/cygdrive/c/home/tmp/git-cc/rebase.py", line 45, in main
cs = parseHistory(history)
File "/cygdrive/c/home/tmp/git-cc/rebase.py", line 119, in parseHistory
add(last, comment)
File "/cygdrive/c/home/tmp/git-cc/rebase.py", line 109, in add
if filterBranches(cs.version):
File "/cygdrive/c/home/tmp/git-cc/rebase.py", line 92, in filterBranches
version = version[-1]
IndexError: list index out of range

Work in Red Hat 5 (python 2.4)

Hi,
I have not only the chance to use clearcase at work, but I alsa use the wonderful red hat enterprise !

Python 2.4 goodies etc. With no root access.
What should I do to make it work on this system ?
First problem I have is the :
defaults = defaults if defaults else []

gitcc fails on rebase

Hi,

While using gitcc rebase, i get this below error, Any idea what could cause this.

cleartool lsh -fmt %o%m|%Nd|%u|%En|%Vn|%Nc\n -recurse .
Traceback (most recent call last):
File "../gitcc", line 48, in
main()
File "../gitcc", line 14, in main
return invoke(cmd, args)
File "../gitcc", line 38, in invoke
cmd.main(_args)
File "h:\Tools\git-cc-master\git-cc-master\rebase.py", line 43, in main
history = getHistory(since)
File "h:\Tools\git-cc-master\git-cc-master\rebase.py", line 90, in getHistory
return cc_exec(lsh)
File "h:\Tools\git-cc-master\git-cc-master\common.py", line 50, in cc_exec
return popen('cleartool', cmd, CC_DIR, *_args)
File "h:\Tools\git-cc-master\git-cc-master\common.py", line 62, in popen
raise Exception(decodeString(encoding, stderr + stdout))
Exception: cleartool: Error: Not an object in a vob: ".".

Thanks,
Raghav

gitcc does not handle moved directories which causes files to disappear.

gitcc does not handle moved directories. Instead it first removes the directory and then later add the directory again. If a directory is moved in ClearCase the contents of the directory still remains in the directory but in the git-repo everything is cleared and therefore files are lost.

A possible fix for this could be to scan each newly added directory for contents and recreate the files.

Another way could be to not remove directories but save them with a different name and reuse them later if they appear again. This method would preserve history for the files in the directory.

Not files after initial rebase

I've no idea how to use ClearCase. I've been asked to look at getting git-cc working. I have followed the instructions here, and have fixed a couple of issues I've run into by looking over the issues list here. But I still have no files.

The glitch rebase finishes and the lshistory.bak file is created.

The .git/gitcc file was pretty empty. It had:
[master]
clearcase = /cygdrive/v/p111000/app_root

I added:
BRANCHES=main|p111000_COL4.0

main is the base 'branch'. p111000_COL4.0 is my view.

Any 'git branch' leads to an error "fatal: Not a valid object name: 'Master'." I see where several others have had this issue, and the advice was always that BRANCHES wasn't correct. I see both of those when I run "clear tool lstype -kind brtype' and in the Clear Case explorer. So I think it's correct.

I just can't seem to actually get the source code into my git directory to start work.

Any help would be appreciated.

Merging multiple CC Vobs into a single git repository

The script works great for the most part ( had to modify it to take out the language checking going out to Git Bash ), but it would be much better if it could allow for multiple VOB import into a single git repository. At my work, we have a project set up over multiple VOBs including a common and driver VOB, and as we are trying to model repositories as per project, this creates a difficult time trying to wipe out our .gitcc then re-initialize it to a different VOB. Any ideas for how to move forward better? We are looking for a one time import into GIT. ( Ideally without submodules, my least favorite part of GIT )

When you merge the activity history, why the date is not used as a condition.

The following function is used to check if the history is the same
def same(a, b):
return a.subject == b.subject and a.user == b.user

But I think you should add a additional condition "date".
Only the event on the same date can be created by one checkin, right?
I mean it should be
return a.subject == b.subject and a.user == b.user and a.date ==b.date

No module named users

Traceback (most recent call last): File "./charleso-git-cc-e81f9e9/gitcc", line 4, in ? import rebase, checkin, init, sync, reset, tag, update File "./charleso-git-cc-e81f9e9/rebase.py", line 7, in ? from users import users, mailSuffix ImportError: No module named users

What is this users module ? It isn't installed on my system.
Is it a python module ?

Importing branches

Can git-cc be made to import branches and merges (hyperlink data) from Clearcase?

At the moment it seems I can either:
Specify "branches=release" and get all the "merge of branch foo into release" changesets, or
Specify "branches=*" and get every single Clearcase commit mashed into multiple commits on the git master branch (with no branching/merging imported)

What I'd like is to have Clearcase branches (the feature/bugfix branches) and merge hyperlinks (where said branches have been brought into the release tree) imported into Git so I can see how the code has changed over time.

Sometimes versions are commited to git in the wrong order.

In reabse.py, main there is a line

cs.sort(key = lambda x: x.date)

that sorts the changesets in chronological order. I guess this is done because the list is in reverse order. Why the list is not simply reversed is a good question as the output from clearcase lshistory which the data is based on is already sorted.

The problem here is that two commits with the same time-stamp will (or might if cs.sort is an unstable sorting algorithm) change ordering. This causes gitcc to commit /main/2 before /main/1 if two commits on the same file have the same timestamp.

I'll replace the sort with a simple reverse and see if that fixes the problem. I'll be back with my answer in a couple of hours after some testing.

execution error within latest cygwin

$ python --version
Python 2.5.2

$ ./gitcc
Traceback (most recent call last):
File "./gitcc", line 4, in
import rebase, checkin, init, sync, reset, update
File "/opt/gitcc/rebase.py", line 188
except Exception as e:
^
SyntaxError: invalid syntax

No rebase just a lshistory file

Hi!

I'm trying to convert my clearcase project, but the result is disappointing....

After the execution of the gitcc rebase command the only result is a lshistory.bak file. No trac, nothing else ....

I have tryed running the gitcc rebase --load .git\lshistory.bak and here i'm getting the following output:

$ gitcc rebase --load =.git/lshistory.bak

git ls-files --modified
git log -n 1 --pretty=format:%ai master_cc
cleartool ls -recurse -short Deployment
Traceback (most recent call last):
File "c:/GitProjects/git-cc/gitcc", line 48, in
main()
File "c:/GitProjects/git-cc/gitcc", line 14, in main
return invoke(cmd, args)
File "c:/GitProjects/git-cc/gitcc", line 38, in invoke
cmd.main(*args)
File "c:\GitProjects\git-cc\rebase.py", line 37, in main
history = open(load, 'r').read().decode(ENCODING)
IOError: [Errno 2] No such file or directory: '=.git/lshistory.bak'

Any good suggestions ??

UnicodeDecodeError: 'utf8' codec can't decode byte 0xb8 in position 7713658: invalid start byte

Error encountered while rebase

[root@linux git-repo]# /root/git-cc-master/gitcc rebase

git ls-files --modified
git log -n 1 --pretty=format:%ai master_cc
cleartool ls -recurse -short .
cleartool lsh -fmt %o%m|%Nd|%u|%En|%Vn|%Nc\n -recurse .
Traceback (most recent call last):
File "/root/git-cc-master/gitcc", line 48, in
main()
File "/root/git-cc-master/gitcc", line 14, in main
return invoke(cmd, args)
File "/root/git-cc-master/gitcc", line 38, in invoke
cmd.main(_args)
File "/root/git-cc-master/rebase.py", line 40, in main
history = getHistory(since)
File "/root/git-cc-master/rebase.py", line 87, in getHistory
return cc_exec(lsh)
File "/root/git-cc-master/common.py", line 50, in cc_exec
return popen('cleartool', cmd, CC_DIR, *_args)
File "/root/git-cc-master/common.py", line 61, in popen
return stdout if not decode else stdout.decode(ENCODING)
File "/usr/lib/python2.6/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb8 in position 7713658: invalid start byte
[root@linux git-repo]#

Support for --git-dir and .git file

There is a great option for git which can put the git dir (.git) into another directory/tree.
Combined with --work-tree option, you can init a git repository to another directory, while the work-tree is considered on the right path.
To achieve this without hassle and without passing --git-dir and --work-tree at each invocation of git command, you create a .git file which contains
gitdir: /path/to/the/real/git/repo

I think I began to use it because there must be some kind of limitation of just using a symbolic link to another directory, but I don't remember why exactly

Support for empty folders

It appears that in ClearCase we have several empty folders to satisfy build tools (i.e. the Flex compiler). In CC, this is fine because folders are versioned objects, but in GIT, as you know, empty folders are ignored.

Is there any chance of having GITCC automatically create .keep files for empty folders?

Permission denied during rebase

Working with a UCM view, I was able to get past other issues with the rebase process by creating a child stream for the GIT synchronization (instead of using the integration stream), and removing "main" from the list of branches I cared about.

It gets all the way past the lsh step and the step where it requests the headlines for each of the activities (sometimes, multiple times, but my guess is that's because my organization re-uses activities). But, it then fails after the initial commit to GIT when it tries to remove some files from the repo:

cleartool diff -diff_format -pred myapp@@/main/myapp_r3_dev_stream/r4_integration/r6_integration/1
git add .gitcc
git commit -m "deliver r6_myapp on 9/1/2011 5:56:13 PM."
git branch -f master_cc
git tag -f master_ci master_cc
Traceback (most recent call last):
File "/cygdrive/c/IBM/RationalSDLC/git-cc/gitcc", line 48, in
main()
File "/cygdrive/c/IBM/RationalSDLC/git-cc/gitcc", line 14, in main
return invoke(cmd, args)
File "/cygdrive/c/IBM/RationalSDLC/git-cc/gitcc", line 38, in invoke
cmd.main(*args)
File "/cygdrive/c/IBM/RationalSDLC/git-cc/rebase.py", line 52, in main
doStash(lambda: doCommit(cs), stash)
File "/cygdrive/c/IBM/RationalSDLC/git-cc/common.py", line 40, in doStash
f()
File "/cygdrive/c/IBM/RationalSDLC/git-cc/rebase.py", line 52, in
doStash(lambda: doCommit(cs), stash)
File "/cygdrive/c/IBM/RationalSDLC/git-cc/rebase.py", line 63, in doCommit
commit(cs)
File "/cygdrive/c/IBM/RationalSDLC/git-cc/rebase.py", line 146, in commit
cs.commit()
File "/cygdrive/c/IBM/RationalSDLC/git-cc/rebase.py", line 183, in commit
file.add(files)
File "/cygdrive/c/IBM/RationalSDLC/git-cc/rebase.py", line 209, in add
self._add(self.file, self.version)
File "/cygdrive/c/IBM/RationalSDLC/git-cc/rebase.py", line 217, in _add
removeFile(toFile)
File "/cygdrive/c/IBM/RationalSDLC/git-cc/common.py", line 139, in removeFile
os.remove(file)
OSError: [Errno 13] Permission denied: 'G:/myapp/ui/pom.xml'

I'd fix it, but I'm not exactly sure what's supposed to happen during this step. It looks like it's core to what the gitcc scripts do that they need to replace files with predecessor versions in order to import them. Doesn't deleting a file in a UCM dynamic view cause it to be deleted immediately in the stream?

Exception File has been modified

Hello I'm getting this when I try to gitcc checkin

Exception: File has been modified: package/className.java. Try rebasing.
Full traceback:

> cleartool unco -rm package/className.java
Traceback (most recent call last):
  File "d:/tools/git-cc/gitcc", line 48, in <module>
    main()
  File "d:/tools/git-cc/gitcc", line 14, in main
    return invoke(cmd, args)
  File "d:/tools/git-cc/gitcc", line 38, in invoke
    cmd.main(*args)
  File "d:\tools\git-cc\checkin.py", line 44, in main
    checkout(statuses, comment.strip(), initial)
  File "d:\tools\git-cc\checkin.py", line 88, in checkout
    stat.stage(transaction)
  File "d:\tools\git-cc\status.py", line 31, in stage
    t.stage(self.file)
  File "d:\tools\git-cc\checkin.py", line 133, in stage
    raise Exception('File has been modified: %s. Try rebasing.' % file)
Exception: File has been modified: package/className.java. Try rebasing.

When I do rebase I get no updates.Is there something I am missing?

Cannot delete files

I was unable to remove files from the repo.

I tried to delete two files: Desktop/.architect and Mobile/.architect.

$ gitcc checkin
> cleartool update .
> git log -z --reverse --pretty=format:%H%x01%s%n%b --first-parent master_ci..
...
> git diff --name-status -M -z --ignore-submodules 65bac0030a7fc196859d03898e0ad62c9ba1efb7^..65bac0030a7fc196859d03898e0ad62c9ba1efb7
> cleartool ls -long Desktop/.architect
> git ls-tree -z 65bac0030a7fc196859d03898e0ad62c9ba1efb7 -- Desktop/.architect
char=D filename=Desktop/.architect
[u'Desktop/.architect']
> cleartool ls -long Mobile/.architect
> git ls-tree -z 65bac0030a7fc196859d03898e0ad62c9ba1efb7 -- Mobile/.architect
char=D filename=Mobile/.architect
[u'Mobile/.architect']
> git merge-base master_ci HEAD
> cleartool co -reserved -nc Desktop
> cleartool co -reserved -nc Mobile
<status.Delete instance at 0x02BC3508>
Trying to delete d:/CC_Views/phil_tsarik_view/project_dir\Desktop/.architect
Traceback (most recent call last):
  File "c:/Program Files (x86)/git-cc/gitcc", line 48, in <module>
    main()
  File "c:/Program Files (x86)/git-cc/gitcc", line 14, in main
    return invoke(cmd, args)
  File "c:/Program Files (x86)/git-cc/gitcc", line 38, in invoke
    cmd.main(*args)
  File "c:\Program Files (x86)\git-cc\checkin.py", line 44, in main
    checkout(statuses, comment.strip(), initial)
  File "c:\Program Files (x86)\git-cc\checkin.py", line 111, in checkout
    stat.commit(transaction)
  File "c:\Program Files (x86)\git-cc\status.py", line 61, in commit
    if exists(path) and os.path.filename(path) in os.listdir(os.path.dirname(path)):
AttributeError: 'module' object has no attribute 'filename'

Please note that there is a backslash in the path to delete: d:/CC_Views/phil_tsarik_view/project_dir\Desktop/.architect. Does this something mean?

Also I tried to delete other files before but always the same error.

Windows 7 x64
Python 2.7.6. Also I tried python 3.x but I couldn't even make an initial gitcc rebase due to some other exception. BTW what python version is supported by git-cc?

Please help

All the version on all branches of CC will be created to master branch of git, is it reasonable?

When we transfer between CC main and git master.

We run "cleartool lshistroy" and then filter "checkinversion operaton" to get all the versions created. )
Typically, the output might be

checkinversion|20140307.1111111|user|dummy|\main\5| (it is a version on Main)
checkinversion|20140307.1111111||dummy|\main\my_branh\5| (it is a version on my_branch)

And then we
cc_exec(['get','-to', toFile, cc_file(file, version)])

And then create git version on master for each of them.
This will create some addtional version on the git master, which are original on the my_branch of CC
is it reasonable?

The empty file will be lost after "gitcc rebase"

Hi charleso,
I find a issue after i migrate the a vob from clearcase to Git by "git rebase": subfolder and the file in this subfolder will be lost in git repository if the file is a empty one. If a subfolder include both a Non-empty file and empty file, only empty file is lost. I am not sure if it is a bug. When I create a snapview in my local from clearcase, i can see the subfolder and its empty files. So I am a little confused about it. Please help check. Thanks!

Hi charleso,
Sorry, today i check the lost files again, I find the real reason why files lost is not the size of file. It may be caused by there is no "checkinversion|XXXXXXXXX.XXXXXX|\main\1"(and upper) in the history log. Such as the following:

checkinversion|20091117.140842|\main\css_refactor\1
mkbranchversion|20091117.140842|\main\css_refactor\0
mkbranchbranch|20091117.140842|\main\css_refactor
mkelemversion|20091117.140842|\main\0
mkelembranch|20091117.140842|\main
mkelemfile element|20091117.140842|

So Can you help check it? If current script doesn't support this kinds of case?

gitcc checkin ignores include/exclude directories

Hi there, is this behavior by design? If yes, I'm assuming these settings are for the CC --> git direction? Maybe another section in the gitcc configuration file, dedicated to the git --> CC direction could handle this feature, what do you think?

UnicodeDecodeError on Windows

I tried to follow the instructions in the README and did this

$ git init
$ gitcc init /cygdrive/x/[my actual path]

Then I edited my .git/gitcc to this

[core]
type = UCM
[master]
clearcase = /cygdrive/x/[my actual path]

I'm not sure which config options are required so I only added type = UCM. Then I did the rebase and got this

$ gitcc rebase
> git ls-files --modified
> git log -n 1 --pretty=format:%ai master_cc
> cleartool ls -recurse -short .
Traceback (most recent call last):
  File "../gitcc/gitcc", line 48, in <module>
    main()
  File "../gitcc/gitcc", line 14, in main
    return invoke(cmd, args)
  File "../gitcc/gitcc", line 38, in invoke
    cmd.main(*args)
  File "/cygdrive/c/aoln/gitcc/rebase.py", line 35, in main
    cache.start()
  File "/cygdrive/c/aoln/gitcc/cache.py", line 22, in start
    self.initial()
  File "/cygdrive/c/aoln/gitcc/cache.py", line 32, in initial
    self.read(cc_exec(ls))
  File "/cygdrive/c/aoln/gitcc/common.py", line 50, in cc_exec
    return popen('cleartool', cmd, CC_DIR, **args)
  File "/cygdrive/c/aoln/gitcc/common.py", line 61, in popen
    return stdout if not decode else stdout.decode(ENCODING)
  File "/usr/lib/python2.6/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 164948-164951: invalid data

This is on Cygwin in Windows XP with python 2.6.5. I'm sure there are many files in my CC repository which are not UTF-8 but is this unsupported or is there some other thing going on?

gitcc rebase results in duplicate commits in git

Sometimes gitcc rebase will duplicate a commit that I just checked in to clearcase (via gitcc checkin). It's as if the gitcc rebase can't tell that recent checkins executed a few minutes ago by "gitcc checkin" should match the existing commit, so it creates a new commit.

Here's what I do

  1. Commit a change in git, let's call it A
  2. gitcc rebase, resulting in a couple of new commits B and C (this doesn't seem to be strictly necessary, the problem occurs even if there aren't any new changes in clearcase).
  3. gitcc checkin, checks commit A to clearcase correctly
  4. gitcc rebase, now there is a new commit D in the git repo that is exactly the same as commit A (except for the commit hash of course).

Any ideas?

Files that have been moved in ClearCase will loose their history.

gitcc does not recognize that a file has moved in ClearCase. In the git repo the file will be deleted and recreated. This means that the file looses it's history in the git-repo every time it is moved in ClearCase.

A possible way to fix this would be to rename all files that are removed to something else and later reuse the files if they reappear.

gitcc rebase skips merged file versions

Hello.
I have some problems with rebasing.

There is a file.
Versions of this file from ClearCase History Browser looks like this:

\main\dev\4
\main\dev\3
\main\dev\mbb\1
\main\dev\mbb\0
\main\dev\mbb
\main\dev\2
\main\dev\1
\main\dev
\main\0
\main

tree

As you can see we have two branches: dev and mmb. And there was a merge from mmd to dev.
gitcc rebase updates this file only until \main\dev\mbb\1 version. It doesn't update to version \main\dev\3 and further.

My .git/gitcc file is:

[core]
exclude = ...
[master]
clearcase =  ...
branches = mbb|dev

I also tried to set branches as mbb|dev|dev/mbb|mbb/dev

Please help, how do I able to solve this problem?

gitcc rebase don't do nothing

I do the commands and don't do nothing..

mpmartins@AGBAR006501 /d/viewsgit/occam (master)
$ /c/Python32/python.exe /d/marco/git-cc/gitcc init /d/views/OCCAM_Evo_1_2/OCCAM/FuentesOCCAM
git config core.autocrlf false

mpmartins@AGBAR006501 /d/viewsgit/occam (master)
$ /c/Python32/python.exe /d/marco/git-cc/gitcc rebase
git ls-files --modified
git log -n 1 --pretty=format:%ai master_cc
cleartool ls -recurse -short .
cleartool lsh -fmt %o%m|%Nd|%u|%En|%Vn|%Nc\n -recurse .

mpmartins@AGBAR006501 /d/viewsgit/occam (master)
$ ls

mpmartins@AGBAR006501 /d/viewsgit/occam (master)
$ git log
fatal: bad default revision 'HEAD'

/bin/env: python: No such file or directory

Hi

When i try to run any of the command, it is throwing me the below error.

/bin/env: python: No such file or directory

Actually I have downloaded git-cc repository as zip file and copied to my local machine. and then i try to run the commands mentioned below

$ "/git-cc-master/gitcc" init D:/CC/View/CVOB.

Is there anything wrong in doing this. Can you please help me out in correcting it.

Note:- I have python also already installed in my local machine.

Thanks In advance..

Regards,
A.Vikramsai

Unwanted files in CC Base after update

Hi,
I just trying gitcc, and I found that by default after I do:
gitcc init ..
gitcc update ..

git has 2 unwanted files inside:

  • update.2012-03-01T155903+0100.updt
  • view.dat

I have tried to add them to exclude but it does not seems to work.
I have check update.py and it ignores excludes.

Error when commit removed files

I removed some files on 'master' branch and made a commit. I removed 3 files (one of them Desktop/images/16x16/Thumbs.db)
Then I run gitcc checkin and get an error:

Traceback (most recent call last):
  File "c:/Program Files (x86)/git-cc/gitcc", line 48, in <module>
    main()
  File "c:/Program Files (x86)/git-cc/gitcc", line 14, in main
    return invoke(cmd, args)
  File "c:/Program Files (x86)/git-cc/gitcc", line 38, in invoke
    cmd.main(*args)
  File "c:\Program Files (x86)\git-cc\checkin.py", line 44, in main
    checkout(statuses, comment.strip(), initial)
  File "c:\Program Files (x86)\git-cc\checkin.py", line 105, in checkout
    stat.stage(transaction)
  File "c:\Program Files (x86)\git-cc\status.py", line 54, in stage
    t.stageDir(dirname(self.file))
  File "c:\Program Files (x86)\git-cc\checkin.py", line 129, in stageDir
    self.co(file)
  File "c:\Program Files (x86)\git-cc\checkin.py", line 122, in co
    cc_exec(['co', '-reserved', '-nc', file])
  File "c:\Program Files (x86)\git-cc\common.py", line 50, in cc_exec
    return popen('cleartool', cmd, CC_DIR, None, False, **args)
  File "c:\Program Files (x86)\git-cc\common.py", line 60, in popen
    raise Exception((stderr + stdout).decode(ENCODING))
Exception: cleartool: Error: Element "Desktop/images/16x16" is already checked out to view "phil_tsarik_view".

Have I done something wrong?

And can you please tell more about the workflow? In particular why is there a branch master_cc, what for? What branch should I work with?

rebase merge conflicts

I just thought I would share a solution to a problem I had encountered.
When there were conflicts between git and clearcase i would have to rebase before pulling or else it caused gitcc to have a fit. The solution (workaround) is as follows

gitcc rebase //this is the rebase that will cause a merge conflict
git mergetool //to resolve the conflicts
git add -A
git rebase --continue

git checkout master_cc
git merge master //or whatever branch you were trying to merge to
git checkout master

gitcc rebase //rebase again and its resolved.

It seems to me that gitcc should include a command to automatically do this (probably in a more efficient manner)

file content is lost during rebase when that new file is checked in at the same time as its parent folder in clearcase

Hi, charleso,

I run into this problem during executing "gitcc rebase" command. Let me elaborate the reproduce steps:

  1. check in a new file using some tools like CCRC (clear case remote client) which makes the version 1 of this file shares the same modified time as that in its parent folder
  2. then migrate that repository to git. After rebase the new file's content is lost, it becomes an empty file.

I think the reason is that:

when check in a new file in clearcase, it will automatically add two versions: version 0 (with the type mkelemversion, which is an empty file) and version 1 (with the type checkinversion, which contains the real content), and if we check in the new file with some tool like CCRC, the file's parent folder will be automatically checked in, so the check in time of version 1 and the folder is the same (the check in time of version 0 is a little earlier)

Then in the rebase.py code, first the version 1 of that file is checked in through Changeset.add(), then we will check in the folder through Uncataloged.add(), in this function:

class Uncataloged(Changeset):
    def add(self, files):
                ......
                history = filter(None, history.split('\n'))    # contains version1 and version0
                all_versions = self.parse_history(history)

                date = cc_exec(['describe', '-fmt', '%Nd', dir])
                actual_versions = self.filter_versions(all_versions, lambda x: x[1] < date)  # version1 is filtered out since its date is the same as that in folder 

                versions = self.checkin_versions(actual_versions)  #version 0 is also filtered out, versions is empty now
                if not versions:
                    print("No proper versions of '%s' file. Check if it is empty." % added)
                    versions = self.empty_file_versions(actual_versions)  #version 0 is added back
                if not versions:
                    print("It appears that you may be missing a branch in the includes section of your gitcc config for file '%s'." % added)
                    continue
                self._add(added, versions[0][2].strip())   # this file becomes blank since version 1 is overwritten by version 0

As the comments in the code above, the file's content is lost since it is overwritten by the empty file version 0.

I think there are two possible solutions:

  1. change
lambda x: x[1] < date

to

lambda x: x[1] <= date
  1. if the versions is empty after
versions = self.checkin_versions(actual_versions)

just continue and do not add the empty version file back.

I prefer No.2 since the 1st solution will cause a duplicate commit for version 1.

What do you think? Thanks.

Some files cause rebase to abort

Background: in our clearcase repository we have files that presumably have so long file names/paths that they cause issues with clearcase. It would seem those files load fine in some other OS's, but not on windows. Since we use windows workstations for developing and linux servers on actual deployment, this hasn't been seen that big of an issue.

However, now trying to use git-cc to get cc stuff to git, and these files are causing the whole process to abort (which lasts several days to begin with - our repo is quite big). Can we somehow ignore such files, or skip to next one? There is only a handful of those anyway.

Error message below. I've edited the file name/path to protect the innocent, but the length is the same. the file name has to be that long due to framework requirements.

git tag -f master_ci master_cc
Traceback (most recent call last):
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 48, in
main()
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 14, in main
return invoke(cmd, args)
File "/cygdrive/c/versioncontrol/git-cc/gitcc", line 38, in invoke
cmd.main(_args)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 52, in main
doStash(lambda: doCommit(cs), stash)
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 39, in doStash
f()
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 52, in
doStash(lambda: doCommit(cs), stash)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 63, in doCommit
commit(cs)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 146, in commit
cs.commit()
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 183, in commit
file.add(files)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 209, in add
self._add(self.file, self.version)
File "/cygdrive/c/versioncontrol/git-cc/rebase.py", line 216, in _add
cc_exec(['get','-to', toFile, cc_file(file, version)])
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 51, in cc_exec
return popen('cleartool', cmd, CC_DIR, *_args)
File "/cygdrive/c/versioncontrol/git-cc/common.py", line 61, in popen
raise Exception((stderr + stdout).decode(ENCODING))
Exception: cleartool: Error: //?/C:/versioncontrol/ourprojectpath/applications/long/path/long/path/long/path/long/path/long/path/long/path/long/path/long/path/long/path/long/path/long/path/long/path/long/path/filename.long0000000000000000000000000000000000000000000000000000000000000000.jsp: No such file or directory

cleartool: Error: Operation "file copy" failed: No such file or directory.

check and exclude the private and checkout files for gitcc update

in gitcc update
cc_exec(['update', '.'], errors=False)
sync.main()
git_exec(['add', '.'])
git_exec(['commit', '-m', message])
reset.main('HEAD')

But I think here the following command should be run
cleartool lsco
cleartool lsprivate
And the results should be excluded for "git add" operation, right?

configuration problem

Hi

I have created new snapshot view. and I have created new directory for src from clearcase.
I have done "git init" on src dir through gitbash cmd prompt.
And "gitcc init d:\snapshot_view_dir"
While doing rebase/update getting below error message.

git log -n 1 --pretty=format:%ai master_cc
cleartool ls -recurse -short GEN4Firmware
Traceback (most recent call last):
File "./gitcc", line 48, in
main()
File "./gitcc", line 14, in main
return invoke(cmd, args)
File "./gitcc", line 38, in invoke
cmd.main(_args)
File "d:\gitsync\git-cc-master\rebase.py", line 36, in main
cache.start()
File "d:\gitsync\git-cc-master\cache.py", line 22, in start
self.initial()
File "d:\gitsync\git-cc-master\cache.py", line 32, in initial
self.read(cc_exec(ls))
File "d:\gitsync\git-cc-master\common.py", line 50, in cc_exec
return popen('cleartool', cmd, CC_DIR, *_args)
File "d:\gitsync\git-cc-master\common.py", line 57, in popen
pipe = Popen(cmd, cwd=cwd, stdout=PIPE, stderr=PIPE, env=env)
File "d:\Python27\lib\subprocess.py", line 679, in init
errread, errwrite)
File "d:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 267] The directory name is invalid

Can you please tell me where i am wrong?

--Kumar

rebase error, appears to be skipping a necessary commit step

I've been experimenting with gitcc and ran into the following exception.

$ gitcc rebase

git ls-files --modified
git log -n 1 --pretty=format:%ai master_cc
cleartool lsh -fmt %o%m|%Nd|%u|%En|%Vn|%Nc\n -recurse -since 28-Feb-2012.20:07:03 .
git branch
git checkout master_cc
cleartool get -to "file1.xml"
git add -f "file2.xml"
cleartool get -to "file2.xml" "file2.xml"
git add -f "file2.xml"
git add .gitcc
git rebase master_ci master_cc
Traceback (most recent call last):
File "e:/gitwork/git-cc-dload/gitcc", line 48, in
main()
File "e:/gitwork/git-cc-dload/gitcc", line 14, in main
return invoke(cmd, args)
File "e:/gitwork/git-cc-dload/gitcc", line 38, in invoke
cmd.main(_args)
File "e:\gitwork\git-cc-dload\rebase.py", line 52, in main
doStash(lambda: doCommit(cs), stash)
File "e:\gitwork\git-cc-dload\common.py", line 38, in doStash
f()
File "e:\gitwork\git-cc-dload\rebase.py", line 52, in
doStash(lambda: doCommit(cs), stash)
File "e:\gitwork\git-cc-dload\rebase.py", line 66, in doCommit
git_exec(['rebase', CI_TAG, CC_TAG])
File "e:\gitwork\git-cc-dload\common.py", line 47, in git_exec
return popen('git', cmd, GIT_DIR, *_args)
File "e:\gitwork\git-cc-dload\common.py", line 60, in popen
raise Exception((stderr + stdout).decode(ENCODING))
Exception: Cannot rebase: Your index contains uncommitted changes.
Please commit or stash them.

In a normal gitcc rebase command after performing "git add .gitcc" it would do a "git commit -m "message" then a "git rebase master_ci master_cc" and so one. In this case it is skipping the commit resulting in the index having the files represented by file1.xml and file2.xml staged but not committed.

The index and working set was clean prior to running "gitcc rebase"

Thanks for any help or insight you might have.
I'm not a python developer or I would probably try and debug it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.