mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:13:01 +00:00
1b3f6d8f9e
History:
* Back in (pre June) 2018 worktrees in git just worked.
* https://dart-review.googlesource.com/c/sdk/+/48091 made it not work.
* https://github.com/dart-lang/sdk/issues/33619 was filed.
* https://dart-review.googlesource.com/c/sdk/+/127485 was created to
work around the problem.
I don't know when it happened, but I can't make the above workaround
work (at least not anymore) --- adding a `default_git_folder` to my
`args.gn` has no effect.
This CL builds on it and automatically sets the correct path based on
a call to `git rev-parse --resolve-git-dir .git` which gives the
correct dir for both worktrees and non-worktrees.
This is the 2nd try which should also work on Windows.
The original CL is in patchset #1.
This reverts commit 7e2cc73da8
.
Change-Id: I298aef8ac9095ce3ef4f827218675584b68a02c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191362
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
49 lines
1.5 KiB
Python
Executable file
49 lines
1.5 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
#
|
|
# This python script is a wrapper around `git rev-parse --resolve-git-dir`.
|
|
# This is used for the build system to work with git worktrees.
|
|
|
|
import sys
|
|
import subprocess
|
|
import os
|
|
import utils
|
|
|
|
|
|
def main():
|
|
try:
|
|
if len(sys.argv) != 2:
|
|
raise Exception('Expects exactly 1 argument.')
|
|
|
|
args = ['git', 'rev-parse', '--resolve-git-dir', sys.argv[1]]
|
|
|
|
windows = utils.GuessOS() == 'win32'
|
|
if windows:
|
|
process = subprocess.Popen(args,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
stdin=subprocess.PIPE,
|
|
shell=True)
|
|
else:
|
|
process = subprocess.Popen(args,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
stdin=subprocess.PIPE,
|
|
shell=False)
|
|
|
|
outs, _ = process.communicate()
|
|
|
|
if process.returncode != 0:
|
|
raise Exception('Got non-0 exit code from git.')
|
|
|
|
print(outs.strip())
|
|
except:
|
|
# Fall-back to ".git".
|
|
print(".git")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|