All of lore.kernel.org
 help / color / mirror / Atom feed
* git to p4 conversion
@ 2011-02-03 13:52 Endre Czirbesz
  2011-02-03 18:23 ` Ian Wienand
  0 siblings, 1 reply; 14+ messages in thread
From: Endre Czirbesz @ 2011-02-03 13:52 UTC (permalink / raw)
  To: git

Hi,

My company is introducing perforce, and the policy is that all source
codes should be kept there.

I have some small (and flat) git repos, which I would like to migrate
into a perforce depot keeping their histories. I tried git-p4 without
any success, and I did not find a good manual for it.

Is there any step-by-step tutorial out there? Is there any living human
who ever made a successful conversion in this direction?

Thanks for your help in advance.

Endre Czirbesz

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-03 13:52 git to p4 conversion Endre Czirbesz
@ 2011-02-03 18:23 ` Ian Wienand
  2011-02-03 19:50   ` Endre Czirbesz
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Wienand @ 2011-02-03 18:23 UTC (permalink / raw)
  To: Endre Czirbesz; +Cc: git

On 03/02/11 05:52, Endre Czirbesz wrote:
> I have some small (and flat) git repos, which I would like to migrate
> into a perforce depot keeping their histories. I tried git-p4 without
> any success, and I did not find a good manual for it.

What exactly did you try?

Theoretically, you could clone your new, empty, company-mandated p4
tree into a fresh git repo, get your existing code onto a new branch
in this fresh repo (it's already in git, right, so that should be
easy), then use 'git-p4 submit' to submit that branch back to p4.

> Is there any step-by-step tutorial out there? Is there any living human
> who ever made a successful conversion in this direction?

I'm not aware of an existing tutorial for this, sorry

-i

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-03 18:23 ` Ian Wienand
@ 2011-02-03 19:50   ` Endre Czirbesz
  2011-02-04  0:03     ` Vitor Antunes
  0 siblings, 1 reply; 14+ messages in thread
From: Endre Czirbesz @ 2011-02-03 19:50 UTC (permalink / raw)
  To: Ian Wienand; +Cc: git

Hello Ian,

Thanks for your reply.

2011/2/3 Ian Wienand <ianw@vmware.com>:
> What exactly did you try?
I am not at my work computer now, but as I remember:

cd workdir
git-p4 clone //depot/projectdir/...@all .
git clone myprojectrepo .

(Everything went fine till this point.)

git-p4 sync
git-p4 submit
Fatal error...

I don't remember the exact message, but it tried to reach a
non-existing git commit (HEAD~xx, where xx was count of my commits, so
it tried to refer to a commit before my initial commit).
I tried to change the order of the clone steps, but the result was the same.

Rgds,

Endre

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-03 19:50   ` Endre Czirbesz
@ 2011-02-04  0:03     ` Vitor Antunes
  2011-02-04  9:25       ` Tor Arvid Lund
  0 siblings, 1 reply; 14+ messages in thread
From: Vitor Antunes @ 2011-02-04  0:03 UTC (permalink / raw)
  To: git

Hi Endre,

Endre Czirbesz <endre <at> czirbesz.hu> writes:

> 
> Hello Ian,
> 
> Thanks for your reply.
> 
> 2011/2/3 Ian Wienand <ianw <at> vmware.com>:
> > What exactly did you try?
> I am not at my work computer now, but as I remember:
> 
> cd workdir
> git-p4 clone //depot/projectdir/...@all .
> git clone myprojectrepo .

I think what you should do is add the git repository as a remote with something
like:

git remote add remotename myprojectrepo
git pull remotename master
git p4 submit

Hope this helps,
Vitor

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-04  0:03     ` Vitor Antunes
@ 2011-02-04  9:25       ` Tor Arvid Lund
  2011-02-04 10:49         ` Endre Czirbesz
  0 siblings, 1 reply; 14+ messages in thread
From: Tor Arvid Lund @ 2011-02-04  9:25 UTC (permalink / raw)
  To: Vitor Antunes; +Cc: git, Endre Czirbesz, Ian Wienand

