git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: rv@rasmusvillemoes.dk, "Jeff King" <peff@peff.net>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 6/6] shallow.c: remove useless code
Date: Tue,  6 Dec 2016 19:53:39 +0700	[thread overview]
Message-ID: <20161206125339.16803-7-pclouds@gmail.com> (raw)
In-Reply-To: <20161206125339.16803-1-pclouds@gmail.com>

Some context before we talk about the removed code.

This paint_down() is part of step 6 of 58babff (shallow.c: the 8 steps
to select new commits for .git/shallow - 2013-12-05). When we fetch from
a shallow repository, we need to know if one of the new/updated refs
needs new "shallow commits" in .git/shallow (because we don't have
enough history of those refs) and which one.

The question at step 6 is, what (new) shallow commits are required in
other to maintain reachability throughout the repository _without_
cutting our history short? To answer, we mark all commits reachable from
existing refs with UNINTERESTING ("rev-list --not --all"), mark shallow
commits with BOTTOM, then for each new/updated refs, walk through the
commit graph until we either hit UNINTERESTING or BOTTOM, marking the
ref on the commit as we walk.

After all the walking is done, we check the new shallow commits. If we
have not seen any new ref marked on a new shallow commit, we know all
new/updated refs are reachable using just our history and .git/shallow.
The shallow commit in question is not needed and can be thrown away.

So, the code.

The loop here (to walk through commits) is basically

1.  get one commit from the queue
2.  ignore if it's SEEN or UNINTERESTING
3.  mark it
4.  go through all the parents and..
5a. mark it if it's never marked before
5b. put it back in the queue

What we do in this patch is drop step 5a because it is not
necessary. The commit being marked at 5a is put back on the queue, and
will be marked at step 3 at the next iteration. The only case it will
not be marked is when the commit is already marked UNINTERESTING (5a
does not check this), which will be ignored at step 2.

But we don't care about refs marking on UNINTERESTING. We care about the
marking on _shallow commits_ that are not reachable from our current
history (and having UNINTERESTING on it means it's reachable). So it's
ok for an UNINTERESTING not to be ref-marked.

Reported-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 shallow.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/shallow.c b/shallow.c
index beb967e..11f7dde 100644
--- a/shallow.c
+++ b/shallow.c
@@ -512,12 +512,8 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
 			    oid_to_hex(&c->object.oid));
 
 		for (p = c->parents; p; p = p->next) {
-			uint32_t **p_refs = ref_bitmap_at(&info->ref_bitmap,
-							  p->item);
 			if (p->item->object.flags & SEEN)
 				continue;
-			if (*p_refs == NULL || *p_refs == *refs)
-				*p_refs = *refs;
 			commit_list_insert(p->item, &head);
 		}
 	}
-- 
2.8.2.524.g6ff3d78


  parent reply	other threads:[~2016-12-06 12:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02 20:31 [PATCH 1/4] shallow.c: make paint_alloc slightly more robust Rasmus Villemoes
2016-12-02 20:31 ` [PATCH 2/4] shallow.c: avoid theoretical pointer wrap-around Rasmus Villemoes
2016-12-03  5:17   ` Jeff King
2016-12-02 20:31 ` [PATCH 3/4] shallow.c: bit manipulation tweaks Rasmus Villemoes
2016-12-03  5:21   ` Jeff King
2016-12-02 20:31 ` [PATCH 4/4] shallow.c: remove useless test Rasmus Villemoes
2016-12-03  5:24   ` Jeff King
2016-12-05 12:00     ` Duy Nguyen
2016-12-03  5:14 ` [PATCH 1/4] shallow.c: make paint_alloc slightly more robust Jeff King
2016-12-05 10:02   ` Duy Nguyen
2016-12-06 12:53 ` [PATCH v2 0/6] shallow.c improvements Nguyễn Thái Ngọc Duy
2016-12-06 12:53   ` [PATCH v2 1/6] shallow.c: rename fields in paint_info to better express their purposes Nguyễn Thái Ngọc Duy
2016-12-06 12:53   ` [PATCH v2 2/6] shallow.c: stop abusing COMMIT_SLAB_SIZE for paint_info's memory pools Nguyễn Thái Ngọc Duy
2016-12-06 12:53   ` [PATCH v2 3/6] shallow.c: make paint_alloc slightly more robust Nguyễn Thái Ngọc Duy
2016-12-06 12:53   ` [PATCH v2 4/6] shallow.c: avoid theoretical pointer wrap-around Nguyễn Thái Ngọc Duy
2016-12-06 12:53   ` [PATCH v2 5/6] shallow.c: bit manipulation tweaks Nguyễn Thái Ngọc Duy
2016-12-06 12:53   ` Nguyễn Thái Ngọc Duy [this message]
2016-12-06 13:42   ` [PATCH v2 0/6] shallow.c improvements Jeff King
2016-12-06 13:47     ` Duy Nguyen
2016-12-07 23:42       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161206125339.16803-7-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=rv@rasmusvillemoes.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).