Skip to content

pointer: Only write the encoded pointer information to Stdout - #1105

Merged
technoweenie merged 1 commit into
git-lfs:masterfrom
sschuberth:master
Apr 7, 2016
Merged

technoweenie merged 1 commit into
git-lfs:masterfrom
sschuberth:master

Conversation

@sschuberth

Copy link
Copy Markdown
Member

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.

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.
@sinbad

sinbad commented Mar 22, 2016

Copy link
Copy Markdown
Contributor

Please can you agree to the Contributor License Agreement since we can't merge this until you do (I think there's a link to do it if you click Details by the error below).

Apart from that this looks good to me but I'd like @technoweenie to OK it as well before merging.

@sschuberth

Copy link
Copy Markdown
Member Author

@sinbad Unfortunately, until I saw the bot check I wasn't aware a CLA is required. I need to get the CLA reviewed by our legal department which might take some some.

@sschuberth

Copy link
Copy Markdown
Member Author

On a related note, I just had a discussion in upstream Git about what kind of information should go to Stdout vs. Stderr, and here are some good answers:

@sinbad

sinbad commented Mar 23, 2016

Copy link
Copy Markdown
Contributor

Yep, I think that's a pretty good guide.

@technoweenie

Copy link
Copy Markdown
Contributor

Hey @sschuberth, thanks for submitting this. I'm certainly not a linux expert, and will usually defer to whatever Git does in cases like this. I think those guidelines make sense for git plumbing commands, but not git porcelain commands.

$ git status 2>/dev/null
On branch lfs-repo-usage
Your branch is based on 'origin/lfs-repo-usage', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)
nothing to commit, working directory clean

The default git status output isn't designed for machine readable content. So, my interpretation is that those guidelines are only for porcelain commands.

It looks like this PR declares git lfs pointer as a plumbing command, while sending some user output to STDERR so it's still readable to humans. Is that common with linux commands? Are there weird edge cases with commands returning STDERR output and a 0 exit code? Based on your profile, I'm assuming you know what you're talking about. I want to make sure that I understand this correctly ;)

@sschuberth

Copy link
Copy Markdown
Member Author

Hi @technoweenie. I wouldn't say I'm a Linux expert either (I was mostly working on Git for Windows), but the discussion I was referring to is about git submodule, which is a porcelain command. Also, the referred commit message by @peff says

Putting messages like "Cloning into.." and "done" on stdout is un-Unix and uselessly clutters the stdout channel.

Note how he says "un-Unix", not "un-git-ish" or the like.

Your counter-example of git status is a good one, but on the other hand @gitster says (also in my linked thread):

We may not have been very strict in code reviews to enfore it, and
especially on the fringes of the system it may be easy to find
violators, though.

Finally, even if this PR would declare git lfs pointer as a plumbing command I'd argue that's a correct thing to do as git-lfs itself lists git lfs pointer under "Low level commands" in its command line help.

Are there weird edge cases with commands returning STDERR output and a 0 exit code?

Again, as mentioned in the linked thread, try git clone. And I wouldn't say that's a weird edge case ;-)

@technoweenie

Copy link
Copy Markdown
Contributor

Nice counter point with git submodule. SOLD 👍

Any idea what it'll take to get the CLA approved? Seems silly to hold up a trivial patch like this. I can totally ninja-merge this, or recreate the changes personally, but I'd rather not so you can get the sweet credit, and potentially contribute in the future ;)

If you can't, or don't feel like going through the hassle, that's totally OK too. I'll just recreate the patch. In the future, you can just open issues for us.

@peff

peff commented Mar 28, 2016

Copy link
Copy Markdown

Yeah, I think you can get into pretty vague, opinionated arguments on stdout vs stderr. Basically, we should strive for usefulness. So if something is the "main" output of a command (as it is with git status), it should go to stdout, regardless of whether it is machine readable or not. If it is extra chattiness that would otherwise make the stdout output harder to parse or reuse, then it should go to stderr (so I think @sschuberth's example shows that).

Something like clone is in a weird no-man's land, because it doesn't really produce a "main" output in the first place. Its function is to do something, and all output is basically human-readable chat.

I don't think we have to care about plumbing versus porcelain when making this distinction.

Are there weird edge cases with commands returning STDERR output and a 0 exit code?

tcl is notorious for treating anything on stderr like an error. IMHO that is just insane.

@sschuberth

Copy link
Copy Markdown
Member Author

Any idea what it'll take to get the CLA approved?

@technoweenie I just need to push our legal department a bit. Give me a few more days. My patch is not super-urgent, and I'd like to get this sorted out anyway.

tcl is notorious for treating anything on stderr like an error. IMHO that is just insane.

@peff Just FYI, PowerShell does the same. But I don't think it's insane per se. It's called standard error after all.

@technoweenie

Copy link
Copy Markdown
Contributor

Honestly, it doesn't sound insane to me either. That's why I wanted to clarify. Should we file a PR to change STDERR to STDUSER or something? :trollface:

@sschuberth no worries, I'll wait patiently :)

@sinbad

sinbad commented Mar 29, 2016

Copy link
Copy Markdown
Contributor

This is such a common sticking point...in SourceTree for quite a while we coloured stderr output red because it was usually best way to highlight errors in large output based on observed Git behaviour, but it could be confusing when people had verbose mode on but the result code was successful. Our eventual solution was to display everything in standard text while the command runs but remembering which was stdout & stderr & applying the highlighting only when the result code was non-zero. Occasionally we highlight more than required in that case but most of the time in fatal cases it does pick out just the bad stuff. If only there were 3 defined output streams... :)

@sschuberth

Copy link
Copy Markdown
Member Author

@technoweenie I was able to accept the CLA now :-)

@technoweenie
technoweenie merged commit da2935d into git-lfs:master Apr 7, 2016
@technoweenie

Copy link
Copy Markdown
Contributor

Thanks! I should've asked about tests. But since I didn't, you get a free ride this time. Here's what I came up with:

73f1af9

It's kind of a good thing though, you would've spent a bunch of time banging your head against the wall because of this:

dcf9249

@technoweenie technoweenie mentioned this pull request Apr 7, 2016
16 of 17 tasks
Empact added a commit to Empact/git that referenced this pull request Apr 19, 2016
The git lfs pointer output was changed in:
git-lfs/git-lfs#1105

This was causing Mac Travis runs to fail, as homebrew had updated to 1.2
while Linux was pinned at 1.1 via GIT_LFS_VERSION.

The travis builds against 1.1 and 1.2 both on linux. Mac can't do the same as
it takes the latest homebrew version regardless.
gitster pushed a commit to git/git that referenced this pull request Apr 19, 2016
Git LFS 1.2.0 removed a line from the output of the 'git lfs pointer'
command [1] which broke the parsing of this output. Adjust the parser
to the new output and add minimum Git LFS version to the docs.

[1] git-lfs/git-lfs#1105

Signed-off-by: Lars Schneider <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants