# git-p4 and git clone

7 messages from 2010-03-22 to 2010-04-08. Participants: Thomas Kistler, Benjamin Meyer, Tor Arvid Lund.
Thread: https://gitlist.dev/t/23146

## Thomas Kistler, 2010-03-22 23:16

Subject: git-p4 and git clone
Message-ID: <B978892CA0FBD142827E74F92AC4BBD429B2444D4D@HQMAIL03.nvidia.com>
URL: https://gitlist.dev/e/B978892CA0FBD142827E74F92AC4BBD429B2444D4D%40HQMAIL03.nvidia.com

```
I'm probably missing something fairly fundamental but I'm running into problems with cloning a git-p4 repository:

First, I'm setting up a git-p4 master repository:

    $ cd tmp1
    $ git-p4 clone //foo/bar

Then I'm cloning it through git:

    $ cd tmp2
    $ git clone tmp1/bar

Finally, I'm trying to submit back to p4:

    $ git-p4 submit

This now fails because the remotes/p4/master seems to get lost when doing the "git clone". Is this supposed to work?

-Thomas
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

```

## Benjamin Meyer, 2010-03-23 00:15

Subject: Re: git-p4 and git clone
Message-ID: <4880E32B-7880-40BF-8AFD-AC00DA457CEE@meyerhome.net>
URL: https://gitlist.dev/e/4880E32B-7880-40BF-8AFD-AC00DA457CEE%40meyerhome.net
In-Reply-To: <B978892CA0FBD142827E74F92AC4BBD429B2444D4D@HQMAIL03.nvidia.com>

```

On Mar 22, 2010, at 7:16 PM, Thomas Kistler wrote:

> I'm probably missing something fairly fundamental but I'm running into problems with cloning a git-p4 repository:
> 
> First, I'm setting up a git-p4 master repository:
> 
>    $ cd tmp1
>    $ git-p4 clone //foo/bar
> 
> Then I'm cloning it through git:
> 
>    $ cd tmp2
>    $ git clone tmp1/bar
> 
> Finally, I'm trying to submit back to p4:
> 
>    $ git-p4 submit
> 
> This now fails because the remotes/p4/master seems to get lost when doing the "git clone". Is this supposed to work?
> 
> -Thomas

There is a -import-local option you can use.  Then the p4/master branch is local and when you do the second clone you will get the p4/master branch.

-Benjamin Meyer
```

## Thomas Kistler, 2010-03-23 15:37

Subject: RE: git-p4 and git clone
Message-ID: <B978892CA0FBD142827E74F92AC4BBD429B2444D5C@HQMAIL03.nvidia.com>
URL: https://gitlist.dev/e/B978892CA0FBD142827E74F92AC4BBD429B2444D5C%40HQMAIL03.nvidia.com
In-Reply-To: <4880E32B-7880-40BF-8AFD-AC00DA457CEE@meyerhome.net>

```
That doesn't seem to work. With --import-local, I can't even submit back from the original repository.

    $ cd tmp1
    $ git-p4 clone --import-local //foo/bar
    $ cd bar
    $ git checkout p4/master
    $ git-p4 submit --verbose
    
Reading pipe: git name-rev HEAD
Reading pipe: git config git-p4.allowSubmit
Reading pipe: git rev-parse --symbolic  --remotes
Reading pipe: git cat-file commit HEAD~0
Reading pipe: git cat-file commit HEAD~1
fatal: Not a valid object name HEAD~1 


-----Original Message-----
From: Benjamin Meyer [mailto:ben@meyerhome.net] 
Sent: Monday, March 22, 2010 5:15 PM
To: Thomas Kistler
Cc: 'git@vger.kernel.org'
Subject: Re: git-p4 and git clone


On Mar 22, 2010, at 7:16 PM, Thomas Kistler wrote:

> I'm probably missing something fairly fundamental but I'm running into problems with cloning a git-p4 repository:
> 
> First, I'm setting up a git-p4 master repository:
> 
>    $ cd tmp1
>    $ git-p4 clone //foo/bar
> 
> Then I'm cloning it through git:
> 
>    $ cd tmp2
>    $ git clone tmp1/bar
> 
> Finally, I'm trying to submit back to p4:
> 
>    $ git-p4 submit
> 
> This now fails because the remotes/p4/master seems to get lost when doing the "git clone". Is this supposed to work?
> 
> -Thomas

There is a -import-local option you can use.  Then the p4/master branch is local and when you do the second clone you will get the p4/master branch.

-Benjamin Meyer
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

```

