use mode of the tree in git-diff, if <tree>:<file> syntax is used
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <junkio@cox.net>
Martin Koegler committed
Apr 22, 2007 at 18:44 UTC
01618a3ab131548582f4e2371b9b5e7328f61e4a
1 file changed
+14
-6
builtin-diff.c
+14
-6
@@ -13,13 +13,10 @@
13
#include "log-tree.h"
14
#include "builtin.h"
15
16
-/* NEEDSWORK: struct object has place for name but we _do_
17
- * know mode when we extracted the blob out of a tree, which
18
- * we currently lose.
19
- */
16
struct blobinfo {
17
unsigned char sha1[20];
18
const char *name;
19
+ unsigned mode;
20
};
21
22
static const char builtin_diff_usage[] =
@@ -70,8 +67,12 @@ static int builtin_diff_b_f(struct rev_info *revs,
67
die("'%s': %s", path, strerror(errno));
68
if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
69
die("'%s': not a regular file or symlink", path);
70
+
71
+ if (blob[0].mode == S_IFINVALID)
72
+ blob[0].mode = canon_mode(st.st_mode);
73
+
74
stuff_change(&revs->diffopt,
74
- canon_mode(st.st_mode), canon_mode(st.st_mode),
75
+ blob[0].mode, canon_mode(st.st_mode),
76
blob[0].sha1, null_sha1,
77
path, path);
78
diffcore_std(&revs->diffopt);
@@ -88,8 +89,14 @@ static int builtin_diff_blobs(struct rev_info *revs,
89
if (argc > 1)
90
usage(builtin_diff_usage);
91
92
+ if (blob[0].mode == S_IFINVALID)
93
+ blob[0].mode = mode;
94
+
95
+ if (blob[1].mode == S_IFINVALID)
96
+ blob[1].mode = mode;
97
+
98
stuff_change(&revs->diffopt,
92
- mode, mode,
99
+ blob[0].mode, blob[1].mode,
100
blob[0].sha1, blob[1].sha1,
101
blob[0].name, blob[1].name);
102
diffcore_std(&revs->diffopt);
@@ -272,6 +279,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
279
die("more than two blobs given: '%s'", name);
280
hashcpy(blob[blobs].sha1, obj->sha1);
281
blob[blobs].name = name;
282
+ blob[blobs].mode = list->mode;
283
blobs++;
284
continue;
285