# BUG on OSX `git p4 submit` can fail when the workspace root doesn't exist locally.

5 messages from 2016-04-27 to 2016-04-28. Participants: Jacob Smith, Stefan Beller, Luke Diamand.
Thread: https://gitlist.dev/t/42156

## Jacob Smith, 2016-04-27 16:15

Subject: BUG on OSX `git p4 submit` can fail when the workspace root doesn't exist locally.
Message-ID: <CAMsgv2UXPkxpocjKhoR7HbmubSBnhJPJ3hMq9Jsk2AD0DoCifA@mail.gmail.com>
URL: https://gitlist.dev/e/CAMsgv2UXPkxpocjKhoR7HbmubSBnhJPJ3hMq9Jsk2AD0DoCifA%40mail.gmail.com

```
On OS X, if the local p4 workspace root doesn't exist, then git-p4 can
fail on submit. The error message looks like this:

    Synchronizing p4 checkout...

    Git submit failed!
    shell-init: error retrieving current directory: getcwd: cannot
access parent directories: No such file or directory
    fatal: Unable to read current working directory: No such file or directory
    Command failed: ['git', 'rev-list', '--no-merges',
'remotes/p4/master..master']

The problem is in the function 'run()' around line 1957. The logic in
the code is:

    1. Detect if the clientPath exists;
    2. If the clientPath doesn't exist, set the 'new_client_dir'
variable to 'True';
    3. chdir() to the clientPath; then,
    4. If 'new_client_dir' is 'True', then p4_sync("...", True).

On my system, the call to `p4 sync -f` leaves the clientPath directory
that git-p4 had chdir()'d into an orphan, so the call to 'git rev-list
...' a few lines fails because the call to getcwd() fails (the
directory has no parents).

I can make the problem "go away" by moving the location of the call to
'chdir(self.clientPath, is_client_path=True)' after the call to
`p4_sync()`, but I'm not sure if that's really fixing the issue, or
not.

Thanks!
-j.

```

## Stefan Beller, 2016-04-27 16:28

Subject: Re: BUG on OSX `git p4 submit` can fail when the workspace root doesn't exist locally.
Message-ID: <CAGZ79kZ6rx4UpPmeGjC8TyHKbVd+Y6i1JyEdDzKuF_9rj4c_7g@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kZ6rx4UpPmeGjC8TyHKbVd%2BY6i1JyEdDzKuF_9rj4c_7g%40mail.gmail.com
In-Reply-To: <CAMsgv2UXPkxpocjKhoR7HbmubSBnhJPJ3hMq9Jsk2AD0DoCifA@mail.gmail.com>

```
On Wed, Apr 27, 2016 at 9:15 AM, Jacob Smith <jaroslov@gmail.com> wrote:
> On OS X,

Do you use the Git as provided from OS X? In that case you better report the bug
to Apple, as their version of Git is slightly different (not close on
upstream, by both
having additional patches as well as not following the upstream closely IIUC).

```

## Jacob Smith, 2016-04-27 18:06

Subject: Re: BUG on OSX `git p4 submit` can fail when the workspace root doesn't exist locally.
Message-ID: <CAMsgv2W7mtJpFf6A4MZs-Sbvdof8EdOOP+uiGYudH8LUjNRo8g@mail.gmail.com>
URL: https://gitlist.dev/e/CAMsgv2W7mtJpFf6A4MZs-Sbvdof8EdOOP%2BuiGYudH8LUjNRo8g%40mail.gmail.com
In-Reply-To: <CAGZ79kZ6rx4UpPmeGjC8TyHKbVd+Y6i1JyEdDzKuF_9rj4c_7g@mail.gmail.com>

```
I debugged the issue using the script here:
    https://github.com/git/git/blob/master/git-p4.py
I'm not sure how close to the main repo that is.

On Wed, Apr 27, 2016 at 11:28 AM, Stefan Beller <sbeller@google.com> wrote:
> On Wed, Apr 27, 2016 at 9:15 AM, Jacob Smith <jaroslov@gmail.com> wrote:
>> On OS X,
>
> Do you use the Git as provided from OS X? In that case you better report the bug
> to Apple, as their version of Git is slightly different (not close on
> upstream, by both
> having additional patches as well as not following the upstream closely IIUC).

```

## Stefan Beller, 2016-04-27 20:53

Subject: Re: BUG on OSX `git p4 submit` can fail when the workspace root doesn't exist locally.
Message-ID: <CAGZ79kZX5H8ddhZQa4r9SPyhAYo=o6gBae3oPCYQ6iNtxXq1Cg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kZX5H8ddhZQa4r9SPyhAYo%3Do6gBae3oPCYQ6iNtxXq1Cg%40mail.gmail.com
In-Reply-To: <CAMsgv2W7mtJpFf6A4MZs-Sbvdof8EdOOP+uiGYudH8LUjNRo8g@mail.gmail.com>

```
On Wed, Apr 27, 2016 at 11:06 AM, Jacob Smith <jaroslov@gmail.com> wrote:
> I debugged the issue using the script here:
>     https://github.com/git/git/blob/master/git-p4.py
> I'm not sure how close to the main repo that is.
>
> On Wed, Apr 27, 2016 at 11:28 AM, Stefan Beller <sbeller@google.com> wrote:
>> On Wed, Apr 27, 2016 at 9:15 AM, Jacob Smith <jaroslov@gmail.com> wrote:
>>> On OS X,
>>
>> Do you use the Git as provided from OS X? In that case you better report the bug
>> to Apple, as their version of Git is slightly different (not close on
>> upstream, by both
>> having additional patches as well as not following the upstream closely IIUC).

In that case, I have cc'd Luke and Lars, who work on p4

```

## Luke Diamand, 2016-04-28 07:36

Subject: Re: BUG on OSX `git p4 submit` can fail when the workspace root doesn't exist locally.
Message-ID: <CAE5ih78eGJN2kUjxfhUiKTAMK5rbTGZ-SFp405w2XRL6BDvwHQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAE5ih78eGJN2kUjxfhUiKTAMK5rbTGZ-SFp405w2XRL6BDvwHQ%40mail.gmail.com
In-Reply-To: <CAGZ79kZX5H8ddhZQa4r9SPyhAYo=o6gBae3oPCYQ6iNtxXq1Cg@mail.gmail.com>

```
On 27 April 2016 at 21:53, Stefan Beller <sbeller@google.com> wrote:
> On Wed, Apr 27, 2016 at 11:06 AM, Jacob Smith <jaroslov@gmail.com> wrote:
>> I debugged the issue using the script here:
>>     https://github.com/git/git/blob/master/git-p4.py
>> I'm not sure how close to the main repo that is.
>>
>> On Wed, Apr 27, 2016 at 11:28 AM, Stefan Beller <sbeller@google.com> wrote:
>>> On Wed, Apr 27, 2016 at 9:15 AM, Jacob Smith <jaroslov@gmail.com> wrote:
>>>> On OS X,
>>>
>>> Do you use the Git as provided from OS X? In that case you better report the bug
>>> to Apple, as their version of Git is slightly different (not close on
>>> upstream, by both
>>> having additional patches as well as not following the upstream closely IIUC).
>
> In that case, I have cc'd Luke and Lars, who work on p4

Which version of p4 are you using?

Your suggested fix looks plausible though. Possibly it needs both
chdirs() so that "p4 sync" will work if the caller is using a
.p4config file in the p4 client directory to set the P4CLIENT.

Thanks!
Luke

```
