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

Re: [PATCH 1/9] t1416: more testcases for reference-transaction hook

From
Jiang Xin <worldhello.net@gmail.com>
Date
Jul 31, 2022, 03:25 UTC
Message-ID
<CANYiYbHcd3UNF2vq6YLQifEWW6eSLhB=7d23907TAbUeum2w0A@mail.gmail.com>
In-Reply-To
<CAPig+cQyW4Bz1kL5MriXeU6Zd93oYQU8ZuA-1gaEmAERpbTaDA@mail.gmail.com>
On Sat, Jul 30, 2022 at 2:44 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 18 quoted lines
> Now that the function breaks out of the loop properly with `|| return
> 1` upon failure, it's no longer necessary to perform the directory
> check at the top of the function since the call to test_commit() will
> correctly fail if the directory does not exist. So, the function can
> be shortened to:
>
>     create_commits_in () {
>         local repo="$1" &&
>         shift &&
>         while test $# -gt 0
>         do
>             local name=$1 &&
>             shift &&
>             test_commit -C "$repo" --no-tag "$name" &&
>             local rev=$(git -C "$repo" rev-parse HEAD) &&
>             eval $name=$rev || return 1
>         done
>     }

Thanks, Eric. Appreciate for all suggestions. I prefer this version and will use it in reroll v2.

Show 11 quoted lines
> > +       done &&
> > +       expect=${1:-expect} &&
> > +       actual=${2:-actual-heads-and-tags} &&
> > +       indir=${indir:+"$indir"/} &&
> > +       test_path_is_file "$expect" &&
> > +       test_when_finished "rm -f \"$actual\"" &&
> > +       git ${indir:+ -C "$indir"} show-ref --heads --tags | \
> > +               make_user_friendly_and_stable_output >"$actual" &&
>
> The exit code from `git show-ref` is being lost down the pipe. You
> also don't need the `\` after `|`.
Will remove unnecessary backslash before EOL.
Show 8 quoted lines
> > +       test_cmp "$expect" "$actual"
> > +}
> > +
> > +test_expect_success 'setup git config and common reference-transaction hook' '
> > +       git config --global \
> > +               core.hooksPath "$HOME/test-hooks" &&
>
> Nit: This would fit nicely on a single line; no need for the line splicing.
Will write in oneline.
Show 12 quoted lines
> > +       git config --global core.abbrev 7 &&
> > +       mkdir "test-hooks" &&
> > +       write_script "test-hooks/reference-transaction" <<-EOF
> > +               exec >>"$HOME/$HOOK_OUTPUT"
> > +               printf "## Call hook: reference-transaction %9s ##\n" "\$@"
> > +               while read -r line
> > +               do
> > +                   printf "%s\n" "\$line"
>
> Nit This is the same as:
>
>     echo "\$line"
Will do.
Show 14 quoted lines
> > +               done
> > +       EOF
> > +'
> > +
> > +test_expect_success "update-ref: create new refs" '
> > +       test_when_finished "rm -f $HOOK_OUTPUT" &&
> > +
> > +       cat >expect <<-EOF &&
> > +               ## Call hook: reference-transaction  prepared ##
>
> This and a bunch of other here-doc tags in subsequent tests are
> missing the backslash:
>
>     cat >expect <<-\EOF &&
Will add backslash unless there are variables need to be expanded.
Previous: Eric SunshineNext: Jiang Xin
Message 6 of 27 in “Fix issues of reference-transaction hook for various git commands”
  1. 0/9 Fix issues of reference-transaction hook for various git commandsJiang Xin, Jul 29, 2022
  2. 2/9 refs: update missing old-oid in transaction from lockfileJiang Xin, Jul 29, 2022
  3. 3/9 refs: add new field in transaction for running transaction hookJiang Xin, Jul 29, 2022
  4. 1/9 t1416: more testcases for reference-transaction hookJiang Xin, Jul 29, 2022
  5. Eric SunshineJul 30, 2022
  6. Jiang XinJul 31, 2022
  7. 4/9 refs: do not run transaction hook for git-pack-refsJiang Xin, Jul 29, 2022
  8. 5/9 refs: avoid duplicate running of the reference-transaction hookJiang Xin, Jul 29, 2022
  9. Michael HeemskerkAug 2, 2022
  10. Jiang XinAug 5, 2022
  11. 0/9 Fix issues of refx-txn hook for various git commandsJiang Xin, Aug 19, 2022
  12. 2/9 refs: update missing old-oid in transaction from lockfileJiang Xin, Aug 19, 2022
  13. 3/9 refs: add new field in transaction for running transaction hookJiang Xin, Aug 19, 2022
  14. 1/9 t1416: more testcases for reference-transaction hookJiang Xin, Aug 19, 2022
  15. 4/9 refs: do not run transaction hook for git-pack-refsJiang Xin, Aug 19, 2022
  16. 5/9 refs: avoid duplicate running of the reference-transaction hookJiang Xin, Aug 19, 2022
  17. 6/9 refs: add reflog_info to hold more fields for reflog entryJiang Xin, Aug 19, 2022
  18. 9/9 refs: reimplement refs_delete_refs() and run hook onceJiang Xin, Aug 19, 2022
  19. 7/9 refs: get error message via refs_update_ref_extended()Jiang Xin, Aug 19, 2022
  20. 8/9 refs: reimplement files_copy_or_rename_ref() to run refs-txn hookJiang Xin, Aug 19, 2022
  21. 6/9 refs: add reflog_info to hold more fields for reflog entryJiang Xin, Jul 29, 2022
  22. Jiang XinAug 1, 2022
  23. 7/9 refs: get error message via refs_update_ref_extended()Jiang Xin, Jul 29, 2022
  24. 8/9 refs: reimplement files_copy_or_rename_ref() to run hookJiang Xin, Jul 29, 2022
  25. 9/9 refs: reimplement refs_delete_refs() and run hook onceJiang Xin, Jul 29, 2022
  26. Michael HeemskerkAug 2, 2022
  27. Patrick SteinhardtAug 9, 2022

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.