1
0
mirror of https://github.com/danog/gift.git synced 2024-11-30 04:19:37 +01:00

Support file arguments for ls-files

This commit is contained in:
Hiroyuki Tanjo 2016-02-19 19:17:39 +09:00 committed by Luke Plaster
parent 25af97c70c
commit 951ba4c0b2

View File

@ -287,13 +287,19 @@ module.exports = class Repo
# Public: Show information about files in the index and the # Public: Show information about files in the index and the
# working tree. # working tree.
# #
# files - Array of String paths; or a String path (optional).
# options - An Object of command line arguments to pass to # options - An Object of command line arguments to pass to
# `git ls-files` (optional). # `git ls-files` (optional).
# callback - Receives `(err,stdout)`. # callback - Receives `(err,stdout)`.
# #
ls_files: (options, callback) -> ls_files: (files, options, callback) ->
[options, callback] = [callback, options] if !callback [options, callback] = [callback, options] if !callback
@git "ls-files", options [files, callback] = [callback, files] if !callback
[files, options] = [options, files] if typeof files is 'object' and not _.isArray files
options ?= {}
files ?= ''
files = [files] if _.isString files
@git "ls-files", options, _.flatten(['--', files])
, (err, stdout, stderr) => , (err, stdout, stderr) =>
return callback err if err return callback err if err
return callback null, @parse_lsFiles stdout,options return callback null, @parse_lsFiles stdout,options