Commit d6ce02f1123a40ccc98f5dfd40168b6d8d986f95

Stefan Sperling 2018-11-17T16:30:29

fix paths in diffs showing newly added trees

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/lib/diff.c b/lib/diff.c
index f251838..be49c12 100644
--- a/lib/diff.c
+++ b/lib/diff.c
@@ -486,6 +486,16 @@ got_diff_tree(struct got_tree_object *tree1, struct got_tree_object *tree2,
 			struct got_tree_entry *te = NULL;
 			if (tree1)
 				te = match_entry_by_name(te2, tree1);
+			free(l2);
+			if (te) {
+				if (asprintf(&l2, "%s%s%s", label2,
+				    label2[0] ? "/" : "", te->name) == -1)
+					return got_error_from_errno();
+			} else {
+				if (asprintf(&l2, "%s%s%s", label2,
+				    label2[0] ? "/" : "", te2->name) == -1)
+					return got_error_from_errno();
+			}
 			err = diff_entry_new_old(te2, te, l2, diff_context,
 			    repo, outfile);
 			if (err)