From 1b1e1af8ccbcfea5e1bbc4e6d2a34125679f16bc Mon Sep 17 00:00:00 2001 From: Suman Kashyap Date: Wed, 19 Sep 2018 16:16:18 -0700 Subject: [PATCH 1/4] Adding support for showing only lfs tracked file names without additional information --- commands/command_ls_files.go | 17 +++++++++++------ docs/man/git-lfs-ls-files.1.ronn | 2 ++ t/t-ls-files.sh | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/commands/command_ls_files.go b/commands/command_ls_files.go index 66f7e2ec..212238a5 100644 --- a/commands/command_ls_files.go +++ b/commands/command_ls_files.go @@ -11,18 +11,19 @@ import ( ) var ( - longOIDs = false - lsFilesScanAll = false - lsFilesScanDeleted = false - lsFilesShowSize = false - debug = false + longOIDs = false + lsFilesScanAll = false + lsFilesScanDeleted = false + lsFilesShowSize = false + lsFilesShowFileOnly = false + debug = false ) func lsFilesCommand(cmd *cobra.Command, args []string) { requireInRepo() var ref string - + Print("Hellow "); if len(args) == 1 { if lsFilesScanAll { Exit("fatal: cannot use --all with explicit reference") @@ -82,6 +83,9 @@ func lsFilesCommand(cmd *cobra.Command, args []string) { p.Version) } else { msg := []string{p.Oid[:showOidLen], lsFilesMarker(p), p.Name} + if lsFilesShowFileOnly { + msg = []string{p.Name} + } if lsFilesShowSize { size := humanize.FormatBytes(uint64(p.Size)) msg = append(msg, "("+size+")") @@ -143,6 +147,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(&lsFilesShowFileOnly, "name", "n", false, "") cmd.Flags().BoolVarP(&debug, "debug", "d", false, "") cmd.Flags().BoolVarP(&lsFilesScanAll, "all", "a", false, "") cmd.Flags().BoolVar(&lsFilesScanDeleted, "deleted", false, "") diff --git a/docs/man/git-lfs-ls-files.1.ronn b/docs/man/git-lfs-ls-files.1.ronn index 5db20645..2ec6ea64 100644 --- a/docs/man/git-lfs-ls-files.1.ronn +++ b/docs/man/git-lfs-ls-files.1.ronn @@ -37,6 +37,8 @@ An asterisk (*) after the OID indicates a LFS pointer, a minus (-) a full object * `-X` `--exclude=`: Exclude paths matching any of these patterns; see [FETCH SETTINGS]. +* `-n` `--name`: + Show only the lfs tracked file names. ## SEE ALSO git-lfs-status(1), git-lfs-config(5). diff --git a/t/t-ls-files.sh b/t/t-ls-files.sh index 9b646132..edd84e37 100755 --- a/t/t-ls-files.sh +++ b/t/t-ls-files.sh @@ -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" +( + 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 2>&1 | tee ls.log + [ "a.dat" = "$(cat ls.log)" ] +) +end_test + From f5bbf0cba24c95e3a9fc3f05f8936d708cb29080 Mon Sep 17 00:00:00 2001 From: Suman Kashyap Date: Wed, 19 Sep 2018 16:20:33 -0700 Subject: [PATCH 2/4] remove log statement --- commands/command_ls_files.go | 1 - 1 file changed, 1 deletion(-) diff --git a/commands/command_ls_files.go b/commands/command_ls_files.go index 212238a5..b0906a73 100644 --- a/commands/command_ls_files.go +++ b/commands/command_ls_files.go @@ -23,7 +23,6 @@ func lsFilesCommand(cmd *cobra.Command, args []string) { requireInRepo() var ref string - Print("Hellow "); if len(args) == 1 { if lsFilesScanAll { Exit("fatal: cannot use --all with explicit reference") From b809bab43093235ed507a6143e4c6917d5f346e7 Mon Sep 17 00:00:00 2001 From: Suman Kashyap Date: Wed, 19 Sep 2018 16:23:56 -0700 Subject: [PATCH 3/4] Fix Indentation --- commands/command_ls_files.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commands/command_ls_files.go b/commands/command_ls_files.go index b0906a73..fc6d6109 100644 --- a/commands/command_ls_files.go +++ b/commands/command_ls_files.go @@ -82,9 +82,9 @@ func lsFilesCommand(cmd *cobra.Command, args []string) { p.Version) } else { msg := []string{p.Oid[:showOidLen], lsFilesMarker(p), p.Name} - if lsFilesShowFileOnly { - msg = []string{p.Name} - } + if lsFilesShowFileOnly { + msg = []string{p.Name} + } if lsFilesShowSize { size := humanize.FormatBytes(uint64(p.Size)) msg = append(msg, "("+size+")") From 3eb8bcf3e7f5f34131a52180539fb434cc3ec919 Mon Sep 17 00:00:00 2001 From: Suman Kashyap Date: Thu, 20 Sep 2018 09:38:17 -0700 Subject: [PATCH 4/4] Rename ls-files --name option to --name-only (-n) --- commands/command_ls_files.go | 6 +++--- docs/man/git-lfs-ls-files.1.ronn | 2 +- t/t-ls-files.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/command_ls_files.go b/commands/command_ls_files.go index fc6d6109..f063ffc6 100644 --- a/commands/command_ls_files.go +++ b/commands/command_ls_files.go @@ -15,7 +15,7 @@ var ( lsFilesScanAll = false lsFilesScanDeleted = false lsFilesShowSize = false - lsFilesShowFileOnly = false + lsFilesShowNameOnly = false debug = false ) @@ -82,7 +82,7 @@ func lsFilesCommand(cmd *cobra.Command, args []string) { p.Version) } else { msg := []string{p.Oid[:showOidLen], lsFilesMarker(p), p.Name} - if lsFilesShowFileOnly { + if lsFilesShowNameOnly { msg = []string{p.Name} } if lsFilesShowSize { @@ -146,7 +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(&lsFilesShowFileOnly, "name", "n", 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, "") diff --git a/docs/man/git-lfs-ls-files.1.ronn b/docs/man/git-lfs-ls-files.1.ronn index 2ec6ea64..3c095217 100644 --- a/docs/man/git-lfs-ls-files.1.ronn +++ b/docs/man/git-lfs-ls-files.1.ronn @@ -37,7 +37,7 @@ An asterisk (*) after the OID indicates a LFS pointer, a minus (-) a full object * `-X` `--exclude=`: Exclude paths matching any of these patterns; see [FETCH SETTINGS]. -* `-n` `--name`: +* `-n` `--name-only`: Show only the lfs tracked file names. ## SEE ALSO diff --git a/t/t-ls-files.sh b/t/t-ls-files.sh index edd84e37..8040f1f4 100755 --- a/t/t-ls-files.sh +++ b/t/t-ls-files.sh @@ -419,7 +419,7 @@ begin_test "ls-files: list/stat files with escaped runes in path before commit" ) end_test -begin_test "ls-files: --name" +begin_test "ls-files: --name-only" ( set -e @@ -437,7 +437,7 @@ begin_test "ls-files: --name" git add a.dat git commit -m "add a.dat" - git lfs ls-files --name 2>&1 | tee ls.log + git lfs ls-files --name-only 2>&1 | tee ls.log [ "a.dat" = "$(cat ls.log)" ] ) end_test