## Tor Arvid Lund, 2010-03-23 17:38

Subject: Re: git-p4 and git clone
Message-ID: <1a6be5fa1003231038h695ebbf2k8a765b4a9b6e274d@mail.gmail.com>
URL: https://gitlist.dev/e/1a6be5fa1003231038h695ebbf2k8a765b4a9b6e274d%40mail.gmail.com
In-Reply-To: <B978892CA0FBD142827E74F92AC4BBD429B2444D5C@HQMAIL03.nvidia.com>

```
On Tue, Mar 23, 2010 at 4:37 PM, Thomas Kistler <tkistler@nvidia.com> wrote:
> That doesn't seem to work. With --import-local, I can't even submit back from the original repository.

Hi.

For me it works in this scenario:
If your perforce depot is A, you "git-p4 clone --import-local" that
into B, then git clone B into C. From C you should be able to do
git-p4 submit.

So, my normal recipe (if anyones interested) is to not use B for
anything other than importing from p4 and functioning as a clone
source. Like so:

$ git-p4 clone --import-local //depot/A@all B
$ mv B/.git B.git
$ rm -rf B
$ cd B.git
$ git config core.bare true
$ rm refs/heads/master
$ echo ref: refs/heads/p4/master > HEAD

(Then I have a script that does "git-p4 sync --import-local" every so
often in this repo)

... And then on my working computer, I do:

$ git clone user@remote:B.git C
$ cd C
$ [work, work, work, git commit]
$ git-p4 submit

...And every so often:
$ git-p4 sync

(Disclaimer: recipe from memory... might not be 100% correct :-/)

-Tor Arvid-

>    $ cd tmp1
>    $ git-p4 clone --import-local //foo/bar
>    $ cd bar
>    $ git checkout p4/master
>    $ git-p4 submit --verbose
>
> Reading pipe: git name-rev HEAD
> Reading pipe: git config git-p4.allowSubmit
> Reading pipe: git rev-parse --symbolic  --remotes
> Reading pipe: git cat-file commit HEAD~0
> Reading pipe: git cat-file commit HEAD~1
> fatal: Not a valid object name HEAD~1
>
>
> -----Original Message-----
> From: Benjamin Meyer [mailto:ben@meyerhome.net]
> Sent: Monday, March 22, 2010 5:15 PM
> To: Thomas Kistler
> Cc: 'git@vger.kernel.org'
> Subject: Re: git-p4 and git clone
>
>
> On Mar 22, 2010, at 7:16 PM, Thomas Kistler wrote:
>
>> I'm probably missing something fairly fundamental but I'm running into problems with cloning a git-p4 repository:
>>
>> First, I'm setting up a git-p4 master repository:
>>
>>    $ cd tmp1
>>    $ git-p4 clone //foo/bar
>>
>> Then I'm cloning it through git:
>>
>>    $ cd tmp2
>>    $ git clone tmp1/bar
>>
>> Finally, I'm trying to submit back to p4:
>>
>>    $ git-p4 submit
>>
>> This now fails because the remotes/p4/master seems to get lost when doing the "git clone". Is this supposed to work?
>>
>> -Thomas
>
> There is a -import-local option you can use.  Then the p4/master branch is local and when you do the second clone you will get the p4/master branch.
>
> -Benjamin Meyer
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information.  Any unauthorized review, use, disclosure or distribution
> is prohibited.  If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```

## Thomas Kistler, 2010-03-23 18:02

Subject: RE: git-p4 and git clone
Message-ID: <B978892CA0FBD142827E74F92AC4BBD429B2444D66@HQMAIL03.nvidia.com>
URL: https://gitlist.dev/e/B978892CA0FBD142827E74F92AC4BBD429B2444D66%40HQMAIL03.nvidia.com
In-Reply-To: <1a6be5fa1003231038h695ebbf2k8a765b4a9b6e274d@mail.gmail.com>

