git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/4] t4041 (diff-submodule-option): rewrite add_file() routine

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 27, 2012, 17:56 UTC
Message-ID
<7vlidnlyjd.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1354005692-2809-3-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 26 quoted lines
> 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 <gitster@pobox.com>
> Signed-off-by: Ramkumar Ramachandra <artagnon@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).

Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 5 of 8 in “t4041 (diff-submodule-option): minor cleanup”
  1. 0/4 t4041 (diff-submodule-option): minor cleanupRamkumar Ramachandra, Nov 27, 2012
  2. 1/4 t4041 (diff-submodule-option): parse digests sensiblyRamkumar Ramachandra, Nov 27, 2012
  3. Junio C HamanoNov 27, 2012
  4. 2/4 t4041 (diff-submodule-option): rewrite add_file() routineRamkumar Ramachandra, Nov 27, 2012
  5. Junio C HamanoNov 27, 2012
  6. 3/4 t4041 (diff-submodule-option): modernize styleRamkumar Ramachandra, Nov 27, 2012
  7. 4/4 t4041 (diff-submodule-option): change tense of test namesRamkumar Ramachandra, Nov 27, 2012
  8. Junio C HamanoNov 27, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.