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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---

  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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux