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

[PATCH v3 11/13] add --always-print option

From
Bo Yang <struggleyb.nku@gmail.com>
Date
Jul 11, 2010, 06:18 UTC
Message-ID
<1278829141-11900-11-git-send-email-struggleyb.nku@gmail.com>
In-Reply-To
<1278829141-11900-1-git-send-email-struggleyb.nku@gmail.com>

Always print the interesting ranges even if the current commit does not change any line of it.

Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
---
 builtin/log.c |    3 +++
 line.c        |   11 +++++++++--
 revision.h    |    3 ++-
 3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index 47b386d..3fa31dc 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -85,6 +85,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 {
 	int i;
 	int decoration_given = 0;
+	static int always_print = 0;
 	struct userformat_want w;
 	const char *path = NULL, *pathspec = NULL;
 	static struct diff_line_range *range = NULL;
@@ -92,6 +93,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 	static struct line_opt_callback_data line_cb = {&range, &ctx, NULL};
 	static const struct option options[] = {
 		OPT_CALLBACK('L', NULL, &line_cb, "n,m", "Process only line range n,m, counting from 1", log_line_range_callback),
+		OPT_BOOLEAN(0, "always-print", &always_print, "Always print the interesting range even if the current commit does not change any line of it"),
 		OPT_END()
 	};
 
@@ -224,6 +226,7 @@ parse_done:
 	/* Test whether line level history is asked for */
 	if (range && range->nr > 0) {
 		setup_line(rev, range);
+		rev->always_print = always_print;
 	}
 }
 
diff --git a/line.c b/line.c
index 5c8f77a..c08b510 100644
--- a/line.c
+++ b/line.c
@@ -1080,6 +1080,13 @@ static void diff_flush_filepair(struct rev_info *rev, struct diff_line_range *ra
 	 * no sensible rang->pair since there is no diff run.
 	 */
 	if (one == NULL) {
+		if (rev->always_print) {
+			chunk.two = two->data;
+			chunk.two_end = two->data + two->size;
+			chunk.ltwo = 1;
+			chunk.range = range;
+			diff_flush_chunks(&rev->diffopt, &chunk);
+		}
 		return;
 	}
 
@@ -1190,7 +1197,7 @@ static void line_log_flush(struct rev_info *rev, struct commit *c)
 		return flush_nontrivial_merge(rev, nontrivial);
 
 	while (range) {
-		if (range->diff)
+		if (range->diff || (range->nr && rev->always_print))
 			diff_flush_filepair(rev, range);
 		range = range->next;
 	}
@@ -1225,7 +1232,7 @@ int cmd_line_log_walk(struct rev_info *rev)
 			assign_parents_range(rev, commit);
 		}
 
-		if (commit->object.flags & NEED_PRINT) {
+		if (commit->object.flags & NEED_PRINT || rev->always_print) {
 			line_log_flush(rev, commit);
 		}
 
diff --git a/revision.h b/revision.h
index bbc4e2c..433da9a 100644
--- a/revision.h
+++ b/revision.h
@@ -72,7 +72,8 @@ struct rev_info {
 			bisect:1,
 			ancestry_path:1,
 			first_parent_only:1,
-			line:1;
+			line:1,
+			always_print:1;
 
 	/* Diff flags */
 	unsigned int	diff:1,
-- 
1.7.0.2.273.gc2413.dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 31 of 39 in “parse-options: stop when encounter a non-option”
  1. 01/13 parse-options: stop when encounter a non-optionBo Yang, Jul 11, 2010
  2. 02/13 parse-options: add two helper functionsBo Yang, Jul 11, 2010
  3. Junio C HamanoJul 12, 2010
  4. 03/13 add the basic data structure for line level historyBo Yang, Jul 11, 2010
  5. Bo YangJul 12, 2010
  6. Junio C HamanoJul 12, 2010
  7. Bo YangJul 18, 2010
  8. 04/13 refactor parse_locBo Yang, Jul 11, 2010
  9. Junio C HamanoJul 12, 2010
  10. 05/13 parse the -L optionsBo Yang, Jul 11, 2010
  11. Junio C HamanoJul 13, 2010
  12. Bo YangJul 18, 2010
  13. Junio C HamanoJul 19, 2010
  14. Thomas RastJul 19, 2010
  15. Junio C HamanoJul 19, 2010
  16. Thomas RastJul 20, 2010
  17. Junio C HamanoJul 20, 2010
  18. Thomas RastJul 22, 2010
  19. Junio C HamanoJul 23, 2010
  20. Bo YangJul 20, 2010
  21. Bo YangJul 20, 2010
  22. 06/13 export three functions from diff.cBo Yang, Jul 11, 2010
  23. 07/13 add range clone functionsBo Yang, Jul 11, 2010
  24. Junio C HamanoJul 12, 2010
  25. 08/13 map/take range to parentBo Yang, Jul 11, 2010
  26. Junio C HamanoJul 12, 2010
  27. 09/13 print the line logBo Yang, Jul 11, 2010
  28. Junio C HamanoJul 12, 2010
  29. 10/13 map/print ranges along traversing the history topologicallyBo Yang, Jul 11, 2010
  30. Junio C HamanoJul 12, 2010
  31. 11/13 add --always-print optionBo Yang, Jul 11, 2010
  32. Junio C HamanoJul 13, 2010
  33. 12/13 add two test casesBo Yang, Jul 11, 2010
  34. 13/13 some document updateBo Yang, Jul 11, 2010
  35. Jakub NarebskiJul 11, 2010
  36. Bo YangJul 12, 2010
  37. Junio C HamanoJul 12, 2010
  38. Bo YangJul 18, 2010
  39. Junio C HamanoJul 12, 2010

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.