Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I parse git status or use gitsharp?

I'd like to integrate git into production pipeline to stage 3dsmax files. While it is alright to work with git through TortoiseGit, I'd like to communicate with it from the Maxscript to add custom menu commands to 3dsmax.

Should I parse git status output text to determine folder status or should I use some wrapping tool to correctly communicate with git?

I was thinking about gitsharp since it is easy to call dotNet objects from Maxscript, but I didn't use external dotNet programs.

like image 211
sergo Avatar asked Dec 30 '09 11:12

sergo


1 Answers

Since git version 1.7.0, there has been a --porcelain option for git status. The output of:

git status --porcelain

... is designed for use by scripts - a compact representation of the output whose format will remain consistent across versions. As the man page says:

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.

So, as that says, you may also want to consider using:

git status -z

... for an even more robust output format.

like image 126
Mark Longair Avatar answered Oct 05 '22 17:10

Mark Longair