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

Re: [PATCH v5 13/34] directory rename detection: tests for handling overwriting untracked files

From
Elijah Newren <newren@gmail.com>
Date
Jan 4, 2018, 21:10 UTC
Message-ID
<CABPp-BH66p1MU0Ry0LRcSpr7yGZymqwrnBmMh239xO3rgShdcw@mail.gmail.com>
In-Reply-To
<20180104005223.13566-1-szeder.dev@gmail.com>
On Wed, Jan 3, 2018 at 5:52 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:
Show 8 quoted lines
>> +             test $(git rev-parse :0:y/b) = $(git rev-parse O:z/b) &&
>
> There is a test helper for that :)
>
>   test_cmp_rev :0:y/b O:z/b
>
> Note, that this is not only a matter of useful output on failure, but
> also that of correctness and robustness.

Cool, good to know. Is there any reason test_cmp_rev is not documented in t/README?

I already changed these yesterday, as part of trying to avoid the use
of plain 'test' as you suggested (I was just waiting another day or so
for more feedback before resubmitting the series).  Since I tended to
have several of these rev-parse comparisons in a single test, I simply
combined them:
    git rev-parse >actual
      :0:y/b :1:x/c :2:x/c :3:x/c
    git rev-parse >expect
      O:z/b O:x/c A:x/c B:x/c
    test_cmp expect actual

That does result in fewer rev-parse invocations, which is probably good, but the test_cmp_rev does seem slightly more readable. Hmmm...

Show 11 quoted lines
> I noticed that this patch series adds several similar
>
>   test $(git hash-object this) = $(git rev-parse that)
>
> conditions.  Well, for that we don't have a test helper
> function.  Similar 'hash-object = rev-parse' comparisons are already
> present in two other test scripts, so perhaps it's worth adding a
> helper function.  Or you could perhaps
>
>   git cat-file -p that >out &&
>   test_cmp this out
Yeah, I switched these over to the same format above; e.g.
   git hash-object this >actual &&
   git rev-parse that > expect &&
   test_cmp expect actual
That does have the advantage of re-using a similar style.
Show 8 quoted lines
>> +             test "very" = "$(cat y/c)" &&
>> +
>> +             test "important" = "$(cat y/d)" &&
>
> The 'verbose' helper could make conditions like these more, well,
> verbose about their failure:
>
>   verbose test "very" = "$(cat y/c)" &&

Also good to know. Is there any reason the "verbose" helper isn't documented in t/README?

I also switched these over yesterday to write to files and then use test_cmp, but

>> +             test "important" != "$(git rev-parse :3:y/d)" &&
>
> I'm not sure what this condition is supposed to check.

Well that's embarrassing. That was supposed to be 'cat-file -p', not rev-parse. And since I'm already testing that y/d on disk does have "important" as its contents and that :3:y/d matches O:z/c (i.e. has contents of "c"), the check was rather unnecessary, and too easy to false pass. I think I should just remove it (and two others like it).

Previous: SZEDER GáborNext: SZEDER Gábor
Message 33 of 46 in “Add directory rename detection to git”
  1. 00/34 Add directory rename detection to gitElijah Newren, Dec 28, 2017
  2. 03/34 merge-recursive: add explanation for src_entry and dst_entryElijah Newren, Dec 28, 2017
  3. 04/34 directory rename detection: basic testcasesElijah Newren, Dec 28, 2017
  4. SZEDER GáborJan 3, 2018
  5. Elijah NewrenJan 3, 2018
  6. 07/34 directory rename detection: partially renamed directory testcase/discussionElijah Newren, Dec 28, 2017
  7. 08/34 directory rename detection: files/directories in the way of some renamesElijah Newren, Dec 28, 2017
  8. 14/34 directory rename detection: tests for handling overwriting dirty filesElijah Newren, Dec 28, 2017
  9. 10/34 directory rename detection: more involved edge/corner testcasesElijah Newren, Dec 28, 2017
  10. 11/34 directory rename detection: testcases exploring possibly suboptimal mergesElijah Newren, Dec 28, 2017
  11. 19/34 merge-recursive: split out code for determining diff_filepairsElijah Newren, Dec 28, 2017
  12. 22/34 merge-recursive: add get_directory_renames()Elijah Newren, Dec 28, 2017
  13. 28/34 merge-recursive: apply necessary modifications for directory renamesElijah Newren, Dec 28, 2017
  14. 29/34 merge-recursive: avoid clobbering untracked files with directory renamesElijah Newren, Dec 28, 2017
  15. 32/34 directory rename detection: new testcases showcasing a pair of bugsElijah Newren, Dec 28, 2017
  16. 30/34 merge-recursive: fix overwriting dirty files involved in renamesElijah Newren, Dec 28, 2017
  17. 31/34 merge-recursive: fix remaining directory rename + dirty overwrite casesElijah Newren, Dec 28, 2017
  18. 34/34 merge-recursive: ensure we write updates for directory-renamed fileElijah Newren, Dec 28, 2017
  19. 33/34 merge-recursive: avoid spurious rename/rename conflict from dir renamesElijah Newren, Dec 28, 2017
  20. 23/34 merge-recursive: check for directory level conflictsElijah Newren, Dec 28, 2017
  21. 26/34 merge-recursive: check for file level conflicts then get new nameElijah Newren, Dec 28, 2017
  22. 25/34 merge-recursive: add computation of collisions due to dir rename & mergingElijah Newren, Dec 28, 2017
  23. 21/34 merge-recursive: make a helper function for cleanup for handle_renamesElijah Newren, Dec 28, 2017
  24. 20/34 merge-recursive: add a new hashmap for storing directory renamesElijah Newren, Dec 28, 2017
  25. 24/34 merge-recursive: add a new hashmap for storing file collisionsElijah Newren, Dec 28, 2017
  26. 27/34 merge-recursive: when comparing files, don't include treesElijah Newren, Dec 28, 2017
  27. 12/34 directory rename detection: miscellaneous testcases to complete coverageElijah Newren, Dec 28, 2017
  28. 18/34 merge-recursive: make !o->detect_rename codepath more obviousElijah Newren, Dec 28, 2017
  29. 16/34 merge-recursive: introduce new functions to handle rename logicElijah Newren, Dec 28, 2017
  30. 17/34 merge-recursive: fix leaks of allocated renames and diff_filepairsElijah Newren, Dec 28, 2017
  31. 13/34 directory rename detection: tests for handling overwriting untracked filesElijah Newren, Dec 28, 2017
  32. SZEDER GáborJan 4, 2018
  33. Elijah NewrenJan 4, 2018
  34. SZEDER GáborJan 5, 2018
  35. Thomas GummererJan 5, 2018
  36. Elijah NewrenJan 5, 2018
  37. 15/34 merge-recursive: move the get_renames() functionElijah Newren, Dec 28, 2017
  38. 09/34 directory rename detection: testcases checking which side did the renameElijah Newren, Dec 28, 2017
  39. 02/34 merge-recursive: fix logic ordering issueElijah Newren, Dec 28, 2017
  40. 06/34 directory rename detection: testcases to avoid taking detection too farElijah Newren, Dec 28, 2017
  41. 01/34 Tighten and correct a few testcases for merging and cherry-pickingElijah Newren, Dec 28, 2017
  42. 05/34 directory rename detection: directory splitting testcasesElijah Newren, Dec 28, 2017
  43. Elijah NewrenJan 3, 2018
  44. Johannes SixtJan 3, 2018
  45. Elijah NewrenJan 3, 2018
  46. Johannes SixtJan 3, 2018

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.