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

Re: [RFC] require-work-tree wants more than what its name says

From
Jeff King <peff@peff.net>
Date
May 4, 2011, 08:50 UTC
Message-ID
<20110504085014.GA9739@sigill.intra.peff.net>
In-Reply-To
<4DC112A1.5090805@drmicha.warpmail.net>
On Wed, May 04, 2011 at 10:47:29AM +0200, Michael J Gruber wrote:
Show 12 quoted lines
> The only thing I can imagine doing right now is changing
> require_work_tree() to actually cd to toplevel when possible, so that
> (like before) on success we're really within. But that changes cwd, of
> course. In summary, a require_work_tree() now can have three assumptions
> when it returns with success:
> 
> - we have a worktree
> - we are within worktree
> - cwd has not changed
> 
> I'd rather break the last one than the second one, but breaking any may
> be a problem, depending on the caller.

Check out some of the older scripts in contrib/examples. Several of them require_work_tree, but do not cd_to_toplevel immediately; instead, they do it much later for some specific bits.

I didn't go through and analyze what would happen in each case if we did the cd_to_toplevel first. I suspect some of it would be pretty mild breakage (like "git commit -F foo" not finding "foo"). But it would be breakage nonetheless.

-Peff
Previous: Michael J GruberNext: Junio C Hamano
Message 11 of 12 in “[RFC] require-work-tree wants more than what its name says”
  1. Junio C HamanoMay 3, 2011
  2. Jeff KingMay 4, 2011
  3. Junio C HamanoMay 4, 2011
  4. Jeff KingMay 4, 2011
  5. Junio C HamanoMay 5, 2011
  6. Jeff KingMay 5, 2011
  7. Jeff KingMay 5, 2011
  8. Sverre RabbelierMay 5, 2011
  9. Junio C HamanoMay 5, 2011
  10. Michael J GruberMay 4, 2011
  11. Jeff KingMay 4, 2011
  12. Junio C HamanoMay 4, 2011

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.