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

Re: [PATCH v3] git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dir

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 14, 2008, 03:54 UTC
Message-ID
<7v4p174diu.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1229201231-12586-1-git-send-email-marcel@oak.homeunix.org>
"Marcel M. Cary" <marcel@oak.homeunix.org> writes:
> I also removed the "pwd -P" from the unit test.
Hmm, really...?
Show 17 quoted lines
>> > +# Prove that the remote end really is a repo, and other commands
>> > +# work fine in this context.
>> > +#
>> > +test_debug "
>> > +    test_expect_success 'pushing from symlinked subdir' '
>> > +
>> > +        git push
>> > +    '
>> > +"
>> 
>> Why should this be hidden inside test_debug?
>
> I'm not particularly trying to test "git push" or "git pull" in general
> here.  That's also why the other "git pull" was in a test_debug.  I
> thought it was really only useful to someone trying to understand the
> contents of the test file.  There are other files that cover push and
> pull.  Do you think these test cases should run all the time here?

I'd say so. Your supporting argument could be "See, push works just fine with this layout, but pull doesn't because it is a shell script that can be fooled, and this change is to fix the inconsistencies between them." Having these test enabled would be a good way to do so. Then it becomes irrelevant if "jump into the middle of a directory hierarchy sideways via symlink" is worth supporting or not ;-)

But whether it is inside test_debug or not, the test should check not just the exit status from 'git push' but also check what happened to the receiving repository at least to make sure it is pushing to the location you are expecting it to.

Show 22 quoted lines
> diff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh
> new file mode 100755
> index 0000000..05854b4
> --- /dev/null
> +++ b/t/t2300-cd-to-toplevel.sh
> @@ -0,0 +1,37 @@
> +#!/bin/sh
> +
> +test_description='cd_to_toplevel'
> +
> +. ./test-lib.sh
> +
> +test_cd_to_toplevel () {
> +	test_expect_success "$2" '
> +		(
> +			cd '"'$1'"' &&
> +			. git-sh-setup &&
> +			cd_to_toplevel &&
> +			[ "$(pwd -P)" = "$TOPLEVEL" ]
> +		)
> +	'
> +}

The quoting of $1 here is a bit tricky, but I think it is good enough for directory names used in tests that use this function.

Previous: Marcel M. CaryNext: Marcel M. Cary
Message 19 of 27 in “fixing git pull from symlinked directory”
  1. 0/2 fixing git pull from symlinked directoryMarcel M. Cary, Nov 15, 2008
  2. 1/2 Add failing test for "git pull" in symlinked directoryMarcel M. Cary, Nov 15, 2008
  3. 2/2 Support shell scripts that run from symlinks into a git working dirMarcel M. Cary, Nov 15, 2008
  4. rev-parse: Fix shell scripts whose cwd is a symlink into a git work-dirMarcel M. Cary, Nov 22, 2008
  5. Jakub NarebskiNov 22, 2008
  6. Andreas EricssonNov 23, 2008
  7. Marcel M. CaryNov 25, 2008
  8. Andreas EricssonNov 25, 2008
  9. Marcel M. CaryNov 25, 2008
  10. Johannes SixtNov 25, 2008
  11. Marcel M. CaryNov 25, 2008
  12. Johannes SixtNov 25, 2008
  13. Junio C HamanoNov 25, 2008
  14. git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dirMarcel M. Cary, Dec 3, 2008
  15. Junio C HamanoDec 3, 2008
  16. git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dirMarcel M. Cary, Dec 10, 2008
  17. Junio C HamanoDec 10, 2008
  18. git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dirMarcel M. Cary, Dec 13, 2008
  19. Junio C HamanoDec 14, 2008
  20. git-sh-setup: Fix scripts whose PWD is a symlink into a git work-dirMarcel M. Cary, Dec 15, 2008
  21. Marcel M. CaryDec 15, 2008
  22. git-sh-setup: Use "cd" option, not /bin/pwd, for symlinked work treeMarcel M. Cary, Feb 7, 2009
  23. Johannes SchindelinFeb 7, 2009
  24. Marcel M. CaryFeb 8, 2009
  25. Johannes SchindelinFeb 8, 2009
  26. Marcel M. CaryFeb 11, 2009
  27. Jeff KingFeb 11, 2009

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.