[on this mailing list, please don't cull the CC list]

On Fri, Feb 4, 2011 at 1:03 AM, Vitor Antunes <vitor.hda@gmail.com> wrote:
> Hi Endre,
>
<snip>
> I think what you should do is add the git repository as a remote with something
> like:
>
> git remote add remotename myprojectrepo
> git pull remotename master
> git p4 submit

That's not what I would do... When I try this, the 'git pull ...'
creates a merge, which I don't want to do when using git-p4.

But I think we're close to something that would work ok:

Endre, you should start like you already have; by git-p4 cloning your
project from perforce. (You maybe want to have a dummy file checked in
to your <projectdir> in perforce, so that the 'git-p4 clone' command
produces at least one commit in your git repo)...

Then, do 'git remote add tempremote <path-to-your-existing-git-repo>'
like Vitor suggests.

At this point I would do:

$ git checkout -b tempbranch tempremote/master
$ git rebase master
$ git-p4 submit

So, the 'git rebase master' should be like applying each of your
existing git commits *on-top-of* the git-p4 branch that you already
have. And that is the key to git-p4 knowing what to push to the
perforce server.

Thus, if I wanted to get all my existing git history into perforce,
this is how I would do it.

    -- Tor Arvid

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-04  9:25       ` Tor Arvid Lund
@ 2011-02-04 10:49         ` Endre Czirbesz
  2011-02-04 14:01           ` Tor Arvid Lund
  0 siblings, 1 reply; 14+ messages in thread
From: Endre Czirbesz @ 2011-02-04 10:49 UTC (permalink / raw)
  To: Tor Arvid Lund; +Cc: Vitor Antunes, git, Ian Wienand

Hi All,

Thanks for the replies.

2011/2/4 Tor Arvid Lund <torarvid@gmail.com>:
> On Fri, Feb 4, 2011 at 1:03 AM, Vitor Antunes <vitor.hda@gmail.com> wrote:
>> git remote add remotename myprojectrepo

> Endre, you should start like you already have; by git-p4 cloning your
> project from perforce. (You maybe want to have a dummy file checked in
> to your <projectdir> in perforce, so that the 'git-p4 clone' command
> produces at least one commit in your git repo)...
>
> Then, do 'git remote add tempremote <path-to-your-existing-git-repo>'
> like Vitor suggests.
>
> At this point I would do:
>
> $ git checkout -b tempbranch tempremote/master
At this point I got an error message:
fatal: git checkout: updating paths is incompatible with switching branches.

So I fetched my tempremote first:
$ git fetch tempremote
$ git checkout -b tempbranch tempremote/master
(I got a warning from fetch, that there are no common commits, but I
supposed that it is right. :) )

> $ git rebase master
It applied all my commits.

> $ git-p4 submit
  Synchronizing p4 checkout...
  ... - file(s) up-to-date.
  Applying 1##############################9 Initial commit
  error: ***: already exists in working directory
[...]
  Unfortunately applying the change failed!

It said this error for all my files. :(
But I think we are almost there. :)

Regards,

Endre

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-04 10:49         ` Endre Czirbesz
@ 2011-02-04 14:01           ` Tor Arvid Lund
  2011-02-04 16:08             ` Endre Czirbesz
  0 siblings, 1 reply; 14+ messages in thread
From: Tor Arvid Lund @ 2011-02-04 14:01 UTC (permalink / raw)
  To: Endre Czirbesz; +Cc: Vitor Antunes, git, Ian Wienand

On Fri, Feb 4, 2011 at 11:49 AM, Endre Czirbesz <endre@czirbesz.hu> wrote:
> Hi All,
>
> Thanks for the replies.
>
> 2011/2/4 Tor Arvid Lund <torarvid@gmail.com>:
>> On Fri, Feb 4, 2011 at 1:03 AM, Vitor Antunes <vitor.hda@gmail.com> wrote:
>>> git remote add remotename myprojectrepo
>
>> Endre, you should start like you already have; by git-p4 cloning your
>> project from perforce. (You maybe want to have a dummy file checked in
>> to your <projectdir> in perforce, so that the 'git-p4 clone' command
>> produces at least one commit in your git repo)...
>>
>> Then, do 'git remote add tempremote <path-to-your-existing-git-repo>'
>> like Vitor suggests.
>>
>> At this point I would do:
>>
>> $ git checkout -b tempbranch tempremote/master
> At this point I got an error message:
> fatal: git checkout: updating paths is incompatible with switching branches.
>
> So I fetched my tempremote first:
> $ git fetch tempremote
> $ git checkout -b tempbranch tempremote/master

See, this is what happens when I write a "how-to" and not actually try
it out before sending it... Obviously, you are correct in that you
have to fetch it before being able to check it out :-)

