creationix / js-git

A JavaScript implementation of Git.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Octal modes

kmalakoff opened this issue · comments

When trying to use js-git in ES6, the octal mode flags are no longer supported with a leading zero: http://www.2ality.com/2015/04/numbers-math-es6.html.

To make a portable version, I used parseInt with the radix argument: https://github.com/kmalakoff/js-git/blob/master/lib/modes.js although I'm not sure if the benefits of representing the modes in octal are worth the verbosity to make a portable version.

nodegit uses decimal representations:

NodeGit.TreeEntry.FILEMODE = {
  UNREADABLE: 0,
  TREE: 16384,
  BLOB: 33188,
  EXECUTABLE: 33261,
  LINK: 40960,
  COMMIT: 57344,
};

NodeGit.Object.TYPE = {
  ANY: -2,
  BAD: -1,
  EXT1: 0,
  COMMIT: 1,
  TREE: 2,
  BLOB: 3,
  TAG: 4,
  EXT2: 5,
  OFS_DELTA: 6,
  REF_DELTA: 7,
};

What do you prefer?

By "binary" do you mean "decimal"? Also since these are just constants, I'm fine with using parseInt. The performance cost will be one-time for the most part.

Yeah, decimal - updated and submitted a pull request. #127