projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sha1_name: make core.warnambiguousrefs the default.
[git.git]
/
combine-diff.c
diff --git
a/combine-diff.c
b/combine-diff.c
index
a38f01b
..
a23894d
100644
(file)
--- a/
combine-diff.c
+++ b/
combine-diff.c
@@
-621,7
+621,8
@@
static void reuse_combine_diff(struct sline *sline, unsigned long cnt,
}
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
}
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
- int dense, const char *header)
+ int dense, const char *header,
+ struct diff_options *opt)
{
unsigned long size, cnt, lno;
char *result, *cp, *ep;
{
unsigned long size, cnt, lno;
char *result, *cp, *ep;
@@
-630,9
+631,11
@@
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
int i, show_hunks, shown_header = 0;
char ourtmp_buf[TMPPATHLEN];
char *ourtmp = ourtmp_buf;
int i, show_hunks, shown_header = 0;
char ourtmp_buf[TMPPATHLEN];
char *ourtmp = ourtmp_buf;
+ int working_tree_file = !memcmp(elem->sha1, null_sha1, 20);
+ int abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;
/* Read the result of merge first */
/* Read the result of merge first */
- if (
memcmp(elem->sha1, null_sha1, 20)
) {
+ if (
!working_tree_file
) {
result = grab_blob(elem->sha1, &size);
write_to_temp_file(ourtmp, result, size);
}
result = grab_blob(elem->sha1, &size);
write_to_temp_file(ourtmp, result, size);
}
@@
-646,6
+649,7
@@
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
int len = st.st_size;
int cnt = 0;
int len = st.st_size;
int cnt = 0;
+ elem->mode = DIFF_FILE_CANON_MODE(st.st_mode);
size = len;
result = xmalloc(len + 1);
while (cnt < len) {
size = len;
result = xmalloc(len + 1);
while (cnt < len) {
@@
-661,6
+665,7
@@
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
else {
/* deleted file */
size = 0;
else {
/* deleted file */
size = 0;
+ elem->mode = 0;
result = xmalloc(1);
result[0] = 0;
ourtmp = "/dev/null";
result = xmalloc(1);
result[0] = 0;
ourtmp = "/dev/null";
@@
-716,12
+721,12
@@
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
show_hunks = make_hunks(sline, cnt, num_parent, dense);
show_hunks = make_hunks(sline, cnt, num_parent, dense);
- if (show_hunks || mode_differs) {
+ if (show_hunks || mode_differs
|| working_tree_file
) {
const char *abb;
if (header) {
shown_header++;
const char *abb;
if (header) {
shown_header++;
- p
uts(header
);
+ p
rintf("%s%c", header, opt->line_termination
);
}
printf("diff --%s ", dense ? "cc" : "combined");
if (quote_c_style(elem->path, NULL, NULL, 0))
}
printf("diff --%s ", dense ? "cc" : "combined");
if (quote_c_style(elem->path, NULL, NULL, 0))
@@
-731,13
+736,11
@@
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
putchar('\n');
printf("index ");
for (i = 0; i < num_parent; i++) {
putchar('\n');
printf("index ");
for (i = 0; i < num_parent; i++) {
- if (elem->parent[i].mode != elem->mode)
- mode_differs = 1;
abb = find_unique_abbrev(elem->parent[i].sha1,
abb = find_unique_abbrev(elem->parent[i].sha1,
-
DEFAULT_ABBREV
);
+
abbrev
);
printf("%s%s", i ? "," : "", abb);
}
printf("%s%s", i ? "," : "", abb);
}
- abb = find_unique_abbrev(elem->sha1,
DEFAULT_ABBREV
);
+ abb = find_unique_abbrev(elem->sha1,
abbrev
);
printf("..%s\n", abb);
if (mode_differs) {
printf("..%s\n", abb);
if (mode_differs) {
@@
-796,7
+799,7
@@
static void show_raw_diff(struct combine_diff_path *p, int num_parent, const cha
inter_name_termination = 0;
if (header)
inter_name_termination = 0;
if (header)
- p
uts(header
);
+ p
rintf("%s%c", header, line_termination
);
for (i = 0; i < num_parent; i++) {
if (p->parent[i].mode)
for (i = 0; i < num_parent; i++) {
if (p->parent[i].mode)
@@
-861,7
+864,7
@@
int show_combined_diff(struct combine_diff_path *p,
default:
case DIFF_FORMAT_PATCH:
default:
case DIFF_FORMAT_PATCH:
- return show_patch_diff(p, num_parent, dense, header);
+ return show_patch_diff(p, num_parent, dense, header
, opt
);
}
}
}
}