# [PATCH] Fix handling of git-p4 on deleted files

4 messages from 2010-10-18 to 2010-10-22. Participants: Andrew Waters, Thomas Berg, Junio C Hamano.
Thread: https://gitlist.dev/t/25470

## Andrew Waters, 2010-10-18 15:39

Subject: [PATCH] Fix handling of git-p4 on deleted files
Message-ID: <AANLkTimzN9ZGwQZ-pi6SMWGY9KS0fjmXu=1gjdfck=W-@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimzN9ZGwQZ-pi6SMWGY9KS0fjmXu%3D1gjdfck%3DW-%40mail.gmail.com

```
When you submit changes containing deleted file the command 'p4 diff
-du ...' includes diffs for deleted files. This causes the failure:

open for read: <deleted file>: No such file or directory
Command failed: p4 diff -du ...

The problem is that perforce has been told to delete the file and then
we try to apply diffs to a file which no longer exists.

---
 contrib/fast-import/git-p4 |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index c1ea643..04ce7e3 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -706,7 +706,9 @@ class P4Submit(Command):
             submitTemplate = self.prepareLogMessage(template, logMessage)
             if os.environ.has_key("P4DIFF"):
                 del(os.environ["P4DIFF"])
-            diff = p4_read_pipe("diff -du ...")
+            diff = ""
+            for editedFile in editedFiles:
+                diff += p4_read_pipe("diff -du %r" % editedFile)

             newdiff = ""
             for newFile in filesToAdd:
-- 
1.7.2.2

```

## Thomas Berg, 2010-10-22 10:20

Subject: Re: [PATCH] Fix handling of git-p4 on deleted files
Message-ID: <AANLkTimHHbg1zVX+1L7Dwgj5VmMFdUZ5X_Vf6UK_26An@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimHHbg1zVX%2B1L7Dwgj5VmMFdUZ5X_Vf6UK_26An%40mail.gmail.com
In-Reply-To: <AANLkTimzN9ZGwQZ-pi6SMWGY9KS0fjmXu=1gjdfck=W-@mail.gmail.com>

```
Hi,

On Mon, Oct 18, 2010 at 5:39 PM, Andrew Waters <apwaters@googlemail.com> wrote:
> When you submit changes containing deleted file the command 'p4 diff
> -du ...' includes diffs for deleted files. This causes the failure:
>
> open for read: <deleted file>: No such file or directory
> Command failed: p4 diff -du ...

I'm a daily git-p4 user and noticed this problem too: 'git p4 submit'
fails for commits with deleted files, with recent Perforce verions.
The problem has been brought up earlier [1], but no patch has actually
submitted yet.

> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index c1ea643..04ce7e3 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -706,7 +706,9 @@ class P4Submit(Command):
>             submitTemplate = self.prepareLogMessage(template, logMessage)
>             if os.environ.has_key("P4DIFF"):
>                 del(os.environ["P4DIFF"])
> -            diff = p4_read_pipe("diff -du ...")
> +            diff = ""
> +            for editedFile in editedFiles:
> +                diff += p4_read_pipe("diff -du %r" % editedFile)
>
>             newdiff = ""
>             for newFile in filesToAdd:
> --

I just tested your patch, and it does indeed fix the problem. I think
you need to "sign off" on the patch, other than that I support
applying it.

Regards,
Thomas

[1] http://kerneltrap.org/mailarchive/git/2010/5/28/31299

```

## Andrew Waters, 2010-10-22 12:26

Subject: [PATCH] Fix handling of git-p4 on deleted files
Message-ID: <AANLkTikOXp7Tz3F0Of7Ua2N39Z1S22WKh0K_zJFLGa2K@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikOXp7Tz3F0Of7Ua2N39Z1S22WKh0K_zJFLGa2K%40mail.gmail.com
In-Reply-To: <AANLkTimHHbg1zVX+1L7Dwgj5VmMFdUZ5X_Vf6UK_26An@mail.gmail.com>

