Re: Please support add -p with a new file, to add only part of the file

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

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

> Josh Triplett wrote:
>
>> I recently found myself with a new file that I needed to check in part
>> of with several commits.  I wanted to use "git add -p newfile" and use
>> 'e' to add and commit several times (along with corresponding bits in
>> existing files).  However, "git add -p" does not work on a new file,
>> only an existing file.
>
> Yep.  A workaround is to use "git add -N newfile" before running
> "git add -p newfile".
>
> I imagine "git add -p '*.c'" should also offer to add hunks from
> source files that git doesn't know about yet, too.
> 
> Here's a quick demo (untested) that might _almost_ do the right thing.
> Unfortunately it leaves intent-to-add entries around even for files
> the operator rejects.  Anyway, maybe it can be a good starting point
> for playing around.

I think a proper solution needs a way to generate a diff that includes
all of the named files (even untracked).  AFAICS there is no such
feature in the diff-* commands right now.

A not-so-proper solution might of course start by looking at which files
are untracked, and only run the 'git add -N' immediately before patch
application.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]