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

Re: [PATCH v3] diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes

From
Tim Henigan <tim.henigan@gmail.com>
Date
Jun 19, 2012, 16:47 UTC
Message-ID
<CAFouetgRq1qkqJmThJJeu=Mdx9jS0c9dw7NPSwuJUOSpskCY2A@mail.gmail.com>
In-Reply-To
<20120619135814.GA3210@sigill.intra.peff.net>
On Tue, Jun 19, 2012 at 9:58 AM, Jeff King <peff@peff.net> wrote:
Show 24 quoted lines
> On Tue, Jun 19, 2012 at 09:05:40AM -0400, Tim Henigan wrote:
>
>> As a side note, I found that these tests fail if a relative path is
>> used for the file in 'non/git'.  In other words, this passes:
>>
>>     test_expect_code 0 git diff --quiet a
>> "$TRASH_DIRECTORY/test-outside/non/git/matching-file"
>>
>> but this fails:
>>
>>     test_expect_code 0 git diff --quiet a ../non/git/matching-file
>>
>> This surprised me, but I have not investigated any further.
>
> The problem is that path_outside_repo in diff-no-index.c does not bother
> handling relative paths at all, and just assumes they are inside the
> repository. This is obviously not true if the path starts with "..", in
> which case you would need to compare the number of ".." with the current
> depth in the repository.
>
> prefix_path already does this (and is what generates the later
> "../non/git/matching-file is not in the repository" message). We could
> perhaps get rid of path_outside_repo and just re-use prefix_path's
> logic, something like (not tested):
With your patch applied, I was able to use relative paths in my tests.
 I also confirmed that all the t4*.sh tests pass.

For what its worth, your patch looks correct to me. Existing consumers of 'prefix_path' should get the same results as before and the one added xmalloc is paired with a free.

Previous: Jeff KingNext: Tim Henigan
Message 6 of 13 in “diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changes”
  1. diff-no-index: exit(1) if 'diff --quiet <repo file> <external file>' finds changesTim Henigan, Jun 18, 2012
  2. Jeff KingJun 18, 2012
  3. Junio C HamanoJun 18, 2012
  4. Tim HeniganJun 19, 2012
  5. Jeff KingJun 19, 2012
  6. Tim HeniganJun 19, 2012
  7. Tim HeniganJun 20, 2012
  8. Jeff KingJun 20, 2012
  9. Junio C HamanoJun 20, 2012
  10. Jeff KingJun 20, 2012
  11. Junio C HamanoJun 20, 2012
  12. Tim HeniganJun 21, 2012
  13. Junio C HamanoJun 21, 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.