> (I got a warning from fetch, that there are no common commits, but I
> supposed that it is right. :) )

That is correct.

>> $ git rebase master
> It applied all my commits.
>
>> $ git-p4 submit
>  Synchronizing p4 checkout...
>  ... - file(s) up-to-date.
>  Applying 1##############################9 Initial commit
>  error: ***: already exists in working directory
> [...]
>  Unfortunately applying the change failed!
>
> It said this error for all my files. :(
> But I think we are almost there. :)

Again, if only I'd tried it myself first! ;)

Well, I can get it to work if I do:
$ git p4 sync

before the 'git p4 submit'.

Try that, and see if it works for you. (BTW, when committing
half-works, and then fails, oftentimes you need to do a bit of cleanup
in perforce... Revert files, manually remove files created by git
inside your p4 clientspec root directory, that sort of thing...)

    -- Tor Arvid

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-04 14:01           ` Tor Arvid Lund
@ 2011-02-04 16:08             ` Endre Czirbesz
       [not found]               ` <AANLkTimGaPQ=hRp+2pvw-hAOg+wp50nvc_sv9jNTay=n@mail.gmail.com>
  0 siblings, 1 reply; 14+ messages in thread
From: Endre Czirbesz @ 2011-02-04 16:08 UTC (permalink / raw)
  To: Tor Arvid Lund; +Cc: Vitor Antunes, git, Ian Wienand

2011/2/4 Tor Arvid Lund <torarvid@gmail.com>:
> Well, I can get it to work if I do:
> $ git p4 sync
>
> before the 'git p4 submit'.
Same result. :(

My current workflow is:

$ rm -rf projdir
$ git-p4 clone //depot/projdir/...@all
$ cd projdir
$ git remote add gitremote endre@gitserver/gitrepo.git
$ git fetch -q gitremote
$ git checkout -b tempbranch gitremote/master
$ git rebase -q master
$ git-p4 sync
$ git-p4 submit

The result is still tons of file already exists in working directory messages.

> Try that, and see if it works for you. (BTW, when committing
> half-works, and then fails, oftentimes you need to do a bit of cleanup
> in perforce... Revert files, manually remove files created by git
> inside your p4 clientspec root directory, that sort of thing...)

I dropped the whole directory, and then recreated it, I do not know
any better 'cleanup'. :)

Rgds,

Endre

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
       [not found]               ` <AANLkTimGaPQ=hRp+2pvw-hAOg+wp50nvc_sv9jNTay=n@mail.gmail.com>
@ 2011-02-04 16:52                 ` Endre Czirbesz
  2011-02-05  0:53                   ` Tor Arvid Lund
  0 siblings, 1 reply; 14+ messages in thread
From: Endre Czirbesz @ 2011-02-04 16:52 UTC (permalink / raw)
  To: Vitor Antunes; +Cc: git, Ian Wienand, Tor Arvid Lund

Hi Vitor,

2011/2/4 Vitor Antunes <vitor.hda@gmail.com>:
>> I dropped the whole directory, and then recreated it, I do not know
>> any better 'cleanup'. :)
>
> Which directory did you drop? Was is the git repository or the P4 workspace?
> You need to clean up the later. Basically, a "rm -rf
> path/to/p4_workspace" and a "p4 sync -f" should do the trick :)

It is almost the same in my case. :)
My p4 client root is ~/work/, my project dir is ~/work/projdir (and at
the moment this is the only directory within ~/work/), and I dropped
the latter.
And then it was created again by git-p4 clone.

I can drop the workspace root, but I do not think it would help.

Regards,

