From: Steffen Prohaska <prohaska@zib.de>
To: gitster@pobox.com, dmitry.kakurin@gmail.com
Cc: git@vger.kernel.org, Steffen Prohaska <prohaska@zib.de>
Subject: [PATCH 2/2] checkout: fix attribute handling in checkout all
Date: Sun, 12 Aug 2007 22:34:35 +0200 [thread overview]
Message-ID: <118695087531-git-send-email-prohaska@zib.de> (raw)
In-Reply-To: <11869508753328-git-send-email-prohaska@zib.de>
We need to check out .gitattributes files first to have
them in place when we check out the remaining files. This
is needed to get the right attributes during checkout,
for example having the right crlf conversion on the first
checkout if crlf is controlled by a .gitattribute file.
This works only together with the commit
'attr: fix attribute handling if .gitattributes is involved'
which ensures that .gitattributes files do not trigger the
attribute machinery too early.
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
builtin-checkout-index.c | 47 ++++++++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/builtin-checkout-index.c b/builtin-checkout-index.c
index 75377b9..5e87a39 100644
--- a/builtin-checkout-index.c
+++ b/builtin-checkout-index.c
@@ -125,27 +125,38 @@ static int checkout_file(const char *name, int prefix_length)
static void checkout_all(const char *prefix, int prefix_length)
{
- int i, errs = 0;
+ int i, pass, errs = 0;
struct cache_entry* last_ce = NULL;
- for (i = 0; i < active_nr ; i++) {
- struct cache_entry *ce = active_cache[i];
- if (ce_stage(ce) != checkout_stage
- && (CHECKOUT_ALL != checkout_stage || !ce_stage(ce)))
- continue;
- if (prefix && *prefix &&
- (ce_namelen(ce) <= prefix_length ||
- memcmp(prefix, ce->name, prefix_length)))
- continue;
- if (last_ce && to_tempfile) {
- if (ce_namelen(last_ce) != ce_namelen(ce)
- || memcmp(last_ce->name, ce->name, ce_namelen(ce)))
- write_tempfile_record(last_ce->name, prefix_length);
+ /* pass 0: check out only .gitattribute files
+ pass 1: check out every file
+
+ This is needed to have all .gitattributes in place before
+ checking out files, and thus do the right conversion.
+ */
+ for (pass = 0; pass < 2; pass++) {
+ for (i = 0; i < active_nr ; i++) {
+ struct cache_entry *ce = active_cache[i];
+ if (pass == 0 && strstr (ce->name, GITATTRIBUTES_FILE) == 0) {
+ continue;
+ }
+ if (ce_stage(ce) != checkout_stage
+ && (CHECKOUT_ALL != checkout_stage || !ce_stage(ce)))
+ continue;
+ if (prefix && *prefix &&
+ (ce_namelen(ce) <= prefix_length ||
+ memcmp(prefix, ce->name, prefix_length)))
+ continue;
+ if (last_ce && to_tempfile) {
+ if (ce_namelen(last_ce) != ce_namelen(ce)
+ || memcmp(last_ce->name, ce->name, ce_namelen(ce)))
+ write_tempfile_record(last_ce->name, prefix_length);
+ }
+ if (checkout_entry(ce, &state,
+ to_tempfile ? topath[ce_stage(ce)] : NULL) < 0)
+ errs++;
+ last_ce = ce;
}
- if (checkout_entry(ce, &state,
- to_tempfile ? topath[ce_stage(ce)] : NULL) < 0)
- errs++;
- last_ce = ce;
}
if (last_ce && to_tempfile)
write_tempfile_record(last_ce->name, prefix_length);
--
1.5.3.rc4.96.g6ceb
next prev parent reply other threads:[~2007-08-12 20:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-12 20:34 [PATCH 1/2] attr: fix attribute handling if .gitattributes is involved Steffen Prohaska
2007-08-12 20:34 ` Steffen Prohaska [this message]
2007-08-12 21:50 ` [PATCH 2/2] checkout: fix attribute handling in checkout all Junio C Hamano
2007-08-12 22:26 ` Steffen Prohaska
2007-08-13 6:14 ` Junio C Hamano
2007-08-13 6:32 ` Marius Storm-Olsen
2007-08-13 6:50 ` Steffen Prohaska
2007-08-13 7:15 ` Marius Storm-Olsen
2007-08-13 7:32 ` Steffen Prohaska
2007-08-13 8:39 ` Marius Storm-Olsen
2007-08-13 8:51 ` Steffen Prohaska
2007-08-13 14:35 ` Dmitry Kakurin
2007-08-14 8:40 ` [PATCH 1/2] attr.c: refactoring Junio C Hamano
2007-08-14 8:41 ` [PATCH 2/2] attr.c: read .gitattributes from index as well Junio C Hamano
2007-08-13 6:46 ` [PATCH 2/2] checkout: fix attribute handling in checkout all Steffen Prohaska
2007-08-13 16:14 ` Johannes Schindelin
2007-08-13 7:24 ` David Kastrup
2007-08-13 14:55 ` git-update-ref bug? (was: [PATCH 2/2] checkout: fix attribute handling in checkout all) David Kastrup
2007-08-13 20:12 ` [PATCH 2/2] checkout: fix attribute handling in checkout all Junio C Hamano
2007-08-13 1:51 ` [PATCH 1/2] attr: fix attribute handling if .gitattributes is involved Brian Downing
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=118695087531-git-send-email-prohaska@zib.de \
--to=prohaska@zib.de \
--cc=dmitry.kakurin@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).