Commit fd73e841d9db03eaddd929bd084adbffaafbc3c2

Add stage-next action to jump to next diff chunk that can be staged

By default bound to '@'. Requested by Pascal Obry.

Commit diff

NEWS

 
88
99 - F5 also refreshes the current view.
1010 - Allow line graphics to be disabled with new line-graphics option.
11 - Also include the reference names when searching.
11 - Main view: also include the reference names when searching.
12 - Stage view: add stage-next action to jump to next diff chunk that can be
13 staged. By default bound to '@'.
1214 - Configure: check for the ncurses header files.
1315
1416Bug fixes:
toggle raw diff

manual.txt

 
366366M Resolve unmerged file by launching git-mergetool(1). Note, to work \
367367 correctly this might require some initial configuration of your \
368368 preferred merge tool. See the manpage of git-mergetool(1).
369@ Move to next chunk in the stage view.
369370',' Move tree view to the parent tree.
370371e Open file in editor.
371372-----------------------------------------------------------------------------
toggle raw diff

tig.c

 
376376 REQ_(TOGGLE_REFS, "Toggle reference display (tags/branches)"), \
377377 REQ_(STATUS_UPDATE, "Update file status"), \
378378 REQ_(STATUS_MERGE, "Merge file using external tool"), \
379 REQ_(STAGE_NEXT, "Find next chunk to stage"), \
379380 REQ_(TREE_PARENT, "Switch to parent directory in tree view"), \
380381 REQ_(EDIT, "Open in editor"), \
381382 REQ_(NONE, "Do nothing")
780780 { ':', REQ_PROMPT },
781781 { 'u', REQ_STATUS_UPDATE },
782782 { 'M', REQ_STATUS_MERGE },
783 { '@', REQ_STAGE_NEXT },
783784 { ',', REQ_TREE_PARENT },
784785 { 'e', REQ_EDIT },
785786
37983798static char status_onbranch[SIZEOF_STR];
37993799static struct status stage_status;
38003800static enum line_type stage_line_type;
3801static size_t stage_chunks;
3802static int *stage_chunk;
38013803
38023804/* Get fields from the diff line:
38033805 * :100644 100644 06a5d6ae9eca55be2e0e585a152e6b1336f2b20e 0000000000000000000000000000000000000000 M
41914191 }
41924192
41934193 stage_line_type = line->type;
4194 stage_chunks = 0;
41944195 string_format(VIEW(REQ_VIEW_STAGE)->ref, info, stage_status.new.name);
41954196 }
41964197
46014601 return TRUE;
46024602}
46034603
4604static void
4605stage_next(struct view *view, struct line *line)
4606{
4607 int i;
4608
4609 if (!stage_chunks) {
4610 static size_t alloc = 0;
4611 int *tmp;
4612
4613 for (line = view->line; line < view->line + view->lines; line++) {
4614 if (line->type != LINE_DIFF_CHUNK)
4615 continue;
4616
4617 tmp = realloc_items(stage_chunk, &alloc,
4618 stage_chunks, sizeof(*tmp));
4619 if (!tmp) {
4620 report("Allocation failure");
4621 return;
4622 }
4623
4624 stage_chunk = tmp;
4625 stage_chunk[stage_chunks++] = line - view->line;
4626 }
4627 }
4628
4629 for (i = 0; i < stage_chunks; i++) {
4630 if (stage_chunk[i] > view->lineno) {
4631 do_scroll_view(view, stage_chunk[i] - view->lineno);
4632 report("Chunk %d of %d", i + 1, stage_chunks);
4633 return;
4634 }
4635 }
4636
4637 report("No next chunk found");
4638}
4639
46044640static enum request
46054641stage_request(struct view *view, enum request request, struct line *line)
46064642{
46464646 return REQ_NONE;
46474647 break;
46484648
4649 case REQ_STAGE_NEXT:
4650 if (stage_line_type == LINE_STAT_UNTRACKED) {
4651 report("File is untracked; press %s to add",
4652 get_key(REQ_STATUS_UPDATE));
4653 return REQ_NONE;
4654 }
4655 stage_next(view, line);
4656 return REQ_NONE;
4657
46494658 case REQ_EDIT:
46504659 if (!stage_status.new.name[0])
46514660 return request;
toggle raw diff

tigrc.5.txt

 
264264toggle-refs Toggle reference display
265265status-update Update file status
266266status-merge Resolve unmerged file
267stage-next Find next chunk to stage
267268tree-parent Switch to parent directory in tree view
268269edit Open in editor
269270------------------------------------------------------------------------------
toggle raw diff