]> granicus.if.org Git - python/commitdiff
bpo-29798: Handle git worktree in `make patchcheck` (#629) (#634)
authorNick Coghlan <ncoghlan@gmail.com>
Sun, 12 Mar 2017 10:03:35 +0000 (20:03 +1000)
committerGitHub <noreply@github.com>
Sun, 12 Mar 2017 10:03:35 +0000 (20:03 +1000)
In git worktree directories, `.git` is a configuration
file rather than a subdirectory
(cherry picked from commit 6a6d090612dd7deaac2bc0399fad743e5e2db606)

Tools/scripts/patchcheck.py

index 7a04aafa82a8a18c95f5772dec54ea66a9215aac..f4ec7d8a30ea23dae92da9d346b89d62f4eeab5a 100755 (executable)
@@ -98,7 +98,10 @@ def changed_files(base_branch=None):
             cmd += ' --rev qparent'
         with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st:
             return [x.decode().rstrip() for x in st.stdout]
-    elif os.path.isdir(os.path.join(SRCDIR, '.git')):
+    elif os.path.exists(os.path.join(SRCDIR, '.git')):
+        # We just use an existence check here as:
+        #  directory = normal git checkout/clone
+        #  file = git worktree directory
         if base_branch:
             cmd = 'git diff --name-status ' + base_branch
         else: