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

Re: [PATCH 3/4] Add tests for .git file

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2008, 03:25 UTC
Message-ID
<7vfxw66a0s.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1202158761-31211-4-git-send-email-hjemli@gmail.com>
Lars Hjemli <hjemli@gmail.com> writes:
Show 27 quoted lines
> Verify that the basic plumbing works when .git is a file pointing at
> the real git directory.
>
> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
> ---
>  t/t0002-gitfile.sh |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 71 insertions(+), 0 deletions(-)
>  create mode 100755 t/t0002-gitfile.sh
>
> diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
> new file mode 100755
> index 0000000..f8f39e6
> --- /dev/null
> +++ b/t/t0002-gitfile.sh
> @@ -0,0 +1,71 @@
> +#!/bin/sh
> +
> +test_description='.git file
> +
> +Verify that plumbing commands work when .git is a file
> +'
> +. ./test-lib.sh
> +
> +chkfile() {
> +	D=$(echo $1 | cut -b 1-2) &&
> +	F=$(echo $1 | cut -b 3-40) &&
> +	if test ! -f $REAL/objects/$D/$F
	P=$(echo $1 | sed -e 's|\(..\)\(.*\)|\1/\2\|') &&
        if test ! -f "$REAL/objects/$P"
		...

Although it probably is more efficient to do this with one process, s/cut/sed/ is mostly a style issue.

Be careful with quoting. $REAL might contain a $IFS whitespace as you grabbed it from $(pwd)...

Show 13 quoted lines
> +test_expect_success 'setup' '
> +	REAL=$(pwd)/.real &&
> +	mv .git $REAL &&
> +	echo "gitdir: $REAL" >.git
> +'
> ...
> +test_expect_success 'check update-index' '
> +	if test -f $REAL/index
> +	then
> +		echo "Hmm, $REAL/index exists?"
> +		false
> +	fi &&
> +	rm -rf $REAL/objects/* &&
... and it matters especially if you do this ;-)
Previous: Lars HjemliNext: Lars Hjemli
Message 8 of 13 in “Introduce the .git-file”
  1. 0/4 Introduce the .git-fileLars Hjemli, Feb 4, 2008
  2. 1/4 Add platform-independent .git "symlink"Lars Hjemli, Feb 4, 2008
  3. 2/4 Document the .git-fileLars Hjemli, Feb 4, 2008
  4. 3/4 Add tests for .git fileLars Hjemli, Feb 4, 2008
  5. 4/4 git-submodule: prepare for the .git-fileLars Hjemli, Feb 4, 2008
  6. Mike HommeyFeb 4, 2008
  7. Lars HjemliFeb 4, 2008
  8. Junio C HamanoFeb 6, 2008
  9. 3/4 Add tests for .git fileLars Hjemli, Feb 6, 2008
  10. Junio C HamanoFeb 6, 2008
  11. Lars HjemliFeb 6, 2008
  12. Junio C HamanoFeb 6, 2008
  13. Lars HjemliFeb 6, 2008

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.