Endre

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-04 16:52                 ` Endre Czirbesz
@ 2011-02-05  0:53                   ` Tor Arvid Lund
  2011-02-05  1:11                     ` Vitor Antunes
  0 siblings, 1 reply; 14+ messages in thread
From: Tor Arvid Lund @ 2011-02-05  0:53 UTC (permalink / raw)
  To: Endre Czirbesz; +Cc: Vitor Antunes, git, Ian Wienand

On Fri, Feb 4, 2011 at 5:52 PM, Endre Czirbesz <endre@czirbesz.hu> wrote:
> Hi Vitor,
>
> 2011/2/4 Vitor Antunes <vitor.hda@gmail.com>:
>>> I dropped the whole directory, and then recreated it, I do not know
>>> any better 'cleanup'. :)
>>
>> Which directory did you drop? Was is the git repository or the P4 workspace?
>> You need to clean up the later. Basically, a "rm -rf
>> path/to/p4_workspace" and a "p4 sync -f" should do the trick :)
>
> It is almost the same in my case. :)
> My p4 client root is ~/work/, my project dir is ~/work/projdir (and at
> the moment this is the only directory within ~/work/), and I dropped
> the latter.
> And then it was created again by git-p4 clone.

I... wonder if we're maybe talking past one another here...

Let's take a few things from the top, just in case... If we think
about the perforce setup (before we start doing any git stuff)... You
have a perforce workspace/client-spec, right? That is - a setup that
tells perforce where you want the files to be placed on your hard
drive when you do a standard "p4 sync". Let's call it ~/p4root/ and
let us say that your project will then be synced by perforce to
~/p4root/myproj/

When you want to do a git-p4 clone, you should definitely be *outside*
of ~/p4root/ . Let's say we have a ~/gitroot/ as well. So do cd
~/gitroot/ so that the git-p4 clone will be under ~/gitroot/myproj/ ;
and then do all the git-p4 stuff (clone, add remote, fetch, rebase,
sync, submit).

I think Vitors point was that before you do git-p4 submit, you should
clean - not ~/gitroot/myproj - but ~/p4root/myproj/.

This is probably not something that you need to do everytime you want
to submit back to perforce, but since we have had some rounds with
trial-and-error with this, we have probably placed some dirty files
inside the perforce folders... Make sure that you don't have files
opened in perforce before you sync.

Clearer? More confused? Best of luck anyway :)

    -- Tor Arvid

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-05  0:53                   ` Tor Arvid Lund
@ 2011-02-05  1:11                     ` Vitor Antunes
  2011-02-07 13:57                       ` Endre Czirbesz
  0 siblings, 1 reply; 14+ messages in thread
From: Vitor Antunes @ 2011-02-05  1:11 UTC (permalink / raw)
  To: Tor Arvid Lund; +Cc: Endre Czirbesz, git, Ian Wienand

Hi Tor,

On Sat, Feb 5, 2011 at 12:53 AM, Tor Arvid Lund <torarvid@gmail.com> wrote:
> I... wonder if we're maybe talking past one another here...
>
> Let's take a few things from the top, just in case... If we think
> about the perforce setup (before we start doing any git stuff)... You
> have a perforce workspace/client-spec, right? That is - a setup that
> tells perforce where you want the files to be placed on your hard
> drive when you do a standard "p4 sync". Let's call it ~/p4root/ and
> let us say that your project will then be synced by perforce to
> ~/p4root/myproj/
>
> When you want to do a git-p4 clone, you should definitely be *outside*
> of ~/p4root/ . Let's say we have a ~/gitroot/ as well. So do cd
> ~/gitroot/ so that the git-p4 clone will be under ~/gitroot/myproj/ ;
> and then do all the git-p4 stuff (clone, add remote, fetch, rebase,
> sync, submit).
>
> I think Vitors point was that before you do git-p4 submit, you should
> clean - not ~/gitroot/myproj - but ~/p4root/myproj/.
>
> This is probably not something that you need to do everytime you want
> to submit back to perforce, but since we have had some rounds with
> trial-and-error with this, we have probably placed some dirty files
> inside the perforce folders... Make sure that you don't have files
> opened in perforce before you sync.
>
> Clearer? More confused? Best of luck anyway :)
>
>    -- Tor Arvid
>

