git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] count-objects: report garbage files in .git/objects/pack directory too
Date: Mon, 04 Feb 2013 10:16:23 -0800	[thread overview]
Message-ID: <7v1ucw2bd4.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1359982145-10792-2-git-send-email-pclouds@gmail.com> ("Nguyễn	Thái Ngọc Duy"'s message of "Mon, 4 Feb 2013 19:49:05 +0700")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> @@ -1024,11 +1035,15 @@ static void prepare_packed_git_one(char *objdir, int local)
>  		int namelen = strlen(de->d_name);
>  		struct packed_git *p;
>  
> -		if (!has_extension(de->d_name, ".idx"))
> +		if (!has_extension(de->d_name, ".idx")) {
> +			report_pack_garbage(path, len - 1, de->d_name);
>  			continue;
> +		}
>  
> -		if (len + namelen + 1 > sizeof(path))
> +		if (len + namelen + 1 > sizeof(path)) {
> +			report_pack_garbage(path, len - 1, de->d_name);
>  			continue;
> +		}
>  
>  		/* Don't reopen a pack we already have. */
>  		strcpy(path + len, de->d_name);
> @@ -1042,8 +1057,10 @@ static void prepare_packed_git_one(char *objdir, int local)
>  		 * .pack file that we can map.
>  		 */
>  		p = add_packed_git(path, len + namelen, local);
> -		if (!p)
> +		if (!p) {
> +			report_pack_garbage(path, len - 1, de->d_name);
>  			continue;
> +		}
>  		install_packed_git(p);
>  	}
>  	closedir(dir);

I forgot to mention one more thing.  Your report_pack_garbage()
special cases ".pack" to see if it is a regular file, but this loop
structure causes a regular file whose name ends with ".pack" but
without corresponding ".idx" file to go unreported.

I think the loop should be restructured to iterate over all known
file types and report unknown ones, if you want to repurpose it for
the reporting, something along this line, perhaps:

	for (each name) {
		if (does it end with ".idx") {
			if (is it unusable ".idx") {
				report garbage;
			}
                        continue;
		}
		if (! we are in report mode)
			continue;
		if (does it end with ".pack") {
			if (!have we seen corresponding ".idx")
				remember it;
			continue;
		}
		report garbage;
	}
	for (remembered pack) {
		if (does it have corresponding ".idx" &&
			is it really usable ".pack")
			continue;
		report garbage;
	}

  parent reply	other threads:[~2013-02-04 18:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-04 12:49 [PATCH 1/2] git-count-objects.txt: describe each line in -v output Nguyễn Thái Ngọc Duy
2013-02-04 12:49 ` [PATCH 2/2] count-objects: report garbage files in .git/objects/pack directory too Nguyễn Thái Ngọc Duy
2013-02-04 17:06   ` Junio C Hamano
2013-02-04 18:16   ` Junio C Hamano [this message]
2013-02-07  7:37     ` Duy Nguyen
2013-02-07 18:12       ` Junio C Hamano
2013-02-07 23:58         ` Duy Nguyen
2013-02-08  3:48 ` [PATCH v2 0/3] count-objects improvements Nguyễn Thái Ngọc Duy
2013-02-08  3:48   ` [PATCH v2 1/3] git-count-objects.txt: describe each line in -v output Nguyễn Thái Ngọc Duy
2013-02-08  3:48   ` [PATCH v2 2/3] count-objects: report garbage files in pack directory too Nguyễn Thái Ngọc Duy
2013-02-08 18:44     ` Junio C Hamano
2013-02-09  1:58       ` Duy Nguyen
2013-02-08  3:48   ` [PATCH v2 3/3] count-objects: report how much disk space taken by garbage files Nguyễn Thái Ngọc Duy
2013-02-08 18:47     ` 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

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

  git send-email \
    --in-reply-to=7v1ucw2bd4.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /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.
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 NNTP newsgroup(s).