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

BUG: `git commit` adding unstaged chunks of files to commits on 2.33.0

From
Andrew Thorp <andrew.thorp.dev@gmail.com>
Date
Aug 31, 2021, 17:15 UTC
Message-ID
<CAHBARKezrkKAs0ACbJ_fnxR-qWacQ5KKuVLwn0WyT7aR+4++pQ@mail.gmail.com>
Hello all,

As described in the subject line, it seems like git commit is committing entire files when chunks of the files are staged using `git add -p`, in spite of leaving chunks out of the stage. See below for the bug-report template questionnaire. Please let me know if there is anything I can do to help resolve this issue or if there is anything needed.

Thanks,
Andrew Thorp
> What did you do before the bug happened? (Steps to reproduce your issue)

Edit a checked-in file, adding multiple chunks of lines to the file. Using `git add -p <file>`, stage one of the chunks, leave some chunks unstaged. After running `git status` the file should both in the section `Changes to be committed:` and `Changes not staged for commit`. Commit the changes.

> What did you expect to happen? (Expected behavior)

I expected all staged changes to be committed and unstaged changes to remain unstaged.

> What happened instead? (Actual behavior)
The entire file was committed, including the unstaged chunks of changes.
> What's different between what you expected and what actually happened?

It appears as though the remaining file lines were both checked in and committed, when only the later should have happened.

[System Info] git version: git version 2.33.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Darwin 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64 compiler info: clang: 12.0.5 (clang-1205.0.22.9) libc info: no libc information available $SHELL (typically, interactive shell): /bin/zsh

Next: Junio C Hamano
Message 1 of 7 in “BUG: `git commit` adding unstaged chunks of files to commits on 2.33.0”
  1. Andrew ThorpAug 31, 2021
  2. Junio C HamanoAug 31, 2021
  3. Andrew ThorpAug 31, 2021
  4. Andrew ThorpAug 31, 2021
  5. Junio C HamanoAug 31, 2021
  6. Andrew ThorpAug 31, 2021
  7. Philippe BlainSep 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.