```
That doesn't work for me. You can't submit from B because there are no remotes in that repository and p4BranchesInGit() is looking for remotes only.
You also cannot submit from C because the remotes are named origin/p4/master whereas p4BranchesInGit() is looking for ^p4/.

-Thomas

-----Original Message-----
From: Tor Arvid Lund [mailto:torarvid@gmail.com] 
Sent: Tuesday, March 23, 2010 10:38 AM
To: Thomas Kistler
Cc: Benjamin Meyer; git@vger.kernel.org
Subject: Re: git-p4 and git clone

On Tue, Mar 23, 2010 at 4:37 PM, Thomas Kistler <tkistler@nvidia.com> wrote:
> That doesn't seem to work. With --import-local, I can't even submit back from the original repository.

Hi.

For me it works in this scenario:
If your perforce depot is A, you "git-p4 clone --import-local" that
into B, then git clone B into C. From C you should be able to do
git-p4 submit.

So, my normal recipe (if anyones interested) is to not use B for
anything other than importing from p4 and functioning as a clone
source. Like so:

$ git-p4 clone --import-local //depot/A@all B
$ mv B/.git B.git
$ rm -rf B
$ cd B.git
$ git config core.bare true
$ rm refs/heads/master
$ echo ref: refs/heads/p4/master > HEAD

(Then I have a script that does "git-p4 sync --import-local" every so
often in this repo)

... And then on my working computer, I do:

$ git clone user@remote:B.git C
$ cd C
$ [work, work, work, git commit]
$ git-p4 submit

...And every so often:
$ git-p4 sync

(Disclaimer: recipe from memory... might not be 100% correct :-/)

-Tor Arvid-

>    $ cd tmp1
>    $ git-p4 clone --import-local //foo/bar
>    $ cd bar
>    $ git checkout p4/master
>    $ git-p4 submit --verbose
>
> Reading pipe: git name-rev HEAD
> Reading pipe: git config git-p4.allowSubmit
> Reading pipe: git rev-parse --symbolic  --remotes
> Reading pipe: git cat-file commit HEAD~0
> Reading pipe: git cat-file commit HEAD~1
> fatal: Not a valid object name HEAD~1
>
>
> -----Original Message-----
> From: Benjamin Meyer [mailto:ben@meyerhome.net]
> Sent: Monday, March 22, 2010 5:15 PM
> To: Thomas Kistler
> Cc: 'git@vger.kernel.org'
> Subject: Re: git-p4 and git clone
>
>
> On Mar 22, 2010, at 7:16 PM, Thomas Kistler wrote:
>
>> I'm probably missing something fairly fundamental but I'm running into problems with cloning a git-p4 repository:
>>
>> First, I'm setting up a git-p4 master repository:
>>
>>    $ cd tmp1
>>    $ git-p4 clone //foo/bar
>>
>> Then I'm cloning it through git:
>>
>>    $ cd tmp2
>>    $ git clone tmp1/bar
>>
>> Finally, I'm trying to submit back to p4:
>>
>>    $ git-p4 submit
>>
>> This now fails because the remotes/p4/master seems to get lost when doing the "git clone". Is this supposed to work?
>>
>> -Thomas
>
> There is a -import-local option you can use.  Then the p4/master branch is local and when you do the second clone you will get the p4/master branch.
>
> -Benjamin Meyer
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information.  Any unauthorized review, use, disclosure or distribution
> is prohibited.  If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```

## Tor Arvid Lund, 2010-03-23 18:11

Subject: Re: git-p4 and git clone
Message-ID: <1a6be5fa1003231111pc98bfbbg299ea0f95a7926a7@mail.gmail.com>
URL: https://gitlist.dev/e/1a6be5fa1003231111pc98bfbbg299ea0f95a7926a7%40mail.gmail.com
In-Reply-To: <B978892CA0FBD142827E74F92AC4BBD429B2444D66@HQMAIL03.nvidia.com>

