threads / discuss / 43650

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

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

## tl;dr

3 messages between Dec 8, 2006 and Dec 9, 2006.

replies: 2people: 3as markdown or json

Pazu· Dec 8, 2006, 12:36 UTC · lore

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

Junio's reworking of the git-commit documentation, and the ensuing discussion about what is commited, and how do you select that, made me remember how much I liked SVK -- particularly, how much I liked to remove files from the commit message template, and have them removed from the commit.

At first, I thought "great opportunity to contribute my first patch to git", until I realized that git-commit is written in bash, and my brain refuses to understand that. Yep, I'm that bad. So I'm writing this, and maybe someone well-versed in bash will find this a good idea and code it :-)

For those not familiar with SVK, if you remove the files mentioned in the commit template (that "here are the files that you're about to commit" part), SVK won't commit them. For example, if I modify a couple of files in git, and execute 'git commit -a', an editor will popup showing something like this:

# Please enter the commit message for your changes. # (Comment lines starting with '#' will not be included) # On branch refs/heads/next # Updated but not checked in: # (will commit) # # modified: perl/Makefile # modified: var.c

Here's where the magic would happen. Removing the line "modified: var.c" would remove var.c from this commit. Of course, the template message should be modified to tell the user he can do that.

So, what do you think about this?
-- Pazu
Junio C Hamano· Dec 8, 2006, 19:18 UTC · re: Pazu · lore
Pazu <pazu@pazu.com.br> writes:
Show 14 quoted lines
> # Please enter the commit message for your changes.
> # (Comment lines starting with '#' will not be included)
> # On branch refs/heads/next
> # Updated but not checked in:
> #   (will commit)
> #
> #	modified:   perl/Makefile
> #	modified:   var.c
>
> Here's where the magic would happen. Removing the line "modified: var.c" would
> remove var.c from this commit. Of course, the template message should be
> modified to tell the user he can do that.
>
> So, what do you think about this?

Personally, I would refuse to use such a modified git, because often the first thing I would do in the commit log buffer is check the listed files and remove the '# ...' lines while typing. I do not want that to affect the set of changes I staged in any way.

But maybe that is just me.
Sean· Dec 9, 2006, 07:02 UTC · re: Junio C Hamano · lore

On Fri, 08 Dec 2006 11:18:16 -0800 Junio C Hamano <junkio@cox.net> wrote:

Show 5 quoted lines
> Personally, I would refuse to use such a modified git, because
> often the first thing I would do in the commit log buffer is
> check the listed files and remove the '# ...' lines while
> typing.  I do not want that to affect the set of changes I
> staged in any way.

Your usage should not affected at all by the addition of this feature. One of the comment lines could be magic, in that if it is missing the feature is disabled. Something like:

#  *** Editable Commit List ***

Or some such at the top of the list, where if it is missing after commit message editing, the post processing of the file list will be completely disabled. Another alternative would be to just enable the feature with an -A or some other commit command line option, so that those uninterested in such a feature don't have to even see it.

It would be interesting to hear from Pasky on how this feature has worked out in practice for Cogito users and whether he thinks it would be a good addition to Git.

← back to recent threads