Merge pull request #2540 from git-lfs/lars/debug
commands: teach 'git lfs ls-files' a '--debug' option
This commit is contained in:
commit
0a8d29d0d9
@ -10,6 +10,7 @@ import (
|
||||
|
||||
var (
|
||||
longOIDs = false
|
||||
debug = false
|
||||
)
|
||||
|
||||
func lsFilesCommand(cmd *cobra.Command, args []string) {
|
||||
@ -38,7 +39,24 @@ func lsFilesCommand(cmd *cobra.Command, args []string) {
|
||||
return
|
||||
}
|
||||
|
||||
if debug {
|
||||
Print(
|
||||
"filepath: %s\n"+
|
||||
" size: %d\n"+
|
||||
"checkout: %v\n"+
|
||||
"download: %v\n"+
|
||||
" oid: %s %s\n"+
|
||||
" version: %s\n",
|
||||
p.Name,
|
||||
p.Size,
|
||||
fileExistsOfSize(p),
|
||||
lfs.ObjectExistsOfSize(p.Oid, p.Size),
|
||||
p.OidType,
|
||||
p.Oid,
|
||||
p.Version)
|
||||
} else {
|
||||
Print("%s %s %s", p.Oid[0:showOidLen], lsFilesMarker(p), p.Name)
|
||||
}
|
||||
})
|
||||
defer gitscanner.Close()
|
||||
|
||||
@ -47,17 +65,22 @@ func lsFilesCommand(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func lsFilesMarker(p *lfs.WrappedPointer) string {
|
||||
// Returns true if a pointer appears to be properly smudge on checkout
|
||||
func fileExistsOfSize(p *lfs.WrappedPointer) bool {
|
||||
info, err := os.Stat(p.Name)
|
||||
if err == nil && info.Size() == p.Size {
|
||||
return "*"
|
||||
return err == nil && info.Size() == p.Size
|
||||
}
|
||||
|
||||
func lsFilesMarker(p *lfs.WrappedPointer) string {
|
||||
if fileExistsOfSize(p) {
|
||||
return "*"
|
||||
}
|
||||
return "-"
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterCommand("ls-files", lsFilesCommand, func(cmd *cobra.Command) {
|
||||
cmd.Flags().BoolVarP(&longOIDs, "long", "l", false, "")
|
||||
cmd.Flags().BoolVarP(&debug, "debug", "d", false, "")
|
||||
})
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ reference. If no reference is given, scan the currently checked-out branch.
|
||||
* `-l` `--long`:
|
||||
Show the entire 64 character OID, instead of just first 10.
|
||||
|
||||
* -d --debug:
|
||||
Show as much information as possible about a LFS file. This is intended
|
||||
for manual inspection; the exact format may change at any time.
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
git-lfs-status(1).
|
||||
|
@ -24,6 +24,16 @@ begin_test "ls-files"
|
||||
git lfs ls-files | tee ls.log
|
||||
grep some.dat ls.log
|
||||
[ `wc -l < ls.log` = 1 ]
|
||||
|
||||
diff -u <(git lfs ls-files --debug) <(cat <<-EOF
|
||||
filepath: some.dat
|
||||
size: 10
|
||||
checkout: true
|
||||
download: true
|
||||
oid: sha256 5aa03f96c77536579166fba147929626cc3a97960e994057a9d80271a736d10f
|
||||
version: https://git-lfs.github.com/spec/v1
|
||||
|
||||
EOF)
|
||||
)
|
||||
end_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user