Bug 241487

Summary: [git-webkit] Incorrect common directory when not in checkout root
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: Tools / TestsAssignee: Jonathan Bedard <jbedard>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, jbedard, mcatanzaro, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Michael Catanzaro 2022-06-09 13:38:50 PDT
git-webkit has started printing strange errors related to git identifier cache. The error message is:

Failed to write identifier cache to '/home/mcatanzaro/Projects/WebKit/../.git/identifiers.json'

And it prints several times when creating a PR, e.g.:

$ git-webkit pr
'main' is not a pull request branch, enter issue URL or title of new issue: https://bugs.webkit.org/show_bug.cgi?id=241485
Switched to a new branch 'eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings'
Created the local development branch 'eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings'
branch 'main' set up to track 'origin/main'.
  Running status to find changed, added, or removed files.
  Reviewing diff to determine which lines changed.
  Extracting affected function names from source files.
  Change author: Michael Catanzaro <mcatanzaro@redhat.com>.
[eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings 56672a1fbb69] [GLib] Validate proxy URLs passed to WebKitNetworkProxySettings https://bugs.webkit.org/show_bug.cgi?id=241485
 Date: Thu Jun 9 15:36:15 2022 -0500
 2 files changed, 7 insertions(+), 2 deletions(-)
Failed to write identifier cache to '/home/mcatanzaro/Projects/WebKit/../.git/identifiers.json'
Failed to write identifier cache to '/home/mcatanzaro/Projects/WebKit/../.git/identifiers.json'
remote: Enumerating objects: 13069, done.
remote: Counting objects: 100% (11049/11049), done.
remote: Compressing objects: 100% (501/501), done.
remote: Total 13069 (delta 10670), reused 10770 (delta 10548), pack-reused 2020
Receiving objects: 100% (13069/13069), 12.52 MiB | 11.56 MiB/s, done.
Resolving deltas: 100% (11626/11626), completed with 1990 local objects.
From github.com:WebKit/WebKit
   ebe6780b9ba2..dfa403878762  main                                      -> main
 * [new tag]                   releases/Apple/Safari-13.1.3-macOS-10.15.7-Security-Update-2020-001 -> releases/Apple/Safari-13.1.3-macOS-10.15.7-Security-Update-2020-001
 * [new tag]                   releases/Apple/Safari-13.1.3-macOS-10.15.7-Security-Update-2022-004 -> releases/Apple/Safari-13.1.3-macOS-10.15.7-Security-Update-2022-004
 * [new tag]                   releases/Apple/Safari-15.5-iOS-15.5       -> releases/Apple/Safari-15.5-iOS-15.5
 * [new tag]                   releases/Apple/Safari-15.5-macOS-12.4     -> releases/Apple/Safari-15.5-macOS-12.4
 * [new tag]                   releases/Apple/Safari-8.0.3-macOS-10.10.2 -> releases/Apple/Safari-8.0.3-macOS-10.10.2
   ebe6780b9ba2..dfa403878762  main                                      -> origin/main
From github.com:WebKit/WebKit
 * branch                      main       -> FETCH_HEAD
Successfully rebased and updated refs/heads/eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings.
Failed to write identifier cache to '/home/mcatanzaro/Projects/WebKit/../.git/identifiers.json'
Rewrite c145a5031ab65973a8333d0cdc8a4deaff355cd7 (1/1) (0 seconds passed, remaining 0 predicted)    
WARNING: Ref 'refs/remotes/origin/main' is unchanged
Ref 'refs/heads/eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings' was rewritten
ERROR: Unexpected diff format when parsing a chunk: '2.36.1'
Total errors found: 0 in 2 files
Enumerating objects: 21, done.
Counting objects: 100% (21/21), done.
Delta compression using up to 32 threads
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1.18 KiB | 605.00 KiB/s, done.
Total 11 (delta 10), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (10/10), completed with 10 local objects.
remote: 
remote: Create a pull request for 'eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings' on GitHub by visiting:
remote:      https://github.com/mcatanzaro/WebKit/pull/new/eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings
remote: 
To github.com:mcatanzaro/WebKit.git
 * [new branch]                eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings -> eng/GLib-Validate-proxy-URLs-passed-to-WebKitNetworkProxySettings
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:mcatanzaro/WebKit.git
   b860f7e425a6..dfa403878762  main -> main
Failed to write identifier cache to '/home/mcatanzaro/Projects/WebKit/../.git/identifiers.json'
Failed to write identifier cache to '/home/mcatanzaro/Projects/WebKit/../.git/identifiers.json'
Created 'PR 1429 | [GLib] Validate proxy URLs passed to WebKitNetworkProxySettings'!
Assigning associated issue to Michael Catanzaro <mcatanzaro@gnome.org>
Posted pull request link to https://bugs.webkit.org/show_bug.cgi?id=241485
https://github.com/WebKit/WebKit/pull/1429
Comment 1 Alexey Proskuryakov 2022-06-13 22:44:03 PDT
What does this print?

git rev-parse --show-toplevel --git-common-dir

I'm guessing that there is a ".." there, but no idea where it would come from.
Comment 2 Michael Catanzaro 2022-06-14 05:54:49 PDT
$ git rev-parse --show-toplevel --git-common-dir
/home/mcatanzaro/Projects/WebKit
.git
Comment 3 Alexey Proskuryakov 2022-06-14 10:01:43 PDT
I don't immediately see from the code how it's possible then! It's my first time looking at this code though, so surely I'm missing something.
Comment 4 Radar WebKit Bug Importer 2022-06-16 13:39:13 PDT
<rdar://problem/95327557>
Comment 5 Jonathan Bedard 2022-06-17 15:26:58 PDT
(In reply to Michael Catanzaro from comment #2)
> $ git rev-parse --show-toplevel --git-common-dir
> /home/mcatanzaro/Projects/WebKit
> .git

Wait, how is there a newline in there? If `def common_directory(self)` in `Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py` isn't returning the right thing, that's your problem. And I think a newline from `git rev-parse --show-toplevel --git-common-dir` would be pretty unexpected
Comment 6 Jonathan Bedard 2022-06-17 15:29:07 PDT
(In reply to Jonathan Bedard from comment #5)
> (In reply to Michael Catanzaro from comment #2)
> > ...
> 
> Wait, how is there a newline in there? If `def common_directory(self)` in
> `Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py` isn't
> returning the right thing, that's your problem. And I think a newline from
> `git rev-parse --show-toplevel --git-common-dir` would be pretty unexpected

Oh, you passed two arguments to `git rev-parse`, that's why. `def common_directory` is definitely the culprit, though
Comment 7 Michael Catanzaro 2022-06-17 15:47:19 PDT
The .. seem to be based on which directory I am in:

$ pwd
/home/mcatanzaro/Projects/WebKit
$ git rev-parse --git-common-dir
.git
$ cd Source/
$ git rev-parse --git-common-dir
../.git
$ cd WebCore/
$ git rev-parse --git-common-dir
../../.git
Comment 8 Jonathan Bedard 2022-06-17 21:51:56 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1610
Comment 9 Jonathan Bedard 2022-06-17 22:00:36 PDT
`git-webkit find HEAD` should reproduce the problem as well.
Comment 10 EWS 2022-06-19 11:27:32 PDT
Committed r295662 (251667@main): <https://commits.webkit.org/251667@main>

Reviewed commits have been landed. Closing PR #1610 and removing active labels.