git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v9 3/5] Implement line-history search (git log -L)

From
Thomas Rast <trast@inf.ethz.ch>
Date
Mar 23, 2013, 06:00 UTC
Message-ID
<87fvzmzmcy.fsf@pctrast.inf.ethz.ch>
In-Reply-To
<7vr4j8a7zy.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 42 quoted lines
> Thomas Rast <trast@student.ethz.ch> writes:
>
>> +void line_log_init(struct rev_info *rev, const char *prefix, struct
>> string_list *args)
>> +{
>> +	struct commit *commit = NULL;
>> +	struct line_log_data *range;
>> +
>> +	commit = check_single_commit(rev);
>> +	range = parse_lines(commit, prefix, args);
>> +	add_line_range(rev, commit, range);
>> +
>> +	if (!rev->diffopt.detect_rename) {
>> +		int i, count = 0;
>> +		struct line_log_data *r = range;
>> +		const char **paths;
>> +		while (r) {
>> +			count++;
>> +			r = r->next;
>> +		}
>> +		paths = xmalloc((count+1)*sizeof(char *));
>> +		r = range;
>> +		for (i = 0; i < count; i++) {
>> +			paths[i] = xstrdup(r->spec->path);
>> +			r = r->next;
>> +		}
>> +		paths[count] = NULL;
>> +		init_pathspec(&rev->diffopt.pathspec, paths);
>> +		free(paths);
>> +	}
>> +}
>
> Why not do the pathspec limitation under "-M"?
>
> It is not like you are picking up origins of blocks of lines copied
> or moved from other files like "blame -C" does, so I suspect it
> would be simpler to mimic what --follow does, which is to (1) use
> the pathspec to follow the paths you care about, and then (2) when
> you find one or more of the paths you were following disappear in a
> commit, only at that point you re-check to see if there are other
> paths that existed in the parent that the disappeared paths were
> renamed from, and match with that one.

It's acting too soon though. The way log -L is currently wired, we do one revision walk with the pathspec filter already enabled to do the topo sorting. Wiring it in *at that point* would be equivalent to fixing --follow.

Which I plan to do Real Soon Now(tm). But let's not open too many cans of worms at the same time.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Junio C HamanoNext: Thomas Rast
Message 6 of 12 in “git log -L”
  1. 0/5 git log -LThomas Rast, Mar 21, 2013
  2. 1/5 Refactor parse_locThomas Rast, Mar 21, 2013
  3. 2/5 Export rewrite_parents() for 'log -L'Thomas Rast, Mar 21, 2013
  4. 3/5 Implement line-history search (git log -L)Thomas Rast, Mar 21, 2013
  5. Junio C HamanoMar 21, 2013
  6. Thomas RastMar 23, 2013
  7. 4/5 log -L: :pattern:file syntax to find by funcnameThomas Rast, Mar 21, 2013
  8. 5/5 Speed up log -L... -MThomas Rast, Mar 21, 2013
  9. Eric SunshineMar 21, 2013
  10. Thomas RastMar 23, 2013
  11. Jeff KingMar 23, 2013
  12. Eric SunshineMar 24, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.