Re: [PATCH 2/6] Split unpack_trees 'reset' flag into two for untracked handling
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Sep 19, 2021, 13:48 UTC
- Message-ID
- <87wnncbrm4.fsf@evledraar.gmail.com>
- In-Reply-To
- <45bd05a945f034d03555f04a1ba85835482dc591.1632006923.git.gitgitgadget@gmail.com>
On Sat, Sep 18 2021, Elijah Newren via GitGitGadget wrote:
Show 7 quoted lines
> - opts.reset = reset; > + opts.reset_keep_untracked = reset; > opts.fn = twoway_merge; > + /* Setup opts.dir so that ignored files in the way get overwritten */ > + opts.dir = xcalloc(1, sizeof(*opts.dir)); > + opts.dir->flags |= DIR_SHOW_IGNORED; > + setup_standard_excludes(opts.dir);
Is the "opts.dir" free'd later somehow?
Show 8 quoted lines
> opts.head_idx = -1; > opts.update = worktree; > opts.skip_unmerged = !worktree; > - opts.reset = 1; > + if (o->force) > + opts.reset_nuke_untracked = 1; > + else > + opts.reset_keep_untracked = 1;
In both cases opts.reset_keep_untracked is set to 1, I assume it's a mistake, aside from that perhaps betteras:
opts.reset_keep_untracked = o->force; /* or !o->force, depending... */
Show 7 quoted lines
> opts.merge = 1;
> opts.fn = oneway_merge;
> opts.verbose_update = o->show_progress;
> opts.src_index = &the_index;
> opts.dst_index = &the_index;
> + if (o->overwrite_ignore) {
> + opts.dir = xcalloc(1, sizeof(*opts.dir));ditto potential leak.
> + opts.dir = xcalloc(1, sizeof(*opts.dir)); > + opts.dir->flags |= DIR_SHOW_IGNORED; > + setup_standard_excludes(opts.dir); > + }
ditto (also more omitted).