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

[PATCH 1/2] stat_tracking_info(): only count real commits

From
KBKjetil Barvik <barvik@broadpark.no>
Date
Mar 4, 2009, 17:47 UTC
Message-ID
<6f183d66558114720e5f193ed028eba53727b330.1236187259.git.barvik@broadpark.no>
In-Reply-To
<cover.1236187259.git.barvik@broadpark.no>

stat_tracking_info() in remote.c is used to collect the statistics to be able to say (for instance) from the output of "git checkout':

  Your branch and 'foo' have diverged,
  and have X and Y different commit(s) each, respectively.

Currently X and Y also includes the count of merges. This patch excludes the merges from being counted.

Signed-off-by: Kjetil Barvik <barvik@broadpark.no>
---
  I hope this is a correct fix, and that it is realy a bugfix.
  ~~
  By the way, I have noticed that when the Y number above is large
  (for instance for a branch I have where Y is ~ 600), then the
  function get_merge_bases_many() and in particular merge_bases_many()
  in commit.c will take a noticable amount of user time (aprox 0.4
  seconds).  So if the chekcout results in that few files need to be
  updated (< 10), this will sometimes acount for much of the total
  time needed for the 'git checkout' command.
  It seems that even though only max 4000 or so unique commits is
  touched (when Y ~ 600), each commit is touched over 250 times, for
  instancce by the insert_by_date() function inside the while-loop in
  merge_bases_many().
  Do someone think it is possible to have a better algorithm here?
  Maybe O(Nlog(n)) or better?  Does someone has a hint about how to
  make it better?
 remote.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/remote.c b/remote.c
index d7079c6..06c414e 100644
--- a/remote.c
+++ b/remote.c
@@ -1310,9 +1310,10 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
 	if (theirs == ours)
 		return 0;
 
-	/* Run "rev-list --left-right ours...theirs" internally... */
+	/* Run "rev-list --no-merges --left-right ours...theirs" internally... */
 	rev_argc = 0;
 	rev_argv[rev_argc++] = NULL;
+	rev_argv[rev_argc++] = "--no-merges";
 	rev_argv[rev_argc++] = "--left-right";
 	rev_argv[rev_argc++] = symmetric;
 	rev_argv[rev_argc++] = "--";
-- 
1.6.1.GIT
Previous: Kjetil BarvikNext: Kjetil Barvik
Message 2 of 11 in “some few more 'git checkout' improvements”
  1. 0/2 some few more 'git checkout' improvementsKjetil Barvik, Mar 4, 2009
  2. 1/2 stat_tracking_info(): only count real commitsKjetil Barvik, Mar 4, 2009
  3. 2/2 better introduction of GIT with USE_NSEC definedKjetil Barvik, Mar 4, 2009
  4. Junio C HamanoMar 5, 2009
  5. Kjetil BarvikMar 5, 2009
  6. Junio C HamanoMar 5, 2009
  7. Johannes SixtMar 5, 2009
  8. Johannes SixtMar 5, 2009
  9. Junio C HamanoMar 5, 2009
  10. Junio C HamanoMar 5, 2009
  11. Johannes SixtMar 6, 2009

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.