【问题标题】:git log -- <file_name> works correct on terminal, but doing g.log(file_name) in git python shows errorgit log -- <file_name> 在终端上工作正常,但在 git python 中执行 g.log(file_name) 会显示错误
【发布时间】:2014-10-16 09:06:41
【问题描述】:

对于某些文件,碰巧在 Git Python 中 g.log() 指令会出错,但对于同一个文件,如果我在终端上执行 [$git log -- ],则可以正常工作。 终端上的以下命令效果很好:

$git log -- org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java

这是我的python代码:

import git
from git import *
import sys
repo = Repo ("/home/directory/git/eclipse.jdt.core")
assert repo.bare == False
g=repo.git
loginfo = g.log('org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java')

它显示以下错误: 回溯(最近一次通话最后): 文件“”,第 1 行,在 文件“/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/cmd.py”,第 227 行,在 返回 lambda *args, **kwargs: self._call_process(name, *args, **kwargs) _call_process 中的文件“/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/cmd.py”,第 456 行 return self.execute(call, **_kwargs) 文件“/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/cmd.py”,第 377 行,在执行 引发 GitCommandError(命令,状态,stderr_value) git.exc.GitCommandError:'git log org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java'返回退出状态128:致命:模糊参数'org.eclipse.jdt.core /model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java':未知修订版或路径不在工作树中。 使用 '--' 将路径与修订分开,如下所示: 'git [...] -- [...]'

有人可以建议如何纠正它吗?

【问题讨论】:

    标签: python git gitpython


    【解决方案1】:

    --g.log(...) 调用中丢失。正确的做法如下。

    g.log('--', "org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java")
    

    【讨论】:

      猜你喜欢
      • 2019-02-18
      • 1970-01-01
      • 2013-09-28
      • 1970-01-01
      • 2021-01-07
      • 2023-04-06
      • 1970-01-01
      • 2012-06-05
      • 2020-07-07
      相关资源
      最近更新 更多