GithubHelp home page GithubHelp logo

Git is loud about homeshick HOT 12 CLOSED

andsens avatar andsens commented on June 19, 2024
Git is loud

from homeshick.

Comments (12)

untitaker avatar untitaker commented on June 19, 2024

Maybe redirecting the output into a tempfile, which gets outputted when git exits with an exitcode != 0 ?

from homeshick.

andsens avatar andsens commented on June 19, 2024

I'm not too fond of using temporary files for that. Maybe homeshick could save the output in a variable using a subshell. I don't think you can check the exit code of a process in a subshell though.
Maybe we can do this instead?

output=$(git clone --quiet $git_repo $repo_path; echo "Exit code was $?")
if [ ${output:${#output}-1} != 0 ]; then
    err "Unable to clone $git_repo. Git says:" "$output"
fi

from homeshick.

andsens avatar andsens commented on June 19, 2024

Just realised this doesn't take of exit codes 10,20,30 etc.

output=$(git clone --quiet $git_repo $repo_path; echo "Exit code was $?")
if [ "${output:${#output}-1}" != " 0" ]; then
    err "Unable to clone $git_repo. Git says:" "$output"
fi

from homeshick.

andsens avatar andsens commented on June 19, 2024

Oh, I see...

output=$(git clone --quiet $git_repo $repo_path; exit $?)
if [ $? != 0 ]; then
    err "Unable to clone $git_repo. Git says:" "$output"
fi

Might be a bit easier :-)

from homeshick.

untitaker avatar untitaker commented on June 19, 2024

What about stderr?

output="$(git clone $git_repo $repo_path 2>&1)"
if [ $? != 0 ]; then
    err "Unable to clone $git_repo. Git says: $output"
fi

from homeshick.

untitaker avatar untitaker commented on June 19, 2024

(in that case we also could omit the --quiet flag, since more information on error is actually better)

from homeshick.

andsens avatar andsens commented on June 19, 2024

Oh yes, that too of course. I just realized that we don't need the exit $? at all. Not sure why I thought the subshell would exit with 0 otherwise.

from homeshick.

untitaker avatar untitaker commented on June 19, 2024

git seems to print all output to stderr (!?), so redirecting only stdout to /dev/null and let errors pass through is not possible.

from homeshick.

untitaker avatar untitaker commented on June 19, 2024

That said, i would prefer a more verbose output, especially when updating submodules, since i still don't fully trust git's submodule functionality.

from homeshick.

andsens avatar andsens commented on June 19, 2024

Maybe we can introduce a --verbose switch. Saying git submodule cannot be trusted is a very subjective argument for outputting unimportant information to the console.
In addition, knowing how the submodule functionality operates I have to disagree.
I think I will implement this. (unless you can provide a stronger argument?)

from homeshick.

untitaker avatar untitaker commented on June 19, 2024

Go ahead 👍

from homeshick.

andsens avatar andsens commented on June 19, 2024

Oh ffs. I get my confusion now. Guess what?

#!/bin/bash
function fn {
    output1=$(test -e nonexistent)
    echo $? # Outputs 1
    local output2=$(test -e nonexistent)
    echo $? # Outputs 0
    local output3
    output3=$(test -e nonexistent)
    echo $? # Outputs 1
}
fn

The local keyword is a command that changes the last exit code. This is why I sometimes couldn't get the proper exit code.

from homeshick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.