git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Feature request : "git fsck" should show the percentage of completeness in step "Checking connectivity:"
@ 2018-07-01 16:21 Toralf Förster
  2018-07-02 19:59 ` Stefan Beller
  2018-07-02 21:41 ` Jeff King
  0 siblings, 2 replies; 3+ messages in thread
From: Toralf Förster @ 2018-07-01 16:21 UTC (permalink / raw)
  To: git

as "git fsck" does it already for "Checking objects:"

Is this a valid feature request?

-- 
Toralf
PGP C4EACDDE 0076E94E

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Feature request : "git fsck" should show the percentage of completeness in step "Checking connectivity:"
  2018-07-01 16:21 Feature request : "git fsck" should show the percentage of completeness in step "Checking connectivity:" Toralf Förster
@ 2018-07-02 19:59 ` Stefan Beller
  2018-07-02 21:41 ` Jeff King
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Beller @ 2018-07-02 19:59 UTC (permalink / raw)
  To: toralf.foerster; +Cc: git

On Sun, Jul 1, 2018 at 9:22 AM Toralf Förster <toralf.foerster@gmx.de> wrote:
>
> as "git fsck" does it already for "Checking objects:"
>
> Is this a valid feature request?

Yes it is. However it is most likely to have the feature incorporated if
it comes in form of a patch.

So clone one of the git.git repositories found at
https://git-blame.blogspot.com/p/git-public-repositories.html
and have a look builtin/fsck.c (Search for "Checking connectivity")
as well as how the progress.{h, c} for its API if needed.

I am not sure if this is an easy thing to add, as knowing the number
of objects before the walk might be hard. How does "Checking objects"
solve that issue?

See Documentation/SubmittingPatches once you have some code
that can be a starter of a discussion. :)

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Feature request : "git fsck" should show the percentage of completeness in step "Checking connectivity:"
  2018-07-01 16:21 Feature request : "git fsck" should show the percentage of completeness in step "Checking connectivity:" Toralf Förster
  2018-07-02 19:59 ` Stefan Beller
@ 2018-07-02 21:41 ` Jeff King
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2018-07-02 21:41 UTC (permalink / raw)
  To: Toralf Förster; +Cc: git

On Sun, Jul 01, 2018 at 06:21:40PM +0200, Toralf Förster wrote:

> as "git fsck" does it already for "Checking objects:"
> 
> Is this a valid feature request?

It's actually hard to do accurately. We don't know how many objects are
reachable until we traverse the graph...which is exactly what the
"checking connectivity" operation is doing.

The operation is bounded by the total number of objects in the
repository. We may have duplicates (in multiple packs, or loose/packed),
and objects which aren't reachable at all. But we could make that a
guess, and just "jump" to 100% at the end.

The code might look something like the patch below. I'm not sure if it's
a good idea or not (I mostly copied the counting from
builtin/count-objects.c; it might be nice to factor that out).

-Peff

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 3ad4f160f9..52e79aed76 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -192,17 +192,49 @@ static int traverse_one_object(struct object *obj)
 	return result;
 }
 
+static int count_loose(const struct object_id *oid, const char *path,
+		       void *data)
+{
+	unsigned int *nr = data;
+	nr++;
+	return 0;
+}
+
+static unsigned object_max(void)
+{
+	unsigned max = 0;
+	struct packed_git *p;
+
+	for_each_loose_object(count_loose, &max, 0);
+
+	for (p = get_packed_git(the_repository); p; p = p->next) {
+		if (open_pack_index(p))
+			continue;
+		max += p->num_objects;
+	}
+
+	return max;
+}
+
 static int traverse_reachable(void)
 {
 	struct progress *progress = NULL;
 	unsigned int nr = 0;
 	int result = 0;
-	if (show_progress)
-		progress = start_delayed_progress(_("Checking connectivity"), 0);
+	unsigned int max = 0;
+
+	if (show_progress) {
+		max = object_max();
+		progress = start_delayed_progress(_("Checking connectivity"),
+						  max);
+	}
+
 	while (pending.nr) {
 		result |= traverse_one_object(object_array_pop(&pending));
 		display_progress(progress, ++nr);
 	}
+
+	display_progress(progress, max);
 	stop_progress(&progress);
 	return !!result;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-02 21:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-01 16:21 Feature request : "git fsck" should show the percentage of completeness in step "Checking connectivity:" Toralf Förster
2018-07-02 19:59 ` Stefan Beller
2018-07-02 21:41 ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).