git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Klaus Ethgen <Klaus@ethgen.ch>
Cc: git@vger.kernel.org
Subject: Re: fatal: unable to read after commit - deeper analysis
Date: Mon, 22 Apr 2019 12:21:27 -0400	[thread overview]
Message-ID: <20190422162127.GC9680@sigill.intra.peff.net> (raw)
In-Reply-To: <20190413092136.GK12669@ikki.ethgen.ch>

On Sat, Apr 13, 2019 at 10:21:36AM +0100, Klaus Ethgen wrote:

> Finally, the error was a combination of 4 tools, git, vim, the mentioned
> vim-addon and task with a task-hook for committing pending.data.
> 
> When I do a git commit which invokes vim, then the following variables
> are set:
> - GIT_INDEX_FILE
> - GIT_AUTHOR_DATE
> - GIT_PREFIX
> - GIT_EXEC_PATH
> 
> And $GIT_INDEX_FILE is the source of trouble here. The task-hook clears
> respective sets the variables GIT_DIR and GIT_WORK_TREE. However, the
> GIT_INDEX_FILE environment is set (in some cases) to an absolute path
> pointing to .git/index.lock or .git/index (I have no idea when it is
> taking the .lock variant).
> 
> Now we have a mismatch of GIT_DIR and GIT_WORK_TREE on one hand and the
> absolute path of GIT_INDEX_FILE on the other. So the trouble is set. The
> following "git add pending.data" did break all. It does something to an
> index that does not belong to the git repo.
> 
> Mystery is when and why this changed in git. It was definitively changed
> in some recent version.

It was always the case that GIT_INDEX_FILE would sometimes be set. For a
partial commit like:

  echo changes >>one
  echo changes >>two
  git add .
  git commit two

we have to create a temporary index (so as not to commit the staged
changes from "one").

I was curious if we started setting it for the more vanilla case of
just "git commit" more recently. But trying to bisect on:

  GIT_EDITOR=set | grep ^GIT_INDEX; :' git commit

I couldn't find any version where we _didn't_ set $GIT_INDEX_FILE, going
back to v1.6.0. So I don't know of any recent changes in this area.

Presumably you've fixed it by unsetting $GIT_INDEX_FILE in your vim
task-hook when it switches to another repo. However, you may want to
switch to asking Git about the full list of repo-related variables you
should clear. In the shell that looks like:

  unset $(git rev-parse --local-env-vars)

That should be more thorough, and will future-proof you against new
variables being added.

-Peff

      reply	other threads:[~2019-04-22 16:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 16:44 fatal: unable to read after commit Klaus Ethgen
2019-04-12  8:39 ` Christian Couder
2019-04-12  9:14   ` Klaus Ethgen
2019-04-12  9:28   ` Klaus Ethgen
2019-04-12  9:30   ` Klaus Ethgen
2019-04-13  9:21   ` fatal: unable to read after commit - deeper analysis Klaus Ethgen
2019-04-22 16:21     ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190422162127.GC9680@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Klaus@ethgen.ch \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).