Yeah, I think we're in sync here. I'm almost sure your (much more
detailed) instructions will solve Endre's problem :)

Kind regards,
-- 
Vitor Antunes

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-05  1:11                     ` Vitor Antunes
@ 2011-02-07 13:57                       ` Endre Czirbesz
  2011-02-07 14:13                         ` Tor Arvid Lund
  0 siblings, 1 reply; 14+ messages in thread
From: Endre Czirbesz @ 2011-02-07 13:57 UTC (permalink / raw)
  To: Vitor Antunes; +Cc: Tor Arvid Lund, git, Ian Wienand

Hi,

Thanks for your patience and the detailed help.
I forgot only one thing, that I need two separate directories... :)

So, after some minor mods in git-p4 (I have some directories with
spaces, and some files with #@*% in their names), it seems as if it
worked, my files are in P4 depot, although I got an error message:

Failed to merge in the changes.
Patch failed at 0001 Initial commit

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

Exception: command failed: git rebase remotes/p4/master

Regards,

Endre

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-07 13:57                       ` Endre Czirbesz
@ 2011-02-07 14:13                         ` Tor Arvid Lund
  2011-02-07 15:07                           ` Endre Czirbesz
  0 siblings, 1 reply; 14+ messages in thread
From: Tor Arvid Lund @ 2011-02-07 14:13 UTC (permalink / raw)
  To: Endre Czirbesz; +Cc: Vitor Antunes, git, Ian Wienand

On Mon, Feb 7, 2011 at 2:57 PM, Endre Czirbesz <endre@czirbesz.hu> wrote:
> Hi,
>
> Thanks for your patience and the detailed help.
> I forgot only one thing, that I need two separate directories... :)
>
> So, after some minor mods in git-p4 (I have some directories with
> spaces, and some files with #@*% in their names), it seems as if it
> worked, my files are in P4 depot, although I got an error message:
>
> Failed to merge in the changes.
> Patch failed at 0001 Initial commit
>
> When you have resolved this problem run "git rebase --continue".
> If you would prefer to skip this patch, instead run "git rebase --skip".
> To restore the original branch and stop rebasing run "git rebase --abort".
>
> Exception: command failed: git rebase remotes/p4/master

Maybe you could run "git p4 submit --verbose"? (the 'verbose' option
might give you a clue as to what the underlying problem is)

    -- Tor Arvid

> Regards,
>
> Endre
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: git to p4 conversion
  2011-02-07 14:13                         ` Tor Arvid Lund
@ 2011-02-07 15:07                           ` Endre Czirbesz
  0 siblings, 0 replies; 14+ messages in thread
From: Endre Czirbesz @ 2011-02-07 15:07 UTC (permalink / raw)
  To: Tor Arvid Lund; +Cc: Vitor Antunes, git, Ian Wienand

2011/2/7 Tor Arvid Lund <torarvid@gmail.com>:
> Maybe you could run "git p4 submit --verbose"? (the 'verbose' option
> might give you a clue as to what the underlying problem is)
I did that actually, just did not want to send the whole output. :)

I will investigate it further, but my boss gave a new highest priority
task for me... :(

Endre

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-02-07 15:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-03 13:52 git to p4 conversion Endre Czirbesz
2011-02-03 18:23 ` Ian Wienand
2011-02-03 19:50   ` Endre Czirbesz
2011-02-04  0:03     ` Vitor Antunes
2011-02-04  9:25       ` Tor Arvid Lund
2011-02-04 10:49         ` Endre Czirbesz
2011-02-04 14:01           ` Tor Arvid Lund
2011-02-04 16:08             ` Endre Czirbesz
     [not found]               ` <AANLkTimGaPQ=hRp+2pvw-hAOg+wp50nvc_sv9jNTay=n@mail.gmail.com>
2011-02-04 16:52                 ` Endre Czirbesz
2011-02-05  0:53                   ` Tor Arvid Lund
2011-02-05  1:11                     ` Vitor Antunes
2011-02-07 13:57                       ` Endre Czirbesz
2011-02-07 14:13                         ` Tor Arvid Lund
2011-02-07 15:07                           ` Endre Czirbesz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.