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

Re: Confusing git log --- First time bug submission please advise on best practices

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 7, 2014, 10:26 UTC
Message-ID
<20140207102619.GA27616@lanh>
In-Reply-To
<CAJaBJzKy0b8MBuB_X_4n8E2=q=CyrpxOyFFrgv_2CQ19pkNmwQ@mail.gmail.com>
On Fri, Feb 07, 2014 at 09:43:46AM +0000, Francis Stephens wrote:
> Thanks for your clear response. I can see where I went wrong now.

Maybe something like this would help avoid confusion a bit in the future? This toy patch puts a horizontal line as a break between two commits if they are not related, so we can clearly see linear commit segments.

--graph definitely helps, but it's too many threads for topic-based development model like git.git that I avoid it most of the time.

-- 8< --
diff --git a/log-tree.c b/log-tree.c
index 08970bf..7841bf2 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -795,6 +795,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
 
 int log_tree_commit(struct rev_info *opt, struct commit *commit)
 {
+	static struct commit_list *last_parents;
 	struct log_info log;
 	int shown;
 
@@ -805,6 +806,17 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
 	if (opt->line_level_traverse)
 		return line_log_print(opt, commit);
 
+	if (last_parents) {
+		struct commit_list *p = last_parents;
+		int got_parent = 0;
+		for (; p && !got_parent; p = p->next)
+			got_parent = !hashcmp(p->item->object.sha1,
+					      commit->object.sha1);
+		if (!got_parent)
+			printf("______________________________________________________________________\n");
+		free_commit_list(last_parents);
+		last_parents = NULL;
+	}
 	shown = log_tree_diff(opt, commit, &log);
 	if (!shown && opt->loginfo && opt->always_show_header) {
 		log.parent = NULL;
@@ -813,5 +825,6 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
 	}
 	opt->loginfo = NULL;
 	maybe_flush_or_die(stdout, "stdout");
+	last_parents = copy_commit_list(commit->parents);
 	return shown;
 }
-- 8< --

> 
> On Thu, Feb 6, 2014 at 4:10 PM, David Kastrup <dak@gnu.org> wrote:
> > Vincent van Ravesteijn <vfr@lyx.org> writes:
> >
> >> The commits that are in the log for master and which are not in the
> >> log for originssh/master are merged in at "6833fd4 (HEAD, master);
> >> Completed merge".
> >>
> >> As "git log" can only present the commits in a linear way, it shows
> >> the commits from the ancentry of both parents of HEAD in a reverse
> >> chronological order. This means that the commits from the two
> >> ancestries are mixed and commits that are shown after each other don't
> >> have to be parent and child. See the documentation of "git log" and
> >> the section "Commit Ordering": "By default, the commits are shown in
> >> reverse chronological order."
> >
> > git log --graph can help with getting a better picture.
Previous: Francis StephensNext: demerphq
Message 5 of 19 in “Confusing git log --- First time bug submission please advise on best practices”
  1. Francis StephensFeb 6, 2014
  2. Vincent van RavesteijnFeb 6, 2014
  3. David KastrupFeb 6, 2014
  4. Francis StephensFeb 7, 2014
  5. Duy NguyenFeb 7, 2014
  6. demerphqFeb 7, 2014
  7. log: add --show-linear-break to help see non-linear historyNguyễn Thái Ngọc Duy, Feb 8, 2014
  8. log: add --nonlinear-barrier to help see non-linear historyNguyễn Thái Ngọc Duy, Mar 17, 2014
  9. Eric SunshineMar 17, 2014
  10. Junio C HamanoMar 17, 2014
  11. Duy NguyenMar 18, 2014
  12. Junio C HamanoMar 18, 2014
  13. 1/2 object.h: centralize object flag allocationNguyễn Thái Ngọc Duy, Mar 20, 2014
  14. 2/2 log: add --show-linear-break to help see non-linear historyNguyễn Thái Ngọc Duy, Mar 20, 2014
  15. Junio C HamanoMar 20, 2014
  16. Duy NguyenMar 21, 2014
  17. 1/2 object.h: centralize object flag allocationNguyễn Thái Ngọc Duy, Mar 25, 2014
  18. 2/2 log: add --show-linear-break to help see non-linear historyNguyễn Thái Ngọc Duy, Mar 25, 2014
  19. Junio C HamanoMar 25, 2014

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.