Thread (1 message) 1 message, 1 author, 2019-01-28

Re: [PATCH v2] git-submodule.sh: shorten submodule SHA-1s using rev-parse

From: Junio C Hamano <hidden>
Date: 2019-01-28 02:34:34

Eric Sunshine [off-list ref] writes:
This could be made a bit easier to follow by using indentation and ||
rather than &&. For instance, rewriting the entire block as:

    # Shorten with hard-coded fallback if rev-parse fails
    sha1_abbr_src=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_src ||
        echo $sha1_src | cut -c1-7)
    sha1_abbr_dst=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_dst ||
        echo $sha1_dst | cut -c1-7)

In fact, the code is clear enough that the comment isn't even needed.

By the way, if git-rev-parse does fail, is it going to produce an
error message on stderr that needs to be suppressed?
All good points ;-).
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help