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

Re: [PATCH 9/9] subtree: fix split after annotated tag was squashed merged

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Oct 26, 2022, 21:26 UTC
Message-ID
<b83b8c41-07c9-ba5a-93a0-ed0ae4c9d3cd@gmail.com>
In-Reply-To
<221021.86mt9pdtcw.gmgdl@evledraar.gmail.com>
Le 2022-10-21 à 12:37, Ævar Arnfjörð Bjarmason a écrit :
Show 51 quoted lines
> 
> On Fri, Oct 21 2022, Philippe Blain via GitGitGadget wrote:
> 
>> From: Philippe Blain <levraiphilippeblain@gmail.com>
>>
>> The previous commit fixed a failure in 'git subtree merge --squash' when
>> the previous squash-merge merged an annotated tag of the subtree
>> repository which is missing locally.
>>
>> The same failure happens in 'git subtree split', either directly or when
>> called by 'git subtree push', under the same circumstances: 'cmd_split'
>> invokes 'find_existing_splits', which loops through previous commits and
>> invokes 'git rev-parse' (via 'process_subtree_split_trailer') on the
>> value of any 'git subtree-split' trailer it finds. This fails if this
>> value is the hash of an annotated tag which is missing locally.
>>
>> Add a new optional argument 'repository' to 'cmd_split' and
>> 'find_existing_splits', and invoke 'cmd_split' with that argument from
>> 'cmd_push'. This allows 'process_subtree_split_trailer' to try to fetch
>> the missing tag from the 'repository' if it's not available locally,
>> mirroring the new behaviour of 'git subtree pull' and 'git subtree
>> merge'.
>>
>> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
>> ---
>>  contrib/subtree/git-subtree.sh     | 26 ++++++++++++++++++--------
>>  contrib/subtree/git-subtree.txt    |  7 ++++++-
>>  contrib/subtree/t/t7900-subtree.sh | 12 ++++++++++++
>>  3 files changed, 36 insertions(+), 9 deletions(-)
>>
>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
>> index 2c67989fe8a..10c9c87839a 100755
>> --- a/contrib/subtree/git-subtree.sh
>> +++ b/contrib/subtree/git-subtree.sh
>> @@ -453,14 +453,19 @@ find_latest_squash () {
>>  	done || exit $?
>>  }
>>  
>> -# Usage: find_existing_splits DIR REV
>> +# Usage: find_existing_splits DIR REV [REPOSITORY]
>>  find_existing_splits () {
>> -	assert test $# = 2
>> +	assert test $# = 2 -o $# = 3
> 
> This "test" syntax is considered unportable, I'm too lazy to dig up the
> reference, but we've removed it in the past. Maybe it's OK with
> git-subtree.sh", but anyway, it's esay enough to change...
> 
> ...but looking at "master" I see one instance of it in git-subtree.sh
> already, so maybe nobody cares...
> 

I did not know it was not portable, in fact I used this form because while reading the rest of the script I found that was the style used already.

So I guess I would leave this as a further cleanup for someone wishing to make 'git subtree' more POSIX...

Previous: Eric SunshineNext: Philippe Blain via GitGitGadget
Message 18 of 20 in “subtree: fix split and merge after annotated tag was squash-merged”
  1. 0/9 subtree: fix split and merge after annotated tag was squash-mergedPhilippe Blain via GitGitGadget, Oct 21, 2022
  2. 3/9 subtree: add 'die_incompatible_opt' function to reduce duplicationPhilippe Blain via GitGitGadget, Oct 21, 2022
  3. Ævar Arnfjörð BjarmasonOct 21, 2022
  4. Philippe BlainOct 26, 2022
  5. 1/9 test-lib-functions: mark 'test_commit' variables as 'local'Philippe Blain via GitGitGadget, Oct 21, 2022
  6. Junio C HamanoOct 21, 2022
  7. Philippe BlainOct 26, 2022
  8. Junio C HamanoOct 26, 2022
  9. 5/9 subtree: define a variable before its first use in 'find_latest_squash'Philippe Blain via GitGitGadget, Oct 21, 2022
  10. 2/9 subtree: use 'git rev-parse --verify [--quiet]' for better error messagesPhilippe Blain via GitGitGadget, Oct 21, 2022
  11. 4/9 subtree: prefix die messages with 'fatal'Philippe Blain via GitGitGadget, Oct 21, 2022
  12. Ævar Arnfjörð BjarmasonOct 21, 2022
  13. Philippe BlainOct 26, 2022
  14. 7/9 subtree: process 'git-subtree-split' trailer in separate functionPhilippe Blain via GitGitGadget, Oct 21, 2022
  15. 9/9 subtree: fix split after annotated tag was squashed mergedPhilippe Blain via GitGitGadget, Oct 21, 2022
  16. Ævar Arnfjörð BjarmasonOct 21, 2022
  17. Eric SunshineOct 21, 2022
  18. Philippe BlainOct 26, 2022
  19. 8/9 subtree: fix squash merging after annotated tag was squashed mergedPhilippe Blain via GitGitGadget, Oct 21, 2022
  20. 6/9 subtree: use named variables instead of "$@" in cmd_pullPhilippe Blain via GitGitGadget, Oct 21, 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.