From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Ramsay Jones" <ramsay@ramsay1.demon.co.uk>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v3 2/4] sha1_file: reorder code in prepare_packed_git_one()
Date: Tue, 12 Feb 2013 16:27:55 +0700 [thread overview]
Message-ID: <1360661277-17273-3-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1360661277-17273-1-git-send-email-pclouds@gmail.com>
The current loop does
while (...) {
if (!not .idx file)
continue;
process .idx file;
}
and is reordered to
while (...) {
if (!.idx file) {
process .idx file;
}
}
This makes it easier to add new extension file processing.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
sha1_file.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 40b2329..8d7da1d 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1024,27 +1024,28 @@ 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"))
- continue;
-
if (len + namelen + 1 > sizeof(path))
continue;
- /* Don't reopen a pack we already have. */
strcpy(path + len, de->d_name);
- for (p = packed_git; p; p = p->next) {
- if (!memcmp(path, p->pack_name, len + namelen - 4))
- break;
+
+ if (has_extension(de->d_name, ".idx")) {
+ /* Don't reopen a pack we already have. */
+ for (p = packed_git; p; p = p->next) {
+ if (!memcmp(path, p->pack_name, len + namelen - 4))
+ break;
+ }
+ if (p)
+ continue;
+ /*
+ * See if it really is a valid .idx file with
+ * corresponding .pack file that we can map.
+ */
+ p = add_packed_git(path, len + namelen, local);
+ if (!p)
+ continue;
+ install_packed_git(p);
}
- if (p)
- continue;
- /* See if it really is a valid .idx file with corresponding
- * .pack file that we can map.
- */
- p = add_packed_git(path, len + namelen, local);
- if (!p)
- continue;
- install_packed_git(p);
}
closedir(dir);
}
--
1.8.1.2.536.gf441e6d
next prev parent reply other threads:[~2013-02-12 9:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-12 9:27 [PATCH v3 0/4] count-objects improvements Nguyễn Thái Ngọc Duy
2013-02-12 9:27 ` [PATCH v3 1/4] git-count-objects.txt: describe each line in -v output Nguyễn Thái Ngọc Duy
2013-02-12 9:27 ` Nguyễn Thái Ngọc Duy [this message]
2013-02-12 9:27 ` [PATCH v3 3/4] count-objects: report garbage files in pack directory too Nguyễn Thái Ngọc Duy
2013-02-12 17:23 ` Junio C Hamano
2013-02-13 9:13 ` [PATCH v4 0/4] count-objects improvements Nguyễn Thái Ngọc Duy
2013-02-13 9:13 ` [PATCH v4 1/4] git-count-objects.txt: describe each line in -v output Nguyễn Thái Ngọc Duy
2013-02-13 9:13 ` [PATCH v4 2/4] sha1_file: reorder code in prepare_packed_git_one() Nguyễn Thái Ngọc Duy
2013-02-13 9:13 ` [PATCH v4 3/4] count-objects: report garbage files in pack directory too Nguyễn Thái Ngọc Duy
2013-02-13 15:55 ` Junio C Hamano
2013-02-13 16:54 ` Junio C Hamano
2013-02-14 9:24 ` Duy Nguyen
2013-02-14 17:02 ` Junio C Hamano
2013-02-15 12:07 ` [PATCH v4+ " Nguyễn Thái Ngọc Duy
2013-02-15 23:20 ` Junio C Hamano
2013-02-13 9:13 ` [PATCH v4 4/4] count-objects: report how much disk space taken by garbage files Nguyễn Thái Ngọc Duy
2013-02-12 9:27 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
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=1360661277-17273-3-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ramsay@ramsay1.demon.co.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.