Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add navigation between merge commits #525

Closed
wants to merge 6 commits into from

Conversation

phi-gamma
Copy link
Contributor

Allow skipping forward and backward between merge commits by means of
two actions “move-next-merge” and “move-prev-merge”. The search
considers all lines containing the merge symbol.

@phi-gamma
Copy link
Contributor Author

I’ve been wanting this feature since the first time I use tig ;) I consider
it immensely useful when browsing larger projects like the kernel:
Pull Linus’ tree first thing in the morning an flip between merges to
get a broad idea of what changed since your last fetch.

Copy link
Owner

@jonas jonas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. I think it is a nice feature, however, there're a couple of things I think are needed before this can be merged. Let me know if you want me to polish things up.

return error("Unknown search request");
}

if (!view->matched_lines && find_merges(view))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always return ERROR_OUT_OF_MEMORY when find_merges succeeds.

break;

default:
return error("Unknown search request");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this error message should be changed.

@@ -292,6 +292,11 @@ view_driver(struct view *view, enum request request)
find_next(view, request);
break;

case REQ_MOVE_NEXT_MERGE:
case REQ_MOVE_PREV_MERGE:
find_merge(view, request);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will segfault on views that does not have a graph. I suggest this only reports an error:

report("Moving between merge commits is not supported by the %s view", view->name);

And the find_merge cases are moved to main_request in src/main.c.

if (!view->ops->get_column_data(view, line, &column_data))
continue;

if (!column_data.graph->is_merge(canvas))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column_data.graph will be NULL here for all views except main.

return false;

view->line[lineno].search_result = true;
view->matched_line[view->matched_lines++] = lineno;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to reuse these member that are usually for search highlighting?

@phi-gamma
Copy link
Contributor Author

···<date: 2016-10-17, Monday>···<from: Jonas Fonseca>···

Thanks for this contribution. I think it is a nice feature,
however, there're a couple of things I think are needed before
this can be merged. Let me know if you want me to polish things
up.

I very much appreciate the review. I’ll try to have something
ready till the end of the week. So far I’ve addressed most of
your points but I’m not sure how to proceed with this one:

  •   struct line *line = &view->line[lineno];
    
  • struct commit *commit = line->data;
    
  • struct graph_canvas *canvas = &commit->graph;
    
  • struct view_column_data column_data;
    
  • if (!view->ops->get_column_data(view, line, &column_data))
    
  •     continue;
    
  • if (!column_data.graph->is_merge(canvas))
    
  •     continue;
    
  • if (!realloc_unsigned_ints(&view->matched_line, view->matched_lines, 1))
    
  •     return false;
    
  • view->line[lineno].search_result = true;
    
  • view->matched_line[view->matched_lines++] = lineno;
    

Any particular reason to reuse these member that are usually for search highlighting?

No particular reason except to have the code as close to the
search routines as possible.

The two obvious options would be a) to extend struct view
with similar fields for collecting the merges, and b) to find the
next merge on demand. Personally I’d go with the latter because
it’s less complex. Any thoughts?

Best,
Philipp

phi-gamma added a commit to phi-gamma/tig that referenced this pull request Oct 22, 2016
Fixes a potential NULL deref.

As per review: jonas#525 (comment)
phi-gamma added a commit to phi-gamma/tig that referenced this pull request Oct 22, 2016
Handle merge ops in main view and emit a message when they are
encountered outside.

As per review: jonas#525 (comment)
phi-gamma added a commit to phi-gamma/tig that referenced this pull request Oct 22, 2016
phi-gamma added a commit to phi-gamma/tig that referenced this pull request Oct 22, 2016
…uest

Emit an error message that indicates a bad request when looking
for merge commits.

As per review: jonas#525 (comment)
phi-gamma added a commit to phi-gamma/tig that referenced this pull request Oct 22, 2016
Find merges by traversing lines directly. Instead of collecting
hte merges like matches, the next merge is determined starting
from the current line. Whether the search wraps around is
controlled by wrap-search.

As per review: jonas#525 (comment)
@phi-gamma
Copy link
Contributor Author

I’ve addressed each of your remarks in a single commit. After review
give me a note and I’ll squash them into a single changeset.

Allow skipping forward and backward between merge commits by means of
two actions “move-next-merge” and “move-prev-merge”. The search
considers all lines containing the merge symbol.
Fixes a potential NULL deref.

As per review: jonas#525 (comment)
Handle merge ops in main view and emit a message when they are
encountered outside.

As per review: jonas#525 (comment)
…uest

Emit an error message that indicates a bad request when looking
for merge commits.

As per review: jonas#525 (comment)
phi-gamma added a commit to phi-gamma/tig that referenced this pull request Oct 22, 2016
Find merges by traversing lines directly. Instead of collecting
hte merges like matches, the next merge is determined starting
from the current line. Whether the search wraps around is
controlled by wrap-search.

As per review: jonas#525 (comment)
Find merges by traversing lines directly. Instead of collecting
hte merges like matches, the next merge is determined starting
from the current line. Whether the search wraps around is
controlled by wrap-search.

As per review: jonas#525 (comment)
@jonas
Copy link
Owner

jonas commented Nov 13, 2016

Thanks squashed and merged.

@jonas jonas closed this Nov 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants