git - 我应该解析 git status 还是使用 gitsharp?

标签 git production-environment pipeline 3dsmax maxscript

我想将 git 集成到生产管道中以暂存 3dsmax 文件。虽然可以通过 TortoiseGit 使用 git,但我想从 Maxscript 与其通信以将自定义菜单命令添加到 3dsmax。

我应该解析 git status 输出文本来确定文件夹状态,还是应该使用一些包装工具来正确地与 git 通信?

我在考虑 gitsharp,因为它很容易从 Maxscript 调用 dotNet 对象,但我没有使用外部 dotNet 程序。

最佳答案

从 git 版本 1.7.0 开始,git status 有了一个 --porcelain 选项。的输出:

git status --porcelain

... 专为脚本使用而设计 - 输出的紧凑表示,其格式将在各个版本中保持一致。正如手册页所说:

Porcelain Format

The porcelain format is similar to the short format, but is guaranteed not to change in a backwards-incompatible way between git versions or based on user configuration. This makes it ideal for parsing by scripts. The description of the short format above also describes the porcelain format, with a few exceptions:

  1. The user’s color.status configuration is not respected; color will always be off.
  2. The user’s status.relativePaths configuration is not respected; paths shown will always be relative to the repository root.

There is also an alternate -z format recommended for machine parsing. In that format, the status field is the same, but some other things change. First, the -> is omitted from rename entries and the field order is reversed (e.g from -> to becomes to from). Second, a NUL (ASCII 0) follows each filename, replacing space as a field separator and the terminating newline (but a space still separates the status field from the first filename). Third, filenames containing special characters are not specially formatted; no quoting or backslash-escaping is performed.

因此,如上所述,您可能还需要考虑使用:

git status -z

...以获得更强大的输出格式。

关于git - 我应该解析 git status 还是使用 gitsharp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1979609/

相关文章:

c# - C# 中的完整惰性管道

python - 如何从项目管道访问scrapy设置

java - 测量生产环境中 Java Web 服务的方法执行时间

c# - 如何处理来自使用同一数据库的多个应用程序的存储过程代码更改?

svn - 为什么要使用SVN?那里有任何 stash 的专业人士(通过 GIT/Mercurial/Bazaar)吗?

linux - 从 GitHub 迁移到 GitLab(作为 POSIX 环境中的远程)

ruby-on-rails - 如何在生产模式下运行redis服务器和juggernaut服务器

opencv - Opencv videoCapture() 中的 Gstreamer 管道

git - 解决 git merge octopus 上的冲突

git - cloudbuild.yaml 包含不同的云构建器配置