- strbuf_add(base, path1, pathlen1);
- if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
- if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {
- opt->change(opt, mode1, mode2,
- sha1, sha2, 1, 1, base->buf, 0, 0);
+ show_path(base, opt, t1, t2);
+ return 0;
+}
+
+
+/* convert path, t1/t2 -> opt->diff_*() callbacks */
+static void emit_diff(struct diff_options *opt, struct strbuf *path,
+ struct tree_desc *t1, struct tree_desc *t2)
+{
+ unsigned int mode1 = t1 ? t1->entry.mode : 0;
+ unsigned int mode2 = t2 ? t2->entry.mode : 0;
+
+ if (mode1 && mode2) {
+ opt->change(opt, mode1, mode2, t1->entry.sha1, t2->entry.sha1,
+ 1, 1, path->buf, 0, 0);
+ }
+ else {
+ const unsigned char *sha1;
+ unsigned int mode;
+ int addremove;
+
+ if (mode2) {
+ addremove = '+';
+ sha1 = t2->entry.sha1;
+ mode = mode2;
+ } else {
+ addremove = '-';
+ sha1 = t1->entry.sha1;
+ mode = mode1;