```
On Tue, Mar 23, 2010 at 7:02 PM, Thomas Kistler <tkistler@nvidia.com> wrote:
> That doesn't work for me. You can't submit from B because there are no remotes in that repository and p4BranchesInGit() is looking for remotes only.
> You also cannot submit from C because the remotes are named origin/p4/master whereas p4BranchesInGit() is looking for ^p4/.

Hmm, ok. Submitting from B doesn't work for me either, as I said in my
previous mail... Tried my recipe now. I get the same problem with C.
The "solution" I found was to run a "git-p4 sync" from C. Then git-p4
will create remotes/p4/master in addition to remotes/origin/*. Then it
worked for me.

-Tor Arvid-

> -Thomas
>
> -----Original Message-----
> From: Tor Arvid Lund [mailto:torarvid@gmail.com]
> Sent: Tuesday, March 23, 2010 10:38 AM
> To: Thomas Kistler
> Cc: Benjamin Meyer; git@vger.kernel.org
> Subject: Re: git-p4 and git clone
>
> On Tue, Mar 23, 2010 at 4:37 PM, Thomas Kistler <tkistler@nvidia.com> wrote:
>> That doesn't seem to work. With --import-local, I can't even submit back from the original repository.
>
> Hi.
>
> For me it works in this scenario:
> If your perforce depot is A, you "git-p4 clone --import-local" that
> into B, then git clone B into C. From C you should be able to do
> git-p4 submit.
>
> So, my normal recipe (if anyones interested) is to not use B for
> anything other than importing from p4 and functioning as a clone
> source. Like so:
>
> $ git-p4 clone --import-local //depot/A@all B
> $ mv B/.git B.git
> $ rm -rf B
> $ cd B.git
> $ git config core.bare true
> $ rm refs/heads/master
> $ echo ref: refs/heads/p4/master > HEAD
>
> (Then I have a script that does "git-p4 sync --import-local" every so
> often in this repo)
>
> ... And then on my working computer, I do:
>
> $ git clone user@remote:B.git C
> $ cd C
> $ [work, work, work, git commit]
> $ git-p4 submit
>
> ...And every so often:
> $ git-p4 sync
>
> (Disclaimer: recipe from memory... might not be 100% correct :-/)
>
> -Tor Arvid-
>
>>    $ cd tmp1
>>    $ git-p4 clone --import-local //foo/bar
>>    $ cd bar
>>    $ git checkout p4/master
>>    $ git-p4 submit --verbose
>>
>> Reading pipe: git name-rev HEAD
>> Reading pipe: git config git-p4.allowSubmit
>> Reading pipe: git rev-parse --symbolic  --remotes
>> Reading pipe: git cat-file commit HEAD~0
>> Reading pipe: git cat-file commit HEAD~1
>> fatal: Not a valid object name HEAD~1
>>
>>
>> -----Original Message-----
>> From: Benjamin Meyer [mailto:ben@meyerhome.net]
>> Sent: Monday, March 22, 2010 5:15 PM
>> To: Thomas Kistler
>> Cc: 'git@vger.kernel.org'
>> Subject: Re: git-p4 and git clone
>>
>>
>> On Mar 22, 2010, at 7:16 PM, Thomas Kistler wrote:
>>
>>> I'm probably missing something fairly fundamental but I'm running into problems with cloning a git-p4 repository:
>>>
>>> First, I'm setting up a git-p4 master repository:
>>>
>>>    $ cd tmp1
>>>    $ git-p4 clone //foo/bar
>>>
>>> Then I'm cloning it through git:
>>>
>>>    $ cd tmp2
>>>    $ git clone tmp1/bar
>>>
>>> Finally, I'm trying to submit back to p4:
>>>
>>>    $ git-p4 submit
>>>
>>> This now fails because the remotes/p4/master seems to get lost when doing the "git clone". Is this supposed to work?
>>>
>>> -Thomas
>>
>> There is a -import-local option you can use.  Then the p4/master branch is local and when you do the second clone you will get the p4/master branch.
>>
>> -Benjamin Meyer
>> -----------------------------------------------------------------------------------
>> This email message is for the sole use of the intended recipient(s) and may contain
>> confidential information.  Any unauthorized review, use, disclosure or distribution
>> is prohibited.  If you are not the intended recipient, please contact the sender by
>> reply email and destroy all copies of the original message.
>> -----------------------------------------------------------------------------------
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>

```

## Thomas Kistler, 2010-04-08 15:55

Subject: cherry pick into remote / git-p4
Message-ID: <B978892CA0FBD142827E74F92AC4BBD429B5EDD0BC@HQMAIL03.nvidia.com>
URL: https://gitlist.dev/e/B978892CA0FBD142827E74F92AC4BBD429B5EDD0BC%40HQMAIL03.nvidia.com
In-Reply-To: <1a6be5fa1003231111pc98bfbbg299ea0f95a7926a7@mail.gmail.com>

```
Before doing a lot of work I wanted to see whether someone has a simple solution to cherry pick a particular commit into a remote branch (and by that I mean the refs/remote branch in the local repository and not the remote repository).

Here is some more background. In our setup, we periodically bunch git changes up and submit them back to an external perforce repository (using a modified version of git-p4). When those changes come back into the git repository (using git-p4 sync) we see the combined changes rather than the individual ones, which can lead to rebase conflicts. So rather than importing the combined changes, we'd like to replay the individual changes from the master branch if present (we store the git commit ids as part of our perforce commit message so we know which ids to replay). But there doesn't seem to be an easy way to do that.

-Thomas 

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

```
