summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7a5eba3)
raw | patch | inline | side by side (parent: 7a5eba3)
author | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 24 Apr 2008 08:07:34 +0000 (10:07 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 24 Apr 2008 08:14:30 +0000 (10:14 +0200) |
By default bound to '@'. Requested by Pascal Obry.
NEWS | patch | blob | history | |
manual.txt | patch | blob | history | |
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
index 23432925967f84d0412e2bbdfc41ef9500d19957..5987ddd582862679bebfa0211de3ed2b55d6c6c0 100644 (file)
--- a/NEWS
+++ b/NEWS
- F5 also refreshes the current view.
- Allow line graphics to be disabled with new line-graphics option.
- - Also include the reference names when searching.
+ - Main view: also include the reference names when searching.
+ - Stage view: add stage-next action to jump to next diff chunk that can be
+ staged. By default bound to '@'.
- Configure: check for the ncurses header files.
Bug fixes:
diff --git a/manual.txt b/manual.txt
index e4f937a4ad5fa357da15dd0e952ebae91afa4c13..f157a09f23e225ce9867e70a71eb5f698529cb28 100644 (file)
--- a/manual.txt
+++ b/manual.txt
M Resolve unmerged file by launching git-mergetool(1). Note, to work \
correctly this might require some initial configuration of your \
preferred merge tool. See the manpage of git-mergetool(1).
+@ Move to next chunk in the stage view.
',' Move tree view to the parent tree.
e Open file in editor.
-----------------------------------------------------------------------------
index 8e06c1ac5031bbb19cb3e0275e91e46c71652976..2a0d793c0bc338aed2f1bc8a6eb50d31e2da3af0 100644 (file)
--- a/tig.c
+++ b/tig.c
REQ_(TOGGLE_REFS, "Toggle reference display (tags/branches)"), \
REQ_(STATUS_UPDATE, "Update file status"), \
REQ_(STATUS_MERGE, "Merge file using external tool"), \
+ REQ_(STAGE_NEXT, "Find next chunk to stage"), \
REQ_(TREE_PARENT, "Switch to parent directory in tree view"), \
REQ_(EDIT, "Open in editor"), \
REQ_(NONE, "Do nothing")
{ ':', REQ_PROMPT },
{ 'u', REQ_STATUS_UPDATE },
{ 'M', REQ_STATUS_MERGE },
+ { '@', REQ_STAGE_NEXT },
{ ',', REQ_TREE_PARENT },
{ 'e', REQ_EDIT },
static char status_onbranch[SIZEOF_STR];
static struct status stage_status;
static enum line_type stage_line_type;
+static size_t stage_chunks;
+static int *stage_chunk;
/* Get fields from the diff line:
* :100644 100644 06a5d6ae9eca55be2e0e585a152e6b1336f2b20e 0000000000000000000000000000000000000000 M
}
stage_line_type = line->type;
+ stage_chunks = 0;
string_format(VIEW(REQ_VIEW_STAGE)->ref, info, stage_status.new.name);
}
return TRUE;
}
+static void
+stage_next(struct view *view, struct line *line)
+{
+ int i;
+
+ if (!stage_chunks) {
+ static size_t alloc = 0;
+ int *tmp;
+
+ for (line = view->line; line < view->line + view->lines; line++) {
+ if (line->type != LINE_DIFF_CHUNK)
+ continue;
+
+ tmp = realloc_items(stage_chunk, &alloc,
+ stage_chunks, sizeof(*tmp));
+ if (!tmp) {
+ report("Allocation failure");
+ return;
+ }
+
+ stage_chunk = tmp;
+ stage_chunk[stage_chunks++] = line - view->line;
+ }
+ }
+
+ for (i = 0; i < stage_chunks; i++) {
+ if (stage_chunk[i] > view->lineno) {
+ do_scroll_view(view, stage_chunk[i] - view->lineno);
+ report("Chunk %d of %d", i + 1, stage_chunks);
+ return;
+ }
+ }
+
+ report("No next chunk found");
+}
+
static enum request
stage_request(struct view *view, enum request request, struct line *line)
{
return REQ_NONE;
break;
+ case REQ_STAGE_NEXT:
+ if (stage_line_type == LINE_STAT_UNTRACKED) {
+ report("File is untracked; press %s to add",
+ get_key(REQ_STATUS_UPDATE));
+ return REQ_NONE;
+ }
+ stage_next(view, line);
+ return REQ_NONE;
+
case REQ_EDIT:
if (!stage_status.new.name[0])
return request;
diff --git a/tigrc.5.txt b/tigrc.5.txt
index 5e204f33c147c774a591d273734e8ef884e3958e..92ea256c4e38ad597c145b7e16a1f5fe96578d9e 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
toggle-refs Toggle reference display
status-update Update file status
status-merge Resolve unmerged file
+stage-next Find next chunk to stage
tree-parent Switch to parent directory in tree view
edit Open in editor
------------------------------------------------------------------------------