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

Re: [PATCH] sequencer: pass absolute GIT_WORK_TREE to exec commands

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 14, 2018, 17:55 UTC
Message-ID
<20180714175555.GD1042117@genre.crustytoothpaste.net>
In-Reply-To
<20180714005702.GA20399@sigill.intra.peff.net>
On Fri, Jul 13, 2018 at 08:57:03PM -0400, Jeff King wrote:
Show 20 quoted lines
> On Sat, Jul 14, 2018 at 12:35:05AM +0000, brian m. carlson wrote:
> 
> > diff --git a/sequencer.c b/sequencer.c
> > index 5354d4d51e..c8e16f9168 100644
> > --- a/sequencer.c
> > +++ b/sequencer.c
> > @@ -2636,6 +2636,8 @@ static int do_exec(const char *command_line)
> >  	fprintf(stderr, "Executing: %s\n", command_line);
> >  	child_argv[0] = command_line;
> >  	argv_array_pushf(&child_env, "GIT_DIR=%s", absolute_path(get_git_dir()));
> > +	argv_array_pushf(&child_env, "GIT_WORK_TREE=%s",
> > +			 absolute_path(get_git_work_tree()));
> >  	status = run_command_v_opt_cd_env(child_argv, RUN_USING_SHELL, NULL,
> >  					  child_env.argv);
> >  
> 
> As a general rule of "always pass GIT_WORK_TREE with GIT_DIR", you have
> to deal with the case where there _isn't_ a work tree. Are we OK here
> because this code is inside sequencer.c, and you cannot do a sequencer
> operation without a work tree?

I believe that's correct. We only call this code path from sequencer_pick_commits or sequencer_continue, and those code paths are only called from revert, commit, and rebase--helper; all of those require a working tree.

Show 7 quoted lines
> So I think it would also work to set:
> 
>   GIT_IMPLICIT_WORK_TREE=0
> 
> here. But if the answer to my "are we OK" above is yes, I am fine with
> either that solution or the one you show here (but I think the commit
> message should probably mention it).

I'll reroll with a mention of that in the commit message. Thanks for a careful review.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Jeff KingNext: brian m. carlson
Message 12 of 22 in “rev-parse --show-toplevel broken during exec'ed rebase?”
  1. Vitali LovichJul 12, 2018
  2. Vitali LovichJul 12, 2018
  3. Johannes SchindelinJul 12, 2018
  4. Johannes SchindelinJul 12, 2018
  5. Junio C HamanoJul 12, 2018
  6. Vitali LovichJul 12, 2018
  7. brian m. carlsonJul 13, 2018
  8. Jeff KingJul 13, 2018
  9. brian m. carlsonJul 13, 2018
  10. sequencer: pass absolute GIT_WORK_TREE to exec commandsbrian m. carlson, Jul 14, 2018
  11. Jeff KingJul 14, 2018
  12. brian m. carlsonJul 14, 2018
  13. sequencer: pass absolute GIT_WORK_TREE to exec commandsbrian m. carlson, Jul 14, 2018
  14. Jeff KingJul 14, 2018
  15. Johannes SchindelinJul 14, 2018
  16. brian m. carlsonJul 14, 2018
  17. Junio C HamanoJul 16, 2018
  18. Jeff KingJul 16, 2018
  19. Junio C HamanoJul 16, 2018
  20. Johannes SchindelinJul 19, 2018
  21. SZEDER GáborJul 19, 2018
  22. Junio C HamanoJul 19, 2018

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.