This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: git doesn't support "-C" args under 1.8.5 occurs in configure.ac
Type: Stage: resolved
Components: Build Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Yuan Liu, eitan.adler, miss-islington, ned.deily, xiang.zhang
Priority: normal Keywords: patch

Created on 2017-05-20 09:29 by Yuan Liu, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1679 closed python-dev, 2017-05-20 09:46
PR 1680 closed python-dev, 2017-05-20 10:09
PR 8744 merged xiang.zhang, 2018-08-12 09:20
PR 8836 merged miss-islington, 2018-08-20 14:36
PR 8837 merged miss-islington, 2018-08-20 14:36
PR 8838 merged xiang.zhang, 2018-08-20 14:47
Messages (6)
msg294021 - (view) Author: Yuan Liu (Yuan Liu) * Date: 2017-05-20 09:29
git doesn't support "-C" args under 1.8.5 occurs in configure.ac

as I noticed from git release notes in 1.8.5: 

 * Just like "make -C <directory>", "git -C <directory> ..." tells Git
   to go there before doing anything else.

So we should have some conditional statements in configure.ac around git checkpoint, otherwise we got error message which is :

Unknown option: -C
usage: git [--version] [--help] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
msg320032 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-06-20 07:40
Encounter the same problem on centos7 and git version is 1.8.3. Instead of checking the version to use -C option, maybe we could just use --git-dir for the same purpose?

--- a/configure
+++ b/configure
@@ -2749,9 +2749,9 @@ HAS_GIT=no-repository
 fi
 if test $HAS_GIT = found
 then
-    GITVERSION="git -C \$(srcdir) rev-parse --short HEAD"
-    GITTAG="git -C \$(srcdir) describe --all --always --dirty"
-    GITBRANCH="git -C \$(srcdir) name-rev --name-only HEAD"
+    GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD"
+    GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"
+    GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD"
 else
     GITVERSION=""
     GITTAG=""
diff --git a/configure.ac b/configure.ac
index b13728e..278ed9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,9 +39,9 @@ HAS_GIT=no-repository
 fi
 if test $HAS_GIT = found
 then
-    GITVERSION="git -C \$(srcdir) rev-parse --short HEAD"
-    GITTAG="git -C \$(srcdir) describe --all --always --dirty"
-    GITBRANCH="git -C \$(srcdir) name-rev --name-only HEAD"
+    GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD"
+    GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"
+    GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD"
 else
     GITVERSION=""
     GITTAG=""

This could give me the right sys._git info.
msg320290 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-06-22 22:55
Thanks for the PR.  I agree with Xiang Zhang that using --git-dir appears to be a better solution.  See other review comments on the PR.
msg323790 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-08-20 14:36
New changeset 4c8555773a801f957297132a92c0acb382d640e4 by Xiang Zhang in branch 'master':
bpo-30411: Use --git-dir instead of -C to make git work under version below 1.8.5. (GH-8744)
https://github.com/python/cpython/commit/4c8555773a801f957297132a92c0acb382d640e4
msg323792 - (view) Author: miss-islington (miss-islington) Date: 2018-08-20 14:48
New changeset 2011dd77b6bd6f02f54ceef9a80a22bd373b66e2 by Miss Islington (bot) in branch '3.7':
bpo-30411: Use --git-dir instead of -C to make git work under version below 1.8.5. (GH-8744)
https://github.com/python/cpython/commit/2011dd77b6bd6f02f54ceef9a80a22bd373b66e2
msg323794 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-08-20 15:15
New changeset 95f9e14e33b713f35f5368acf7be56750bbdb5a8 by Xiang Zhang in branch '2.7':
[2.7] bpo-30411: Use --git-dir instead of -C to make git work under version below 1.8.5. (GH-8744) (GH-8838)
https://github.com/python/cpython/commit/95f9e14e33b713f35f5368acf7be56750bbdb5a8
History
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74596
2018-08-20 15:19:30xiang.zhangsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-08-20 15:15:18xiang.zhangsetmessages: + msg323794
2018-08-20 14:48:34miss-islingtonsetnosy: + miss-islington
messages: + msg323792
2018-08-20 14:47:57xiang.zhangsetpull_requests: + pull_request8313
2018-08-20 14:36:50miss-islingtonsetpull_requests: + pull_request8312
2018-08-20 14:36:40miss-islingtonsetpull_requests: + pull_request8311
2018-08-20 14:36:25xiang.zhangsetmessages: + msg323790
2018-08-12 09:20:19xiang.zhangsetkeywords: + patch
stage: patch review
pull_requests: + pull_request8227
2018-06-22 22:55:13ned.deilysetmessages: + msg320290
2018-06-20 07:40:03xiang.zhangsetversions: + Python 2.7, Python 3.6, Python 3.8
nosy: + xiang.zhang, ned.deily

messages: + msg320032

components: + Build
2018-05-16 07:44:14eitan.adlersetnosy: + eitan.adler
2017-05-20 10:09:03python-devsetpull_requests: + pull_request1775
2017-05-20 09:46:27python-devsetpull_requests: + pull_request1774
2017-05-20 09:29:22Yuan Liucreate