Re: [PATCH v2 4/9] unpack-trees: add special cwd handling

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

 



On Mon, Nov 29, 2021 at 6:14 AM Derrick Stolee <stolee@xxxxxxxxx> wrote:
>
> On 11/25/2021 3:39 AM, Elijah Newren via GitGitGadget wrote:
> > From: Elijah Newren <newren@xxxxxxxxx>
> >
> > When running commands such as `git reset --hard` from a subdirectory, if
> > that subdirectory is in the way of adding needed files, bail with an
> > error message.
> ...
> > -test_expect_failure 'reset --hard fails if cwd needs to be removed' '
> > +test_expect_success 'reset --hard fails if cwd needs to be removed' '
> >       git checkout foo/bar/baz &&
> >       test_when_finished "git clean -fdx" &&
>
> This test doesn't include any condition on the final state of
> the worktree. I could imagine that an implementation could be
> writing to the worktree incrementally and then bail halfway
> through. A clean "git status" would give us some confidence that
> the worktree and index are in a good state after the command
> fails.

Makes sense; I can add a
   git diff --exit-code HEAD &&
to the test.

> > +     if (o->reset == UNPACK_RESET_OVERWRITE_UNTRACKED) {
> > +             /* Avoid nuking startup_info->original_cwd... */
> > +             if (startup_info->original_cwd &&
> > +                 !strcmp(startup_info->original_cwd, ce->name))
> > +                     return add_rejected_path(o, ERROR_CWD_IN_THE_WAY,
> > +                                              ce->name);
> > +             /* ...but nuke anything else. */
> > +             return 0;
> > +     }
> > +
>
> This implementation appears to do the right thing in the case
> I'm describing: we check which entries would need to change and
> we reject them before doing any real work.

Thanks for taking a look.



[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