Re: git add -p with new file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Fri, 9 Dec 2016, Jeff King wrote:

On Tue, Dec 06, 2016 at 08:18:59PM -0500, Ariel wrote:

If you do git add -p new_file it says:

No changes.

Which is a rather confusing message. I would expect it to show me the
content of the file in patch form, in the normal way that -p works, let me
edit it, etc.

What should:
[git add directory with two new files]
do?

It should do the exact same thing that git add without -p does: Add the directory and both files, but because of the -p also show the diff on the screen and ask.

It's contrary to the rest of git-add for specifying pathspecs to actually make things _more_ inclusive rather than less.

Is it? Because git add without -p is happy to add new files.

Historically "add -p" has been more like "add -u" in updating tracked
files.

But it doesn't have to be that way. You could make add -p identical to add without options, except the -p prompts to review diffs first.

We have "-A" for "update everything _and_ new files". It doesn't
seem unreasonable to me to have a variant of "-p" that is similar.

That seems unnecessarily complex because -p asks about each file, so you will never find new files added without realizing it.

I don't think that variant should just be "add -N everything, and then
run add -p". As Duy points out, the patch for a new file is just one big
block. But the decision of "do I want to start tracking this untracked
file" is potentially an interesting one.

What makes sense to me is a two part question: First ask 'Add new path', and then if yes, ask to stage the hunk (where the hunk is the entire file).

This makes -p useful on new files, without hurting prior expectations of how it works.

	-Ariel



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]