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

2 messages, 2 authors, 2016-11-28 · open the first message on its own page

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

From: Luis Ressel <hidden>
Date: 2016-11-25 17:49:34

Hello,

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.

Regards,
Luis Ressel

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

From: Johannes Schindelin <hidden>
Date: 2016-11-28 14:09:48

Hi Luis,

On Fri, 25 Nov 2016, Luis Ressel wrote:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help