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

Re: Re* [PATCH] Documentation/git-blame.txt: --follow is a NO-OP

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2012, 21:00 UTC
Message-ID
<7vpq5f3xct.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v7grn5h1l.fsf_-_@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> Let's do this for now instead.  That would make it clear to people
> who (rightly or wrongly) think the "--follow" option should do
> something that we already do so, and explain the output that they
> see when they do give the "--follow" option to the command.
>
> I may do a "--no-follow" patch as a follow-up, or I may not,
> depending on the mood and workload.
A patch to do so looks like this.

If you know your history did not have any rename, or if you care only about the history after a large rename that happened some time ago, "git blame --no-follow $path" can be a way to tell the command not to bother about them.

When you use -C, the lines that came from the renamed file will still be found without the whole-file rename detection anyway, and this is not all that interesting either way, I would think.

diff --git c/builtin/blame.c w/builtin/blame.c
index cad4111..bfa6086 100644
--- c/builtin/blame.c
+++ w/builtin/blame.c
@@ -42,6 +42,7 @@ static int blank_boundary;
 static int incremental;
 static int xdl_opts;
 static int abbrev = -1;
+static int no_whole_file_rename;
 
 static enum date_mode blame_date_mode = DATE_ISO8601;
 static size_t blame_date_width;
@@ -1226,7 +1227,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
 	 * The first pass looks for unrenamed path to optimize for
 	 * common cases, then we look for renames in the second pass.
 	 */
-	for (pass = 0; pass < 2; pass++) {
+	for (pass = 0; pass < 2 - no_whole_file_rename; pass++) {
 		struct origin *(*find)(struct scoreboard *,
 				       struct commit *, struct origin *);
 		find = pass ? find_rename : find_origin;
@@ -2344,6 +2345,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 	init_revisions(&revs, NULL);
 	revs.date_mode = blame_date_mode;
 	DIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);
+	DIFF_OPT_SET(&revs.diffopt, FOLLOW_RENAMES);
 
 	save_commit_buffer = 0;
 	dashdash_pos = 0;
@@ -2367,6 +2369,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 		parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
 	}
 parse_done:
+	no_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);
+	DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);
 	argc = parse_options_end(&ctx);
 
 	if (0 < abbrev)
diff --git c/diff.c w/diff.c
index f1b0447..32ebcbb 100644
--- c/diff.c
+++ w/diff.c
@@ -3584,6 +3584,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 		DIFF_OPT_SET(options, FIND_COPIES_HARDER);
 	else if (!strcmp(arg, "--follow"))
 		DIFF_OPT_SET(options, FOLLOW_RENAMES);
+	else if (!strcmp(arg, "--no-follow"))
+		DIFF_OPT_CLR(options, FOLLOW_RENAMES);
 	else if (!strcmp(arg, "--color"))
 		options->use_color = 1;
 	else if (!prefixcmp(arg, "--color=")) {
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 of 15 in “git blame --follow”
  1. norbert.nemecSep 6, 2012
  2. Jeff KingSep 6, 2012
  3. norbert.nemecSep 6, 2012
  4. Jeff KingSep 6, 2012
  5. Documentation/git-blame.txt: --follow is a NO-OPDrew Northup, Sep 19, 2012
  6. Junio C HamanoSep 19, 2012
  7. Jeff KingSep 19, 2012
  8. Junio C HamanoSep 19, 2012
  9. Jeff KingSep 19, 2012
  10. Kevin BallardSep 19, 2012
  11. Jeff KingSep 19, 2012
  12. Kevin BallardSep 19, 2012
  13. Re* [PATCH] Documentation/git-blame.txt: --follow is a NO-OPJunio C Hamano, Sep 21, 2012
  14. Junio C HamanoSep 21, 2012
  15. Junio C HamanoSep 20, 2012

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.