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

Re: git-commit: select which files to commit while editing the commit message

From
Junio C Hamano <junkio@cox.net>
Date
Dec 9, 2006, 00:59 UTC
Message-ID
<7vfybpg9yx.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<m2d56taoqu.fsf@ziti.local>
Seth Falcon <sethfalcon@gmail.com> writes:
Show 19 quoted lines
> I don't think I understand what an --exclude=<pattern> option would
> do, but I'm pretty sure it doesn't help the use case I'm thinking of:
>
>    Editing away, you've made changes in 8 files.
>
>    Reviewing diff, you want to commit 6 of those and continue working
>    on the other two.
>
>    It seems that there could be a less manual way than 
>    git update-index f1 f2 ... f6
>
>
> Hmm, maybe I could do:
>
>    git diff --name-only > changed
>    ## edit changed
>    cat changed|xargs git update-index
>
> I suppose this could be wrapped in a simple way to bring up an editor.

Note that output of cat piped to anything is almost always a bad programming ;-)

Maybe the "git add --interactive" would give you a transcript like this:

        $ git add --interactive '*.c' '*.h'
	showing list of modified files...
         1) bozbar.c 2) filfre.c 3) frotz.h 4) nitfol.c 5) rezrov.h
         6) xyzzy.c  7) yomin.h  8) z.c
        choice> 2 3 5 6 7
	showing list of modified files...
         1) bozbar.c 2* filfre.c 3* frotz.h 4) nitfol.c 5* rezrov.h
         6* xyzzy.c  7* yomin.h  8) z.c
        choice> 4+
	showing "git diff -- nitfol.c"...
        diff --git a/nitfol.c b/nitfol.c
        @@ -22,x +22,y @@
         {
        -	int i;
        +	long i;
        +	i = 314;
	 
        stage this hunk [Yes/No/All/Done]? y
        ...
 
The latter half is to come up with a subset of diff and then run
"git-apply --cached" to update only the index with the chosen
hunks.
Previous: Seth FalconNext: Josef Weidendorfer
Message 7 of 20 in “Re: git-commit: select which files to commit while editing the commit message”
  1. Jakub NarebskiDec 8, 2006
  2. Luben TuikovDec 8, 2006
  3. Josef WeidendorferDec 8, 2006
  4. Seth FalconDec 8, 2006
  5. Jakub NarebskiDec 9, 2006
  6. Seth FalconDec 9, 2006
  7. Junio C HamanoDec 9, 2006
  8. Josef WeidendorferDec 10, 2006
  9. Junio C HamanoDec 10, 2006
  10. git-add --interactive (wip)Junio C Hamano, Dec 11, 2006
  11. Josef WeidendorferDec 11, 2006
  12. Junio C HamanoDec 12, 2006
  13. Johannes SchindelinDec 12, 2006
  14. Andreas EricssonDec 13, 2006
  15. Josef WeidendorferDec 13, 2006
  16. Junio C HamanoDec 13, 2006
  17. Johannes SchindelinDec 13, 2006
  18. Shawn PearceDec 13, 2006
  19. Johannes SchindelinDec 13, 2006
  20. Josef WeidendorferDec 13, 2006

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.