Re: [PATCH v4 08/12] rebase: update refs from 'update-ref' commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/15/2022 9:25 AM, Phillip Wood wrote:
>> Now that the 'git rebase --update-refs' command is implemented to write
>> to the update-refs file, we can remove the fake construction of the
>> update-refs file from a test in t2407-worktree-heads.sh.
> 
> This is looking good. I've left a few comments, mostly about error propagation. It's nice to see us recording the initial value of the ref when the todo list is created. It's also good to see this using a lock file. We could perhaps lock the file (with a timeout) when we read it in sequencer_get_update_refs_state() to avoid a race where a process is checking out a new branch in one worktree and another is preparing to rebase that branch in another worktree.

>> +static int do_update_ref(struct repository *r, const char *refname)
>> +{
>> +    struct string_list_item *item;
>> +    struct string_list list = STRING_LIST_INIT_DUP;
>> +
>> +    sequencer_get_update_refs_state(r->gitdir, &list);
> 
> We're ignoring any errors here and always returning 0 from this function.

Thanks. Will fix.
 
>> +
>> +    for_each_string_list_item(item, &list) {
>> +        if (!strcmp(item->string, refname)) {
>> +            struct update_ref_record *rec = item->util;
>> +            read_ref("HEAD", &rec->after);

This is the other place where we could have a failure.

>>   +static int do_update_refs(struct repository *r)
>> +{
>> +    int res = 0;
>> +    struct string_list_item *item;
>> +    struct string_list refs_to_oids = STRING_LIST_INIT_DUP;
>> +    struct ref_store *refs = get_main_ref_store(r);
>> +
>> +    sequencer_get_update_refs_state(r->gitdir, &refs_to_oids);

We need to check for failure here, too.

>> +    for_each_string_list_item(item, &refs_to_oids) {
>> +        struct update_ref_record *rec = item->util;
>> +
>> +        if (oideq(&rec->after, the_hash_algo->null_oid)) {
>> +            /*
>> +             * Ref was not updated. User may have deleted the
>> +             * 'update-ref' step.
>> +             */
> 
> Unless we want to support users editing the todo list without using "git rebase --edit-todo" then by the end of the series it is a bug if we leave an entry in the update-refs file that has been removed from the todo list so I wander if we should remove this if().

I think this is leftover from the previous version and will
never happen. If rec->after is null, then it would be removed
earlier when parsing the todo list.

>>   +    do_update_refs(r);
> 
> Should this be inside the "if (is_rebase_i(opts))" that is closed just above it? We're also ignoring the return value.

Couldn't hurt. Should be a no-op if not in interactive mode.

>>   +    write_update_refs_state(&ctx.refs_to_oids);
> 
> We're ignoring the return value. Also I think todo_list_add_update_ref_commands() only ever returns 0.

Thanks for your attention to detail here.

-Stolee



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux