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

Re: [PATCH 2/3] branch: add test for -m renaming multiple config sections

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 13, 2017, 17:31 UTC
Message-ID
<CACBZZX5e1cGKeHZhA1vWebdZek=a+TdYzXc5GuXaDi8SpL1YXw@mail.gmail.com>
In-Reply-To
<xmqqwp8f7r01.fsf@gitster.mtv.corp.google.com>
On Tue, Jun 13, 2017 at 7:10 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 30 quoted lines
> Sahil Dua <sahildua2305@gmail.com> writes:
>
>> +     cat >expect <<-\EOF &&
>> +     branch.dest.key1=value1
>> +     some.gar.b=age
>> +     branch.dest.key2=value2
>> +     EOF
>> +     cat >config.branch <<\EOF &&
>> +;; Comment for source
>> +[branch "source"]
>> +     ;; Comment for the source value
>> +     key1 = value1
>> +     ;; Comment for some.gar
>> +[some "gar"]
>> +     ;; Comment for the some.gar value
>> +     b = age
>> +     ;; Comment for source, again
>> +[branch "source"]
>> +     ;; Comment for the source value, again
>> +     key2 = value2
>> +EOF
>
> Indenting using <<- would make it easier to read.  I.e.
>
>         cat >config.branch <<-\EOF &&
>         ;; Comment for ...
>         [branch "source"]
>                 ;; Comment for ...
>         ...
>         EOF

I should have added a comment for that, I can't find any portable (but suggestions welcome) way to do that and preserve the indentation, so the test_cmp would still succeed if the moving/renaming function munged all leading whitespace in the config with -\EOF as opposed to \EOF.

Show 18 quoted lines
>> +     cat config.branch >>.git/config &&
>> +     git branch -m source dest &&
>> +     git config -f .git/config -l | grep -F -e source -e dest -e some.gar >actual &&
>> +     test_cmp expect actual &&
>> +
>> +     # ...and that the comments for those sections are also
>> +     # preserved.
>> +     cat config.branch | sed "s/\"source\"/\"dest\"/" >expect &&
>> +     grep -A 9001 "Comment for source" .git/config >actual &&
>
> Where does 9001 come from?  Is that just "an arbitrary large
> number"?
>
> Besides, "grep -A" is quite unportable.  Would
>
>         sed -n -e "/Comment for source/,$p" .git/config >actual
>
> work equally well?

It's just a sufficiently large number, I thought -A was portable enough after grepping the test suite, but on closer inspection it turns out those were all git-grep invocations, oops. Yeah all I need here is all lines after a line matching a given string, so that sed command works, will fix it up to use that.

Show 9 quoted lines
>> +     test_cmp expect actual
>> +'
>> +
>>  test_expect_success 'deleting a symref' '
>>       git branch target &&
>>       git symbolic-ref refs/heads/symref refs/heads/target &&
>>
>> --
>> https://github.com/git/git/pull/363
Previous: Junio C HamanoNext: Junio C Hamano
Message 26 of 39 in “branch: add tests for new copy branch feature”
  1. 1/6 branch: add tests for new copy branch featureSahil Dua, May 31, 2017
  2. 4/6 config: modify function signature to include copy argumentSahil Dua, May 31, 2017
  3. 6/6 branch: don't copy or rename config when same branch nameSahil Dua, May 31, 2017
  4. 3/6 config: abstract out create section from key logicSahil Dua, May 31, 2017
  5. 2/6 branch: add copy branch optionSahil Dua, May 31, 2017
  6. Junio C HamanoJun 1, 2017
  7. Sahil DuaJun 1, 2017
  8. 5/6 config: add copy config section logicSahil Dua, May 31, 2017
  9. 1/3 branch: add tests for new copy branch featureSahil Dua, Jun 1, 2017
  10. 2/3 config: abstract out create section from key logicSahil Dua, Jun 1, 2017
  11. 3/3 branch: add copy branch feature implementationSahil Dua, Jun 1, 2017
  12. Ævar Arnfjörð BjarmasonJun 1, 2017
  13. Sahil DuaJun 1, 2017
  14. 1/3 branch: add tests for new copy branch featureSahil Dua, Jun 5, 2017
  15. 2/3 config: abstract out create section from key logicSahil Dua, Jun 5, 2017
  16. 3/3 branch: add copy branch feature implementationSahil Dua, Jun 5, 2017
  17. Sahil DuaJun 5, 2017
  18. Junio C HamanoJun 6, 2017
  19. Junio C HamanoJun 6, 2017
  20. Ævar Arnfjörð BjarmasonJun 6, 2017
  21. Sahil DuaJun 6, 2017
  22. Junio C HamanoJun 6, 2017
  23. 1/3 config: create a function to format section headersSahil Dua, Jun 13, 2017
  24. 2/3 branch: add test for -m renaming multiple config sectionsSahil Dua, Jun 13, 2017
  25. Junio C HamanoJun 13, 2017
  26. Ævar Arnfjörð BjarmasonJun 13, 2017
  27. Junio C HamanoJun 13, 2017
  28. Ævar Arnfjörð BjarmasonJun 13, 2017
  29. 2/3 branch: add test for -m renaming multiple config sectionsSahil Dua, Jun 18, 2017
  30. 3/3 branch: add a --copy (-c) option to go with --move (-m)Sahil Dua, Jun 13, 2017
  31. Junio C HamanoJun 13, 2017
  32. Junio C HamanoJun 13, 2017
  33. Sahil DuaJun 14, 2017
  34. 3/3 branch: add a --copy (-c) option to go with --move (-m)Sahil Dua, Jun 18, 2017
  35. Junio C HamanoJun 13, 2017
  36. Ævar Arnfjörð BjarmasonJun 13, 2017
  37. 1/3 config: create a function to format section headersSahil Dua, Jun 18, 2017
  38. Ramsay JonesJun 19, 2017
  39. Sahil DuaJun 19, 2017

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.