Merge pull request #3271 from skashyap7/master
Support listing only filename tracked by git lfs using --name (-n) option
This commit is contained in:
commit
e7b6b33b5a
@ -11,18 +11,18 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
longOIDs = false
|
||||
lsFilesScanAll = false
|
||||
lsFilesScanDeleted = false
|
||||
lsFilesShowSize = false
|
||||
debug = false
|
||||
longOIDs = false
|
||||
lsFilesScanAll = false
|
||||
lsFilesScanDeleted = false
|
||||
lsFilesShowSize = false
|
||||
lsFilesShowNameOnly = false
|
||||
debug = false
|
||||
)
|
||||
|
||||
func lsFilesCommand(cmd *cobra.Command, args []string) {
|
||||
requireInRepo()
|
||||
|
||||
var ref string
|
||||
|
||||
if len(args) == 1 {
|
||||
if lsFilesScanAll {
|
||||
Exit("fatal: cannot use --all with explicit reference")
|
||||
@ -82,6 +82,9 @@ func lsFilesCommand(cmd *cobra.Command, args []string) {
|
||||
p.Version)
|
||||
} else {
|
||||
msg := []string{p.Oid[:showOidLen], lsFilesMarker(p), p.Name}
|
||||
if lsFilesShowNameOnly {
|
||||
msg = []string{p.Name}
|
||||
}
|
||||
if lsFilesShowSize {
|
||||
size := humanize.FormatBytes(uint64(p.Size))
|
||||
msg = append(msg, "("+size+")")
|
||||
@ -143,6 +146,7 @@ func init() {
|
||||
RegisterCommand("ls-files", lsFilesCommand, func(cmd *cobra.Command) {
|
||||
cmd.Flags().BoolVarP(&longOIDs, "long", "l", false, "")
|
||||
cmd.Flags().BoolVarP(&lsFilesShowSize, "size", "s", false, "")
|
||||
cmd.Flags().BoolVarP(&lsFilesShowNameOnly, "name-only", "n", false, "")
|
||||
cmd.Flags().BoolVarP(&debug, "debug", "d", false, "")
|
||||
cmd.Flags().BoolVarP(&lsFilesScanAll, "all", "a", false, "")
|
||||
cmd.Flags().BoolVar(&lsFilesScanDeleted, "deleted", false, "")
|
||||
|
@ -37,6 +37,8 @@ An asterisk (*) after the OID indicates a LFS pointer, a minus (-) a full object
|
||||
* `-X` <paths> `--exclude=`<paths>:
|
||||
Exclude paths matching any of these patterns; see [FETCH SETTINGS].
|
||||
|
||||
* `-n` `--name-only`:
|
||||
Show only the lfs tracked file names.
|
||||
## SEE ALSO
|
||||
|
||||
git-lfs-status(1), git-lfs-config(5).
|
||||
|
@ -418,3 +418,27 @@ begin_test "ls-files: list/stat files with escaped runes in path before commit"
|
||||
|
||||
)
|
||||
end_test
|
||||
|
||||
begin_test "ls-files: --name-only"
|
||||
(
|
||||
set -e
|
||||
|
||||
reponame="ls-files-name"
|
||||
git init "$reponame"
|
||||
cd "$reponame"
|
||||
|
||||
git lfs track "*.dat"
|
||||
git add .gitattributes
|
||||
git commit -m "initial commit"
|
||||
|
||||
contents="test contents"
|
||||
echo "$contents" > a.dat
|
||||
|
||||
git add a.dat
|
||||
git commit -m "add a.dat"
|
||||
|
||||
git lfs ls-files --name-only 2>&1 | tee ls.log
|
||||
[ "a.dat" = "$(cat ls.log)" ]
|
||||
)
|
||||
end_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user