Created
September 23, 2011 05:33
-
-
Save jaysoffian/1236806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 573d8d2631 (HEAD, master) | |
Author: Jay Soffian <[email protected]> | |
Date: Fri Sep 23 01:26:04 2011 -0400 | |
diff_tree: honor in-tree .gitattributes when used in a bare repo | |
diff --git a/tree-diff.c b/tree-diff.c | |
index b3cc2e4753..6fd84eb2bb 100644 | |
--- a/tree-diff.c | |
+++ b/tree-diff.c | |
@@ -5,6 +5,8 @@ | |
#include "diff.h" | |
#include "diffcore.h" | |
#include "tree.h" | |
+#include "attr.h" | |
+#include "unpack-trees.h" | |
static void show_entry(struct diff_options *opt, const char *prefix, | |
struct tree_desc *desc, struct strbuf *base); | |
@@ -280,6 +282,19 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha | |
die("unable to read destination tree (%s)", sha1_to_hex(new)); | |
init_tree_desc(&t1, tree1, size1); | |
init_tree_desc(&t2, tree2, size2); | |
+ | |
+ if (is_bare_repository()) { | |
+ struct unpack_trees_options unpack_opts; | |
+ memset(&unpack_opts, 0, sizeof(unpack_opts)); | |
+ unpack_opts.index_only = 1; | |
+ unpack_opts.head_idx = -1; | |
+ unpack_opts.src_index = &the_index; | |
+ unpack_opts.dst_index = &the_index; | |
+ unpack_opts.fn = oneway_merge; | |
+ if (unpack_trees(1, DIFF_OPT_TST(opt, REVERSE_DIFF) ? &t1 : &t2, &unpack_opts) == 0) | |
+ git_attr_set_direction(GIT_ATTR_INDEX, &the_index); | |
+ } | |
+ | |
retval = diff_tree(&t1, &t2, base, opt); | |
if (!*base && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename()) { | |
init_tree_desc(&t1, tree1, size1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment