git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH] git-add--interactive: manual hunk editing mode v2
Date: Thu, 5 Jun 2008 09:53:54 +0200	[thread overview]
Message-ID: <200806050954.13244.trast@student.ethz.ch> (raw)
In-Reply-To: <20080605014618.GA27381@sigill.intra.peff.net>

[-- Attachment #1: Type: text/plain, Size: 2842 bytes --]

Jeff King wrote:
> 
> But that being said, I think your approach is much more powerful, since
> you are allowing arbitrary editing of the hunk (as much as that is
> possible).
[...]
> So perhaps manual hunk editing is simply something for advanced users
> who are comfortable with the patch format.

I'll think about this for a while.  Somehow I don't like the idea of
editing the actual patch _contents_ for the user, meaning that what
the user needs to edit his patch into is not what we are going to
apply.

On the other hand it would be just as powerful.  Manually splitting a
hunk is, in the general case, only possible in "my" scheme.  However,
to make any difference, you later have to answer 'n' to some of the
sub-hunks.  So in "your" scheme, you could just have deleted the lines
in question.

Of course, manually editing the '+' lines or even introducing new
stuff into the patch is not possible, but then you should probably
have edited the actual file contents, not the patch.  (The working
directory will still have the old version, so if you commit after add
-p, it will appear to undo part of the last commit.)

Then again, if this is just about editor convenience, maybe make a
macro that toggles between '-'/'+' and ' '/'#', respectively?  (Which
makes me wonder if it would be useful to keep the '#' lines, minus the
help message, around until the final git-apply in case you change your
mind and re-edit.)

> > +# Empty lines and lines starting with # will be removed.
> 
> What about lines starting with characters besides -, +, space, or @?
> They will normally be ignored by diff.

Diff doesn't really have a say in this, does it?  And looking in
builtin-apply.c:

	switch (first) {  // line 1858 as of v1.5.6-rc1-122-g3859f95
	case '\n':
		/* Newer GNU diff, empty context line */
		// actual work snipped
		break;
	// cases ' ', '+', '-' also covered
	default:
		if (apply_verbosely)
			error("invalid start of line: '%c'", first);
		return -1;

so it appears invalid lines are actually not ignored, but abort hunk
processing.  While the error checking will be handled by apply
--check, I don't think it would be a good idea to silently drop all
other lines from the edit, as they probably indicate user error.

On the other hand, this also shows that dropping empty lines is
wrong...

>  - Minor fixups and style comments. All of my style comments are "I
>    would have done it as..." and not "Oh God, this is horrible" so I
>    don't think any block acceptance.

From a Perl POV, they probably _are_ horrible.  I'm just not used to
the idioms, and tend to fall for semantic differences to Python as
well.

Thank you for the very thorough review!  I'll improve the patch
accordingly.

- Thomas

-- 
Thomas Rast
trast@student.ethz.ch




[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

  reply	other threads:[~2008-06-05  7:54 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-23 20:21 [PATCH] git-add--interactive: manual hunk editing mode Thomas Rast
2008-05-24  1:24 ` Ping Yin
2008-05-29 15:37 ` Thomas Rast
2008-05-29 16:12   ` Johannes Schindelin
2008-05-29 19:10     ` Thomas Rast
2008-05-29 19:16       ` Thomas Rast
2008-05-29 18:58   ` Jeff King
2008-05-30  9:49     ` Johannes Schindelin
2008-05-30 10:46       ` Jakub Narebski
2008-05-30 12:21     ` Thomas Rast
2008-05-30 21:35       ` Junio C Hamano
2008-06-01  0:41     ` [RFC PATCH] git-add--interactive: manual hunk editing mode v2 Thomas Rast
2008-06-01 14:50       ` [RFC PATCH] git-add--interactive: manual hunk editing mode v2.1 Thomas Rast
2008-06-01 15:14         ` Jeff King
2008-06-05  1:46       ` [RFC PATCH] git-add--interactive: manual hunk editing mode v2 Jeff King
2008-06-05  7:53         ` Thomas Rast [this message]
2008-06-05  8:11           ` Jeff King
2008-06-05  9:04             ` Thomas Rast
2008-06-05  9:20               ` Jeff King
2008-06-05  9:38                 ` Thomas Rast
2008-06-05  9:46                   ` Jeff King
2008-06-05  8:16         ` Junio C Hamano
2008-06-05  8:56           ` Jeff King
2008-06-05 10:28             ` Johannes Schindelin
2008-06-06  5:10               ` Jeff King
2008-06-06  6:03                 ` Jeff King
2008-06-08 22:33                   ` Thomas Rast
2008-06-08 23:06                     ` Johannes Schindelin
2008-06-06 14:31                 ` Johannes Schindelin
2008-06-08 22:18                   ` Thomas Rast
2008-06-08 23:02                     ` Johannes Schindelin
2008-06-05 12:38         ` [WIP PATCH v2] git-add--interactive: manual hunk editing mode Thomas Rast
2008-06-08 22:32           ` [PATCH v3] " Thomas Rast
2008-06-08 23:19             ` Johannes Schindelin
2008-06-09  5:46               ` Johan Herland
2008-06-09 12:29                 ` Jeff King
2008-06-09 16:13                   ` Johannes Schindelin
2008-06-09 19:59                     ` Junio C Hamano
2008-06-09 17:31                   ` Johan Herland
2008-06-09 20:17                     ` Jeff King
2008-06-09 21:19                       ` Johan Herland
2008-06-10 11:05                         ` Jeff King
2008-06-11  9:02                           ` Thomas Rast
2008-06-12  4:49                             ` Jeff King
2008-06-12  6:55                               ` Thomas Rast
2008-06-12  7:13                                 ` Jeff King
2008-06-13 15:48                                   ` [PATCH v4] " Thomas Rast
2008-06-23 18:38                                     ` Jeff King
2008-06-23 18:54                                       ` Johannes Schindelin
2008-06-23 19:57                                         ` Jeff King
2008-06-23 21:16                                           ` apply --recount, was " Johannes Schindelin
2008-06-24  5:09                                             ` Jeff King
2008-06-24 19:07                                               ` [PATCH 0/3] Manual editing for 'add' and 'add -p' Thomas Rast
2008-06-24 19:53                                                 ` Miklos Vajna
2008-06-24 19:08                                               ` [PATCH 1/3] Allow git-apply to ignore the hunk headers (AKA recountdiff) Thomas Rast
2008-06-24 23:35                                                 ` Junio C Hamano
2008-06-25  5:45                                                   ` Jeff King
2008-06-27 17:43                                                   ` Johannes Schindelin
2008-06-24 19:08                                               ` [PATCH 2/3] git-add: introduce --edit (to edit the diff vs. the index) Thomas Rast
2008-06-24 19:08                                               ` [PATCH 3/3] git-add--interactive: manual hunk editing mode Thomas Rast
2008-06-10 11:19                       ` [PATCH v3] " Andreas Ericsson
2008-06-05  9:02     ` [PATCH] " Thomas Rast

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200806050954.13244.trast@student.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).