js/maint-receive-pack-symref-alias
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest3 patches 4 repliesIn review
- v22 patches 3 repliesSuperseded
- v12 patches 3 repliesSuperseded
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | receive-pack: switch global variable 'commands' to a parameterbuiltin-receive-pack.c | +27 | 0 replies | |
| 2/3 | t5516-fetch-push.sh: style cleanupt/ | +46 | 0 replies | |
| 3/3 | receive-pack: detect aliased updates which can occur with symrefsbuiltin-receive-pack.c t/ | +113 | 0 replies | |
| 3/3 | receive-pack: detect aliased updates which can occur with symrefsbuiltin-receive-pack.c t/ | +113 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 0/3] js/maint-receive-pack-symref-alias
- Incorporated Junio's feedback from v1 and v2.
- Rebuilt on-top of f78683f, which is where v1 was applied in pu.
- Added an additional patch to the series to reformat the tests in t5516-fetch-push.sh to use a consistent style, per Junio's tweaks to the test I wrote for v1.
Jay Soffian (3):
receive-pack: switch global variable 'commands' to a parameter t5516-fetch-push.sh: style cleanup
receive-pack: detect aliased updates which can occur with symrefs
builtin-receive-pack.c | 128 ++++++++++++++++++++++++++++++++++-------------- t/t5516-fetch-push.sh | 118 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 186 insertions(+), 60 deletions(-)
interdiff from what's in pu:
builtin-receive-pack.c | 76 +++++++++++++++++++++++++------------ t/t5516-fetch-push.sh | 98 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 126 insertions(+), 48 deletions(-)
builtin-receive-pack.c +52 -24
@@ -130,6 +130,7 @@ static void write_head_info(void)struct command {struct command *next;const char *error_string; +unsigned int skip_update;unsigned char old_sha1[20 ];unsigned char new_sha1[20 ];char ref_name[FLEX_ARRAY ];/* more */
@@ -487,30 +488,67 @@ static void run_update_post_hook(struct command *commands) } } -static int aliased_ref (struct command *cmd,struct string_list *list) +static void check_aliased_update (struct command *cmd,struct string_list *list) {struct string_list_item *item; +struct command *dst_cmd;unsigned char sha1[20 ]; +char cmd_oldh[41 ], cmd_newh[41 ], dst_oldh[41 ], dst_newh[41 ];int flag;const char *dst_name =resolve_ref (cmd->ref_name, sha1,0 , &flag);if (!(flag &REF_ISSYMREF )) -return 0 ; +return ; + +if ((item =string_list_lookup (dst_name, list)) ==NULL ) +return ; + + cmd->skip_update =1 ; + + dst_cmd = (struct command *) item->util; + +if (!hashcmp (cmd->old_sha1, dst_cmd->old_sha1) && + !hashcmp (cmd->new_sha1, dst_cmd->new_sha1)) +return ; + + dst_cmd->skip_update =1 ; + +strcpy (cmd_oldh,find_unique_abbrev (cmd->old_sha1,DEFAULT_ABBREV )); +strcat (cmd_newh,find_unique_abbrev (cmd->new_sha1,DEFAULT_ABBREV )); +strcpy (dst_oldh,find_unique_abbrev (dst_cmd->old_sha1,DEFAULT_ABBREV )); +strcat (dst_newh,find_unique_abbrev (dst_cmd->new_sha1,DEFAULT_ABBREV )); +rp_error ("refusing inconsistent update between symref '%s' (%s..%s) and" +" its target '%s' (%s..%s)" , + cmd->ref_name, cmd_oldh, cmd_newh, + dst_cmd->ref_name, dst_oldh, dst_newh); -if ((item =string_list_lookup (dst_name, list)) !=NULL ) { -struct command *other_cmd = (struct command *) item->util; -return (!(hashcmp (cmd->old_sha1, other_cmd->old_sha1) && -hashcmp (cmd->new_sha1, other_cmd->new_sha1))); + cmd->error_string = dst_cmd->error_string = +"inconsistent aliased update" ; +} + +static void check_aliased_updates (struct command *commands) +{ +struct command *cmd; +struct string_list ref_list = {NULL ,0 ,0 ,0 }; + +for (cmd = commands; cmd; cmd = cmd->next) { +struct string_list_item *item = +string_list_append (cmd->ref_name, &ref_list); + item->util = (void *)cmd; } -return 0 ; +sort_string_list (&ref_list); + +for (cmd = commands; cmd; cmd = cmd->next) +check_aliased_update (cmd, &ref_list); + +string_list_clear (&ref_list,0 ); }static void execute_commands (struct command *commands,const char *unpacker_error) {struct command *cmd;unsigned char sha1[20 ]; -struct string_list ref_list = {NULL ,0 ,0 ,0 };if (unpacker_error) {for (cmd = commands; cmd; cmd = cmd->next)
@@ -524,27 +562,19 @@ static void execute_commands(struct command *commands, const char *unpacker_erroreturn ; } - head_name =resolve_ref ("HEAD" , sha1,0 ,NULL ); +check_aliased_updates (commands); -for (cmd = commands; cmd; cmd = cmd->next) { -struct string_list_item *item = -string_list_append (cmd->ref_name, &ref_list); - item->util = (void *)cmd; - } -sort_string_list (&ref_list); + head_name =resolve_ref ("HEAD" , sha1,0 ,NULL ); -for (cmd = commands; cmd; cmd = cmd->next) { -if (!aliased_ref (cmd, &ref_list)) +for (cmd = commands; cmd; cmd = cmd->next) +if (!cmd->skip_update) cmd->error_string =update (cmd); - } -string_list_clear (&ref_list,0 ); }static struct command *read_head_info (void ) {struct command *commands =NULL ;struct command **p = &commands; -for (;;) {static char line[1000 ];unsigned char old_sha1[20 ], new_sha1[20 ];
@@ -573,12 +603,10 @@ static struct command *read_head_info(void)if (strstr (refname + reflen +1 ,"side-band-64k" )) use_sideband =LARGE_PACKET_MAX ; } - cmd =xmalloc (sizeof (struct command ) + len -80 ); + cmd =xcalloc (1 ,sizeof (struct command ) + len -80 );hashcpy (cmd->old_sha1, old_sha1);hashcpy (cmd->new_sha1, new_sha1);memcpy (cmd->ref_name, line +82 , len -81 ); - cmd->error_string =NULL ; - cmd->next =NULL ; *p = cmd; p = &cmd->next; }
@@ -671,8 +699,8 @@ static const char *unpack(void)static void report (struct command *commands,const char *unpack_status) { -struct strbuf buf =STRBUF_INIT ;struct command *cmd; +struct strbuf buf =STRBUF_INIT ;packet_buf_write (&buf,"unpack %s\n" , unpack_status ? unpack_status :"ok" );
t/t5516-fetch-push.sh +74 -24
208 lines not on this page · raw message