```
Signed-off-by: Andrew Waters <apwaters@googlemail.com>
---
 contrib/fast-import/git-p4 |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index c1ea643..04ce7e3 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -706,7 +706,9 @@ class P4Submit(Command):
             submitTemplate = self.prepareLogMessage(template, logMessage)
             if os.environ.has_key("P4DIFF"):
                 del(os.environ["P4DIFF"])
-            diff = p4_read_pipe("diff -du ...")
+            diff = ""
+            for editedFile in editedFiles:
+                diff += p4_read_pipe("diff -du %r" % editedFile)

             newdiff = ""
             for newFile in filesToAdd:
-- 
1.7.2.2


On 22 October 2010 11:20, Thomas Berg <merlin66b@gmail.com> wrote:
> Hi,
>
> On Mon, Oct 18, 2010 at 5:39 PM, Andrew Waters <apwaters@googlemail.com> wrote:
>> When you submit changes containing deleted file the command 'p4 diff
>> -du ...' includes diffs for deleted files. This causes the failure:
>>
>> open for read: <deleted file>: No such file or directory
>> Command failed: p4 diff -du ...
>
> I'm a daily git-p4 user and noticed this problem too: 'git p4 submit'
> fails for commits with deleted files, with recent Perforce verions.
> The problem has been brought up earlier [1], but no patch has actually
> submitted yet.
>
>> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
>> index c1ea643..04ce7e3 100755
>> --- a/contrib/fast-import/git-p4
>> +++ b/contrib/fast-import/git-p4
>> @@ -706,7 +706,9 @@ class P4Submit(Command):
>>             submitTemplate = self.prepareLogMessage(template, logMessage)
>>             if os.environ.has_key("P4DIFF"):
>>                 del(os.environ["P4DIFF"])
>> -            diff = p4_read_pipe("diff -du ...")
>> +            diff = ""
>> +            for editedFile in editedFiles:
>> +                diff += p4_read_pipe("diff -du %r" % editedFile)
>>
>>             newdiff = ""
>>             for newFile in filesToAdd:
>> --
>
> I just tested your patch, and it does indeed fix the problem. I think
> you need to "sign off" on the patch, other than that I support
> applying it.
>
> Regards,
> Thomas
>
> [1] http://kerneltrap.org/mailarchive/git/2010/5/28/31299
>

```

## Junio C Hamano, 2010-10-22 18:52

Subject: Re: [PATCH] Fix handling of git-p4 on deleted files
Message-ID: <7vpqv2kqkt.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vpqv2kqkt.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTikOXp7Tz3F0Of7Ua2N39Z1S22WKh0K_zJFLGa2K@mail.gmail.com>

```
Andrew Waters <apwaters@googlemail.com> writes:

> On 22 October 2010 11:20, Thomas Berg <merlin66b@gmail.com> wrote:
>> Hi,
>>
>> On Mon, Oct 18, 2010 at 5:39 PM, Andrew Waters <apwaters@googlemail.com> wrote:
>>> When you submit changes containing deleted file the command 'p4 diff
>>> -du ...' includes diffs for deleted files. This causes the failure:
>>>
>>> open for read: <deleted file>: No such file or directory
>>> Command failed: p4 diff -du ...
>>
>> I'm a daily git-p4 user and noticed this problem too: 'git p4 submit'
>> fails for commits with deleted files, with recent Perforce verions.
>> The problem has been brought up earlier [1], but no patch has actually
>> submitted yet.

Thanks for a resend.  Will queue.

> Signed-off-by: Andrew Waters <apwaters@googlemail.com>
> ---
>  contrib/fast-import/git-p4 |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index c1ea643..04ce7e3 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -706,7 +706,9 @@ class P4Submit(Command):
>              submitTemplate = self.prepareLogMessage(template, logMessage)
>              if os.environ.has_key("P4DIFF"):
>                  del(os.environ["P4DIFF"])
> -            diff = p4_read_pipe("diff -du ...")
> +            diff = ""
> +            for editedFile in editedFiles:
> +                diff += p4_read_pipe("diff -du %r" % editedFile)
>
>              newdiff = ""
>              for newFile in filesToAdd:
> -- 
> 1.7.2.2

```
