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

Re: [feature request] Make "commit --only" work with new files

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 28, 2016, 14:09 UTC
Message-ID
<alpine.DEB.2.20.1611281505270.117539@virtualbox>
In-Reply-To
<20161125175619.19e13e59@gentp.lnet>
Hi Luis,
On Fri, 25 Nov 2016, Luis Ressel wrote:
Show 8 quoted lines
> currently "git commit --only <file>" only works if <file> is already
> checked into the repo, but not with newly created and still untracked
> files (builtin/commit.c:list_path() throws the error "error: pathspec
> '<file>' did not match any file(s) known to git.")
> 
> I don't think this limitation is intented. I've had a look at the
> relevant part of builtin/commit.c, but unfortunately it wasn't obvious
> to me how to fix this.

The best way to go about it is probably to define the desired behavior first, in the form of a patch to the test suite. Personally, I would extend t/t7509-commit.sh with a new test case.

Then, once you have that test case (that should be marked with test_expect_failure, because it fails for now), you can use a debugger such as gdb to single-step into the relevant function (I guess "prepare_index()" is a good candidate) to find out why the files are not added.

From there, it should be easier to figure out what to patch, and how.

Good hunting! Johannes

Previous: Luis ResselNext: Junio C Hamano
Message 2 of 3 in “[feature request] Make "commit --only" work with new files”
  1. Luis ResselNov 25, 2016
  2. Johannes SchindelinNov 28, 2016
  3. Junio C HamanoNov 28, 2016

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.