add-interactive: refactor mode hunk handling
commit7535e5a16aa7167074ac74ee1342814767a83a82
authorJeff King <peff@peff.net>
Thu, 16 Apr 2009 07:14:15 +0000 (16 03:14 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Apr 2009 19:35:38 +0000 (19 12:35 -0700)
tree6c737817220eb001cf0844af02b536732bd16526
parentcbd3a01ed803778b2377e0148448f7e617bc381a
add-interactive: refactor mode hunk handling

The original implementation considered the mode separately
from the rest of the hunks, asking about it outside the main
hunk-selection loop. This patch instead places a mode change
as the first hunk in the loop. This has two advantages:

  1. less duplicated code (since we use the main selection
     loop). This also cleans up an inconsistency, which is
     that the main selection loop separates options with a
     comma, whereas the mode prompt used slashes.

  2. users can now skip the mode change and come back to it,
     search for it (via "/mode"), etc, as they can with other
     hunks.

To facilitate this, each hunk is now marked with a "type".
Mode hunks are not considered for splitting (which would
make no sense, and also confuses the split_hunk function),
nor are they editable. In theory, one could edit the mode
lines and change to a new mode. In practice, there are only
two modes that git cares about (0644 and 0755), so either
you want to move from one to the other or not (and you can
do that by staging or not staging).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-add--interactive.perl