Skip to content

Commit

Permalink
pointer: Only write the encoded pointer information to Stdout
Browse files Browse the repository at this point in the history
This allows to create a pointer file by redirecting Stdout like

    $ git lfs pointer --file=path/to/file > pointer-to-file

Before this change, "pointer-to-file" would also contain the line saying

    "Git LFS pointer for path/to/file"

which makes the pointer file invalid.
  • Loading branch information
sschuberth committed Mar 22, 2016
1 parent 8f90f59 commit da2935d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions commands/command_pointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ func pointerCommand(cmd *cobra.Command, args []string) {
}

ptr := lfs.NewPointer(hex.EncodeToString(oidHash.Sum(nil)), size, nil)
fmt.Printf("Git LFS pointer for %s\n\n", pointerFile)
fmt.Fprintf(os.Stderr, "Git LFS pointer for %s\n\n", pointerFile)
buf := &bytes.Buffer{}
lfs.EncodePointer(io.MultiWriter(os.Stdout, buf), ptr)

if comparing {
buildOid = gitHashObject(buf.Bytes())
fmt.Printf("\nGit blob OID: %s\n\n", buildOid)
fmt.Fprintf(os.Stderr, "\nGit blob OID: %s\n\n", buildOid)
}
} else {
comparing = false
Expand All @@ -81,22 +81,22 @@ func pointerCommand(cmd *cobra.Command, args []string) {
if !pointerStdin {
pointerName = pointerCompare
}
fmt.Printf("Pointer from %s\n\n", pointerName)
fmt.Fprintf(os.Stderr, "Pointer from %s\n\n", pointerName)

if err != nil {
Error(err.Error())
os.Exit(1)
}

fmt.Printf(buf.String())
fmt.Fprintf(os.Stderr, buf.String())
if comparing {
compareOid = gitHashObject(buf.Bytes())
fmt.Printf("\nGit blob OID: %s\n", compareOid)
fmt.Fprintf(os.Stderr, "\nGit blob OID: %s\n", compareOid)
}
}

if comparing && buildOid != compareOid {
fmt.Printf("\nPointers do not match\n")
fmt.Fprintf(os.Stderr, "\nPointers do not match\n")
os.Exit(1)
}

Expand Down

0 comments on commit da2935d

Please sign in to comment.