From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org
Cc: Jay Soffian <jaysoffian@gmail.com>,
Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
Michael Haggerty <mhagger@alum.mit.edu>
Subject: [PATCH 2/2] diff_index: honor in-index, not working-tree, .gitattributes
Date: Thu, 22 Sep 2011 17:44:21 -0400 [thread overview]
Message-ID: <1316727861-90460-2-git-send-email-jaysoffian@gmail.com> (raw)
In-Reply-To: <1316727861-90460-1-git-send-email-jaysoffian@gmail.com>
When diff'ing the index against a tree (using either diff-index
or diff --cached), git previously looked at .gitattributes in the
working tree before considering .gitattributes in the index, even
though the diff itself otherwise ignores the working tree.
Further, with an index, but no working tree, the in-index
.gitattributes were ignored entirely.
Calling git_attr_set_direction(GIT_ATTR_INDEX) before generating
the diff fixes both of these behaviors.
---
This is a weather balloon patch I guess.
Obviously there is a behavior change here as evidenced by the change to
t4020-diff-external.sh. I think the old behavior was wrong and this is a
bug fix. But the old behavior has been that way a long time, so maybe
we should use '--cached-attributes' instead for the "correct" behavior.
Since I'm not really sure what we should do with --cached -R, I'm
punting on that for now.
Jeff's message regarding diff-tree made my head hurt, so tackling that
will have to wait...
diff-lib.c | 3 +++
t/t4020-diff-external.sh | 4 ++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index f8454dd291..fe218931e6 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -11,6 +11,7 @@
#include "unpack-trees.h"
#include "refs.h"
#include "submodule.h"
+#include "attr.h"
/*
* diff-files
@@ -476,6 +477,8 @@ static int diff_cache(struct rev_info *revs,
int run_diff_index(struct rev_info *revs, int cached)
{
struct object_array_entry *ent;
+ if (cached)
+ git_attr_set_direction(GIT_ATTR_INDEX, NULL);
ent = revs->pending.objects;
if (diff_cache(revs, ent->item->sha1, ent->name, cached))
diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index 083f62d1d6..c6fdab3e87 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -160,10 +160,10 @@ test_expect_success 'external diff with autocrlf = true' '
'
test_expect_success 'diff --cached' '
- git add file &&
+ git add .gitattributes file &&
git update-index --assume-unchanged file &&
echo second >file &&
- git diff --cached >actual &&
+ git diff --cached file >actual &&
test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual
'
--
1.7.7.rc2.5.g12a2f
next prev parent reply other threads:[~2011-09-22 21:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-22 21:44 [PATCH 1/2] Teach '--cached' option to check-attr Jay Soffian
2011-09-22 21:44 ` Jay Soffian [this message]
2011-09-22 22:39 ` [PATCH 2/2] diff_index: honor in-index, not working-tree, .gitattributes Junio C Hamano
2011-09-23 0:38 ` Jay Soffian
2011-09-23 5:37 ` Jay Soffian
2011-09-23 16:44 ` Junio C Hamano
2011-09-23 21:32 ` Jay Soffian
2011-09-23 21:48 ` Junio C Hamano
2011-09-23 10:21 ` Michael Haggerty
2011-09-23 15:50 ` Jay Soffian
2011-09-22 23:36 ` [PATCH 1/2] Teach '--cached' option to check-attr 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=1316727861-90460-2-git-send-email-jaysoffian@gmail.com \
--to=jaysoffian@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
--cc=peff@peff.net \
/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).