From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Christian Couder <chriscool@tuxfamily.org>
Subject: [PATCH 3/3] diff-files: careful when inspecting work tree items
Date: Sun, 30 Mar 2008 17:30:08 -0700 [thread overview]
Message-ID: <7viqz3u44v.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 7v4panyduy.fsf@gitster.siamese.dyndns.org
This fixes the same breakage in diff-files.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff-lib.c | 17 +++++++++++------
t/t2201-add-update-typechange.sh | 6 +++---
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index a8e107a..d4ad6b6 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -362,10 +362,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
int silent_on_removed = option & DIFF_SILENT_ON_REMOVED;
unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
? CE_MATCH_RACY_IS_DIRTY : 0);
+ char symcache[PATH_MAX];
if (diff_unmerged_stage < 0)
diff_unmerged_stage = 2;
entries = active_nr;
+ symcache[0] = '\0';
for (i = 0; i < entries; i++) {
struct stat st;
unsigned int oldmode, newmode;
@@ -397,16 +399,17 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
memset(&(dpath->parent[0]), 0,
sizeof(struct combine_diff_parent)*5);
- if (lstat(ce->name, &st) < 0) {
- if (errno != ENOENT && errno != ENOTDIR) {
+ changed = check_work_tree_entity(ce, &st, symcache);
+ if (!changed)
+ dpath->mode = ce_mode_from_stat(ce, st.st_mode);
+ else {
+ if (changed < 0) {
perror(ce->name);
continue;
}
if (silent_on_removed)
continue;
}
- else
- dpath->mode = ce_mode_from_stat(ce, st.st_mode);
while (i < entries) {
struct cache_entry *nce = active_cache[i];
@@ -459,8 +462,10 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
if (ce_uptodate(ce))
continue;
- if (lstat(ce->name, &st) < 0) {
- if (errno != ENOENT && errno != ENOTDIR) {
+
+ changed = check_work_tree_entity(ce, &st, symcache);
+ if (changed) {
+ if (changed < 0) {
perror(ce->name);
continue;
}
diff --git a/t/t2201-add-update-typechange.sh b/t/t2201-add-update-typechange.sh
index 469a8e0..e15e3eb 100755
--- a/t/t2201-add-update-typechange.sh
+++ b/t/t2201-add-update-typechange.sh
@@ -104,7 +104,7 @@ test_expect_success modify '
} >expect-final
'
-test_expect_failure diff-files '
+test_expect_success diff-files '
git diff-files --raw >actual &&
diff -u expect-files actual
'
@@ -114,7 +114,7 @@ test_expect_success diff-index '
diff -u expect-index actual
'
-test_expect_failure 'add -u' '
+test_expect_success 'add -u' '
rm -f ".git/saved-index" &&
cp -p ".git/index" ".git/saved-index" &&
git add -u &&
@@ -122,7 +122,7 @@ test_expect_failure 'add -u' '
diff -u expect-final actual
'
-test_expect_failure 'commit -a' '
+test_expect_success 'commit -a' '
if test -f ".git/saved-index"
then
rm -f ".git/index" &&
--
1.5.5.rc2.131.g3d2f0
prev parent reply other threads:[~2008-03-31 0:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-29 7:13 Possible d/f conflict bug or regression Christian Couder
2008-03-29 8:01 ` Christian Couder
2008-03-30 1:29 ` Bryan Donlan
2008-03-30 4:44 ` Christian Couder
2008-03-30 4:51 ` Bryan Donlan
2008-03-30 23:46 ` Junio C Hamano
2008-03-31 0:28 ` [PATCH 1/3] Add corner case tests for diff-index and diff-files Junio C Hamano
2008-03-31 0:29 ` [PATCH 2/3] diff-index: careful when inspecting work tree items Junio C Hamano
2008-03-31 3:12 ` Junio C Hamano
2008-03-31 3:47 ` Christian Couder
2008-03-31 0:30 ` Junio C Hamano [this message]
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=7viqz3u44v.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
/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).