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

Re: [PATCH (Apple Git) 03/13] t0500: New regression test for git add of a path that contains a .git directory

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 30, 2019, 11:47 UTC
Message-ID
<CAPig+cR_p9ybUjfSqY_Kod39Ztxt9Y7Js=QvFU-WDJh58sb5Yg@mail.gmail.com>
In-Reply-To
<20190129193818.8645-4-jeremyhu@apple.com>

On Tue, Jan 29, 2019 at 4:19 PM Jeremy Huddleston Sequoia <jeremyhu@apple.com> wrote:

> Subject: t0500: New regression test for git add of a path that contains a .git directory

Please describe the actual problem here in the commit message so readers of this change can understand what this is all about.

Show 10 quoted lines
> Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
> ---
> diff --git a/t/t0500-apple.sh b/t/t0500-apple.sh
> @@ -0,0 +1,40 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2012-2016 Apple Inc.
> +#
> +# Tests for regressions found by Apple Inc. for issues that upstream does not
> +# want to fix or accept tests for.
This is an odd comment for a patch which is intended to be upstreamed.
> +test_description='Apple Inc. specific tests'

Is this script actually specific to Apple? If not, a better description is likely warranted. Alternatively, place this new test in an appropriate existing test script.

> +# <rdar://problem/10238070>
Inaccessible private bug report. Please describe the actual regression here.
Show 5 quoted lines
> +# This test case addresses a regression introduced between v1.7.3 and v1.7.5
> +# git bisect good v1.7.3
> +# git bisect bad v1.7.5
> +# ...
> +# found 18e051a3981f38db08521bb61ccf7e4571335353

This commentary isn't very useful going forward, thus not worth having in the script itself, although it may make useful information for the commit message (though more likely not). Usually, such commentary would be placed below the "---" line just under your sign-off.

> +test_expect_success '<rdar://problem/10238070> -- git add of a path that contains a .git directory' '

As above, a better title would be welcome, one which actually means something to people without access to the private bug report.

> +       rm -rf .git &&
> +       mkdir -p orig/sub/dir/otherdir &&
> +       cd orig/sub &&

We don't 'cd' around inside tests without ensuring that the 'cd' is undone automatically even if the test fails. (See below.)

> +       echo "1" > dir/file &&
> +       echo "2" > dir/otherdir/file &&
> +       git init --quiet &&

Why --quiet? Output generated by commands is already suppressed by default when the test is run normally, but it is useful to have when something goes wrong, so we don't usually want to suppress it manually. Same comment applies to >/dev/null redirects.

> +       git add -A &&
> +       git commit -m "Initial Commit" --quiet &&
> +       cd - > /dev/null &&

If something fails above this point, then this "cd -" will never execute, so any tests which get added below this one in the script will operate in the wrong directory. The normal way to 'cd' within a test is within a subshell so the 'cd' is undone automatically whether the test fails or not:

    (
        cd orig/sub
        ...
    )
Show 6 quoted lines
> +       git init --bare --quiet "${TESTROOT}/git_dir.git" &&
> +       git --git-dir="${TESTROOT}/git_dir.git" --work-tree=/ add -f -- "${TESTROOT}/orig/sub/" &&
> +       git --git-dir="${TESTROOT}/git_dir.git" --work-tree=/ add -f -- "${TESTROOT}/orig/" &&
> +       git --git-dir="${TESTROOT}/git_dir.git" --work-tree=/ commit -m "Commit." |
> +               grep -q "2 files changed, 2 insertions"
> +'

We don't normally place a Git command upstream of a pipe since its exit status will get swallowed by the pipe, thus potentially losing important information. Instead, redirect the command output to a file and 'grep' on the file.

Also, the string you're grepping is likely to be localized, so use test_i18ngrep() instead.

