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

Re: [PATCH] rebase, cherry-pick, revert: only run from toplevel

From
Elijah Newren <newren@gmail.com>
Date
Sep 1, 2021, 06:08 UTC
Message-ID
<CABPp-BFET9PhgAh+xvMWzTGD+pW3ujOUXO6JOF1rtFMMpDHZvg@mail.gmail.com>
In-Reply-To
<xmqqk0k0sw2h.fsf@gitster.g>
On Tue, Aug 31, 2021 at 10:29 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
>
> Elijah Newren <newren@gmail.com> writes:
>
> > Ooh, this sounds intriguing to me...but what if we changed that rule
> > slightly and just decided to never make the cwd go away?  Currently,
> > the checkout code removes directories if they have no tracked or
> > untracked or ignored files left, i.e. if they're empty.  What if we
> > decide to only have remove_scheduled_dirs() remove directories that
> > are empty AND they are not the current working directory?
>
> Is that generally doable?  What would we do when the directory the
> subcommand was started from (or one of its parent directories) is
> not just missing but has to be a file in the revision the subcommand
> is trying to checkout?

The same problem (an untracked directory is in the way) already exists and has to be handled by all relevant subcommands, right?

In particular, if the current working directory only has untracked files in it, then the directory cannot be removed. That will prevent us from checking out the revision we want, so we have to throw an error.

So my idea just piggy backs on that, resulting in the same error also being shown when the current working directory has 0 untracked files within it.

Since the whole thread started from, "maybe we should throw an error instead of continuing if it would result in the current working directory getting deleted", I believe this idea does exactly what we were looking for...and nicely tailors the new error cases to precisely the situations we wanted them for -- when the current working directory would have been removed by the old code.

Previous: Junio C HamanoNext: Jeff King
Message 11 of 12 in “rebase, cherry-pick, revert: only run from toplevel”
  1. rebase, cherry-pick, revert: only run from toplevelElijah Newren via GitGitGadget, Aug 31, 2021
  2. Elijah NewrenAug 31, 2021
  3. Johannes SixtAug 31, 2021
  4. Jeff KingAug 31, 2021
  5. Elijah NewrenAug 31, 2021
  6. Taylor BlauSep 1, 2021
  7. Elijah NewrenSep 1, 2021
  8. Taylor BlauSep 1, 2021
  9. Elijah NewrenSep 1, 2021
  10. Junio C HamanoSep 1, 2021
  11. Elijah NewrenSep 1, 2021
  12. Jeff KingSep 1, 2021

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.