Ramkumar Ramachandra <artag...@gmail.com> writes:

> Instead of "cd there and then come back", use the "cd there in a
> subshell" pattern.  Also fix '&&' chaining in one place.
>
> Suggested-by: Junio C Hamano <gits...@pobox.com>
> Signed-off-by: Ramkumar Ramachandra <artag...@gmail.com>
> ---
>  t/t4041-diff-submodule-option.sh |   13 +++++--------
>  1 files changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/t/t4041-diff-submodule-option.sh 
> b/t/t4041-diff-submodule-option.sh
> index cfb71e5..103c690 100755
> --- a/t/t4041-diff-submodule-option.sh
> +++ b/t/t4041-diff-submodule-option.sh
> @@ -11,18 +11,15 @@ This test tries to verify the sanity of the --submodule 
> option of git diff.
>  . ./test-lib.sh
>  
>  add_file () {
> +     (cd "$1" &&
> +         shift &&
> +         for name; do
>               echo "$name" > "$name" &&
>               git add "$name" &&
>               test_tick &&
>               git commit -m "Add $name"
> +         done >/dev/null &&
> +         git rev-parse --short --verify HEAD)

While at it, why not do the "indent with a single tab", and other
style fixes?  e.g.

        (
                cd "$1" &&
                shift &&
                for name
                do
                        echo "$name" >"$name" &&
                        git add $name" &&
                        test_tick &&
                        git commit -m "Add $name" || exit
                done >/dev/null &&
                git rev-parse --short --verify HEAD
        )

The "|| exit" is needed to catch failures inside the loop (not that
"git commit" there is likely to fail, so it is just for
completeness).

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to