Previous: Jeremy Huddleston SequoiaNext: Johannes Schindelin
Message 38 of 63 in “Differences between git-2.20.1 and Apple Git-116”
  1. 00/13 Differences between git-2.20.1 and Apple Git-116Jeremy Huddleston Sequoia, Jan 29, 2019
  2. 05/13 t5701: git --version can have SP in itJeremy Huddleston Sequoia, Jan 29, 2019
  3. Johannes SchindelinJan 30, 2019
  4. Jeremy Huddleston SequoiaJan 30, 2019
  5. 08/13 git mergetool/difftool doesn't list 'opendiff' as an available tool on 10.8Jeremy Huddleston Sequoia, Jan 29, 2019
  6. Johannes SchindelinJan 30, 2019
  7. 06/13 Set Apple Git version during buildJeremy Huddleston Sequoia, Jan 29, 2019
  8. Johannes SchindelinJan 30, 2019
  9. Jeremy Huddleston SequoiaJan 30, 2019
  10. 09/13 Use symbolic links rather than hard links for files in libexecJeremy Huddleston Sequoia, Jan 29, 2019
  11. brian m. carlsonJan 30, 2019
  12. Jeremy Huddleston SequoiaJan 30, 2019
  13. Johannes SchindelinJan 30, 2019
  14. Jeremy Huddleston SequoiaJan 30, 2019
  15. 01/13 .gitignore: Remove *.s as it matches *.S on case insensitive filesystemJeremy Huddleston Sequoia, Jan 29, 2019
  16. Eric SunshineJan 30, 2019
  17. Jeremy Huddleston SequoiaJan 30, 2019
  18. Eric SunshineJan 30, 2019
  19. Eric SunshineJan 30, 2019
  20. Johannes SchindelinJan 30, 2019
  21. Jeremy Huddleston SequoiaJan 30, 2019
  22. Junio C HamanoJan 31, 2019
  23. Jeremy SequoiaJan 31, 2019
  24. Eric SunshineJan 31, 2019
  25. Junio C HamanoJan 30, 2019
  26. 04/13 t4014: git --version can have SP in itJeremy Huddleston Sequoia, Jan 29, 2019
  27. Junio C HamanoJan 29, 2019
  28. Johannes SchindelinJan 30, 2019
  29. 10/13 Support for Xcode.app co-exestince and relocationJeremy Huddleston Sequoia, Jan 29, 2019
  30. Johannes SchindelinJan 30, 2019
  31. Jeremy Huddleston SequoiaJan 30, 2019
  32. 07/13 HTML documentation is not provided with Apple's git. Make the error message more on point.Jeremy Huddleston Sequoia, Jan 29, 2019
  33. Junio C HamanoJan 29, 2019
  34. Johannes SchindelinJan 30, 2019
  35. Junio C HamanoJan 30, 2019
  36. Johannes SchindelinJan 30, 2019
  37. 03/13 t0500: New regression test for git add of a path that contains a .git directoryJeremy Huddleston Sequoia, Jan 29, 2019
  38. Eric SunshineJan 30, 2019
  39. Johannes SchindelinJan 30, 2019
  40. Jeremy Huddleston SequoiaJan 30, 2019
  41. 12/13 Enable support for Xcode.app-bundled gitconfigJeremy Huddleston Sequoia, Jan 29, 2019
  42. Junio C HamanoJan 29, 2019
  43. Jeremy Huddleston SequoiaJan 29, 2019
  44. Johannes SchindelinJan 30, 2019
  45. Jeremy Huddleston SequoiaJan 30, 2019
  46. Jeremy Huddleston SequoiaJan 30, 2019
  47. Jonathan NiederJan 31, 2019
  48. Jeremy Huddleston SequoiaJan 31, 2019
  49. Junio C HamanoJan 31, 2019
  50. brian m. carlsonJan 30, 2019
  51. 13/13 Enable support for Xcode.app-bundled gitattributesJeremy Huddleston Sequoia, Jan 29, 2019
  52. 02/13 test-lib: Export PERL5LIB for testing git-svnJeremy Huddleston Sequoia, Jan 29, 2019
  53. Junio C HamanoJan 29, 2019
  54. Jeremy Huddleston SequoiaJan 29, 2019
  55. SZEDER GáborJan 29, 2019
  56. Jeremy SequoiaJan 30, 2019
  57. Junio C HamanoJan 30, 2019
  58. Carlo ArenasJan 30, 2019
  59. Johannes SchindelinJan 30, 2019
  60. Jeremy SequoiaJan 30, 2019
  61. 11/13 Fix problem found from running the test suite.Jeremy Huddleston Sequoia, Jan 29, 2019
  62. Junio C HamanoJan 29, 2019
  63. Eric WongJan 29, 2019

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.