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

Re: [PATCH 3/3] stash: require a clean index to apply

From
JKJonathan Kamens <jkamens@quantopian.com>
Date
Jun 5, 2015, 00:43 UTC
Message-ID
<5570F094.10007@quantopian.com>

I'm writing about the patch that Jeff King submitted on April 22, in <20150422193101.GC27945@peff.net>, in particular, https://github.com/git/git/commit/ed178ef13a26136d86ff4e33bb7b1afb5033f908 . It appears that this patch was included in git 2.4.2, and it breaks my workflow.

In particular, I have a pre-commit hook whith does the following:
1. Stash unstaged changes ("git stash -k").
2. Run flake8 over all staged changes.
3. If flake8 complains, then error out of the commit.
4. Otherwise, apply the stash and exit.

This way I am prevented from committing staged changes that don't pass flake8. I can't imagine that this is a terribly uncommon workflow.

This worked fine until the aforementioned comment, after which my hook complains, "Cannot apply stash: Your index contains uncommitted changes."

The reason I have to do things this way is as follows. Suppose I did the following:

1. Stage changes that have a flake8 violation.
2. Fix the flake8 violation in the unstaged version of the staged file.
3. Commit the previously staged changes.

If my commit hook runs over the unstaged version of the file, then it won't detect the flake8 violation, and as a result the violation will be committed.

If anyone has a suggestion for how I can achieve the desired goal within the constraints of the 2.4.2 version of git-stash.sh, I'd love to hear it. Otherwise, I'd like to ask for this patch to be reconsidered.

Thank you,
Jonathan Kamens
Next: Jeff King
Message 1 of 16 in “Re: [PATCH 3/3] stash: require a clean index to apply”
  1. Jonathan KamensJun 5, 2015
  2. Jeff KingJun 7, 2015
  3. Jeff KingJun 7, 2015
  4. bärJun 10, 2015
  5. Jeff KingJun 10, 2015
  6. Junio C HamanoJun 10, 2015
  7. Jeff KingJun 10, 2015
  8. bärJun 10, 2015
  9. Junio C HamanoJun 15, 2015
  10. Revert "stash: require a clean index to apply"Jeff King, Jun 15, 2015
  11. Junio C HamanoJun 15, 2015
  12. Jonathan KamensJun 25, 2015
  13. Jeff KingJun 26, 2015
  14. Jonathan KamensJun 26, 2015
  15. Jeff KingJun 26, 2015
  16. Junio C HamanoJun 26, 2015

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.