show diff if we're diffing to a root commit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index ac0b83d..bb029b7 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1288,7 +1288,7 @@ gw_get_diff(struct gw_trans *gw_trans, struct gw_header *header)
struct buf *diffbuf = NULL;
char *label1 = NULL, *label2 = NULL, *diff_html = NULL, *buf = NULL,
*buf_color = NULL, *n_buf = NULL, *newline = NULL;
- int type1, type2;
+ int obj_type;
size_t newsize;
f = got_opentemp();
@@ -1303,30 +1303,23 @@ gw_get_diff(struct gw_trans *gw_trans, struct gw_header *header)
if (error)
goto done;
- error = got_repo_match_object_id(&id1, &label1, header->parent_id,
- GOT_OBJ_TYPE_ANY, 1, header->repo);
- if (error)
- goto done;
+ if (strncmp(header->parent_id, "/dev/null", 9) != 0) {
+ error = got_repo_match_object_id(&id1, &label1,
+ header->parent_id, GOT_OBJ_TYPE_ANY, 1, header->repo);
+ if (error)
+ goto done;
+ }
error = got_repo_match_object_id(&id2, &label2,
header->commit_id, GOT_OBJ_TYPE_ANY, 1, header->repo);
if (error)
goto done;
- error = got_object_get_type(&type1, header->repo, id1);
- if (error)
- goto done;
-
- error = got_object_get_type(&type2, header->repo, id2);
+ error = got_object_get_type(&obj_type, header->repo, id2);
if (error)
goto done;
- if (type1 != type2) {
- error = got_error(GOT_ERR_OBJ_TYPE);
- goto done;
- }
-
- switch (type1) {
+ switch (obj_type) {
case GOT_OBJ_TYPE_BLOB:
error = got_diff_objects_as_blobs(id1, id2, NULL, NULL, 3, 0,
header->repo, f);