Commit Diff


commit - 18f4293943894155d5ccbdb423f1e8a2bb1e1d62
commit + 5415655556f118165e3643dc22d370cb9fef469b
blob - ac5d837761422d5a991095c0be7f0e6d384be0cd
blob + 4f7d23771ac7850de8807514c25be47cc3ceb7fc
--- got/got.c
+++ got/got.c
@@ -304,10 +304,7 @@ print_patch(struct got_commit_object *commit, struct g
 	struct got_tree_object *tree1 = NULL, *tree2;
 	struct got_object_qid *qid;
 	char *id_str1 = NULL, *id_str2;
-	time_t time1 = 0, time2;
 
-	time2 = got_object_commit_get_committer_time(commit);
-
 	err = got_object_open_as_tree(&tree2, repo,
 	    got_object_commit_get_tree_id(commit));
 	if (err)
@@ -321,7 +318,6 @@ print_patch(struct got_commit_object *commit, struct g
 		if (err)
 			return err;
 
-		time1 = got_object_commit_get_committer_time(pcommit);
 		err = got_object_open_as_tree(&tree1, repo,
 		    got_object_commit_get_tree_id(pcommit));
 		got_object_commit_close(pcommit);
@@ -338,8 +334,7 @@ print_patch(struct got_commit_object *commit, struct g
 		goto done;
 
 	printf("diff %s %s\n", id_str1 ? id_str1 : "/dev/null", id_str2);
-	err = got_diff_tree(tree1, tree2, "", "", time1, time2, diff_context,
-	    repo, stdout);
+	err = got_diff_tree(tree1, tree2, "", "", diff_context, repo, stdout);
 done:
 	if (tree1)
 		got_object_tree_close(tree1);
@@ -705,11 +700,11 @@ cmd_diff(int argc, char *argv[])
 	switch (type1) {
 	case GOT_OBJ_TYPE_BLOB:
 		error = got_diff_objects_as_blobs(id1, id2, NULL, NULL,
-		    0, 0, diff_context, repo, stdout);
+		    diff_context, repo, stdout);
 		break;
 	case GOT_OBJ_TYPE_TREE:
 		error = got_diff_objects_as_trees(id1, id2, "", "",
-		    0, 0, diff_context, repo, stdout);
+		    diff_context, repo, stdout);
 		break;
 	case GOT_OBJ_TYPE_COMMIT:
 		printf("diff %s %s\n", id_str1 ? id_str1 : "/dev/null",
blob - e2ad0b8574261d2a1994d2b5bb1bb382d6ecc407
blob + 01e0ac643704c52d2defe4e6e2bffdc0b8b5f8e4
--- include/got_diff.h
+++ include/got_diff.h
@@ -19,48 +19,42 @@
  * to the provided output FILE. Two const char * diff header labels may
  * be provided which will be used to identify each blob in the diff output.
  * If a label is NULL, use the blob's SHA1 checksum instead.
- * Specified timestamps and will be shown in the diff unless they are zero.
  * The number of context lines to show in the diff must be specified as well.
  */
 const struct got_error *got_diff_blob(struct got_blob_object *,
-    struct got_blob_object *, const char *, const char *, time_t, time_t,
-    int, FILE *);
+    struct got_blob_object *, const char *, const char *, int, FILE *);
 
 /*
  * Compute the differences between two trees and write unified diff text
  * to the provided output FILE. Two const char * diff header labels may
  * be provided which will be used to identify each blob in the diff output.
  * If a label is NULL, use the blob's SHA1 checksum instead.
- * Specified timestamps and will be shown in the diff unless they are zero.
  * The number of context lines to show in the diff must be specified as well.
  */
 const struct got_error *got_diff_tree(struct got_tree_object *,
     struct got_tree_object *, const char *label1, const char *label2,
-    time_t, time_t, int, struct got_repository *, FILE *);
+    int, struct got_repository *, FILE *);
 
 /*
  * Diff two objects, assuming both objects are blobs. Two const char * diff
  * header labels may be provided which will be used to identify each blob in
  * the diff output. If a label is NULL, use the blob's SHA1 checksum instead.
- * Specified timestamps and will be shown in the diff unless they are zero.
  * The number of context lines to show in the diff must be specified as well.
  * Write unified diff text to the provided output FILE.
  */
 const struct got_error *got_diff_objects_as_blobs(struct got_object_id *,
-    struct got_object_id *, const char *, const char *, time_t, time_t,
-    int, struct got_repository *, FILE *);
+    struct got_object_id *, const char *, const char *, int,
+    struct got_repository *, FILE *);
 
 /*
  * Diff two objects, assuming both objects are trees. Two const char * diff
  * header labels may be provided which will be used to identify each blob in
  * the trees. If a label is NULL, use the blob's SHA1 checksum instead.
- * Specified timestamps and will be shown in the diff unless they are zero.
  * The number of context lines to show in diffs must be specified.
  * Write unified diff text to the provided output FILE.
  */
 const struct got_error *got_diff_objects_as_trees(struct got_object_id *,
-    struct got_object_id *, char *, char *, time_t, time_t, int,
-    struct got_repository *, FILE *);
+    struct got_object_id *, char *, char *, int, struct got_repository *, FILE *);
 
 /*
  * Diff two objects, assuming both objects are commits.
blob - de31251b908ee9dcad7ab631054200fd0b6cfc0a
blob + c7992b73cb317bc2e0ad0c8d713d036c6276e2db
--- lib/diff.c
+++ lib/diff.c
@@ -36,40 +36,10 @@
 #include "got_lib_inflate.h"
 #include "got_lib_object.h"
 
-static char *
-get_datestr(time_t *time, char *datebuf)
-{
-	char *p, *s = ctime_r(time, datebuf);
-	p = strchr(s, '\n');
-	if (p)
-		*p = '\0';
-	return s;
-}
-
-static char *
-get_label(const char *path, time_t time, const char *fallback)
-{
-	char datebuf[26];
-	char *datestr = NULL;
-	char *label;
-
-	if (path == NULL)
-		return strdup(fallback);
-
-	if (time)
-		datestr = get_datestr(&time, datebuf);
-
-	if (asprintf(&label, "%s%s%s%s", path, datestr ? "\t" : "",
-	    datestr ? datestr : "", datestr ? " UTC" : "") == -1)
-		return NULL;
-
-	return label;
-}
-
 static const struct got_error *
 diff_blobs(struct got_blob_object *blob1, struct got_blob_object *blob2,
-    const char *label1, const char *label2, time_t time1, time_t time2,
-    int diff_context, FILE *outfile, struct got_diff_changes *changes)
+    const char *label1, const char *label2, int diff_context, FILE *outfile,
+    struct got_diff_changes *changes)
 {
 	struct got_diff_state ds;
 	struct got_diff_args args;
@@ -78,12 +48,9 @@ diff_blobs(struct got_blob_object *blob1, struct got_b
 	char hex1[SHA1_DIGEST_STRING_LENGTH];
 	char hex2[SHA1_DIGEST_STRING_LENGTH];
 	char *idstr1 = NULL, *idstr2 = NULL;
-	char *l1 = NULL, *l2 = NULL;
 	size_t size1, size2;
 	int res, flags = 0;
 
-	memset(&args, 0, sizeof(args));
-
 	if (blob1) {
 		f1 = got_opentemp();
 		if (f1 == NULL)
@@ -130,19 +97,10 @@ diff_blobs(struct got_blob_object *blob1, struct got_b
 		ds.stb2.st_size = size2;
 	ds.stb2.st_mtime = 0; /* XXX */
 
+	memset(&args, 0, sizeof(args));
 	args.diff_format = D_UNIFIED;
-	l1 = get_label(label1, time1, idstr1);
-	if (l1 == NULL) {
-		err = got_error_from_errno();
-		goto done;
-	}
-	args.label[0] = l1;
-	l2 = get_label(label2, time2, idstr2);
-	if (l2 == NULL) {
-		err = got_error_from_errno();
-		goto done;
-	}
-	args.label[1] = l2;
+	args.label[0] = label1 ? label1 : idstr1;
+	args.label[1] = label2 ? label2 : idstr2;
 	args.diff_context = diff_context;
 	flags |= D_PROTOTYPE;
 
@@ -150,8 +108,6 @@ diff_blobs(struct got_blob_object *blob1, struct got_b
 	fprintf(outfile, "blob + %s\n", idstr2);
 	err = got_diffreg(&res, f1, f2, flags, &args, &ds, outfile, changes);
 done:
-	free(l1);
-	free(l2);
 	if (f1)
 		fclose(f1);
 	if (f2)
@@ -161,11 +117,10 @@ done:
 
 const struct got_error *
 got_diff_blob(struct got_blob_object *blob1, struct got_blob_object *blob2,
-    const char *label1, const char *label2, time_t time1, time_t time2,
-    int diff_context, FILE *outfile)
+    const char *label1, const char *label2, int diff_context, FILE *outfile)
 {
-	return diff_blobs(blob1, blob2, label1, label2, time1, time2,
-	    diff_context, outfile, NULL);
+	return diff_blobs(blob1, blob2, label1, label2, diff_context, outfile,
+	    NULL);
 }
 
 const struct got_error *
@@ -179,7 +134,7 @@ got_diff_blob_lines_changed(struct got_diff_changes **
 		return got_error_from_errno();
 	SIMPLEQ_INIT(&(*changes)->entries);
 
-	err = diff_blobs(blob1, blob2, NULL, NULL, 0, 0, 3, NULL, *changes);
+	err = diff_blobs(blob1, blob2, NULL, NULL, 3, NULL, *changes);
 	if (err) {
 		got_diff_free_changes(*changes);
 		*changes = NULL;
@@ -214,7 +169,7 @@ match_entry_by_name(struct got_tree_entry *te1, struct
 }
 
 static const struct got_error *
-diff_added_blob(struct got_object_id *id, const char *label, time_t time,
+diff_added_blob(struct got_object_id *id, const char *label,
     int diff_context, struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err;
@@ -228,8 +183,7 @@ diff_added_blob(struct got_object_id *id, const char *
 	err = got_object_blob_open(&blob, repo, obj, 8192);
 	if (err)
 		goto done;
-	err = got_diff_blob(NULL, blob, NULL, label, 0, time, diff_context,
-	    outfile);
+	err = got_diff_blob(NULL, blob, NULL, label, diff_context, outfile);
 done:
 	got_object_close(obj);
 	if (blob)
@@ -239,8 +193,8 @@ done:
 
 static const struct got_error *
 diff_modified_blob(struct got_object_id *id1, struct got_object_id *id2,
-    const char *label1, const char *label2, time_t time1, time_t time2,
-    int diff_context, struct got_repository *repo, FILE *outfile)
+    const char *label1, const char *label2, int diff_context,
+    struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err;
 	struct got_object *obj1 = NULL;
@@ -272,8 +226,8 @@ diff_modified_blob(struct got_object_id *id1, struct g
 	if (err)
 		goto done;
 
-	err = got_diff_blob(blob1, blob2, label1, label2, time1, time2,
-	    diff_context, outfile);
+	err = got_diff_blob(blob1, blob2, label1, label2, diff_context,
+	    outfile);
 
 done:
 	if (obj1)
@@ -289,7 +243,7 @@ done:
 
 static const struct got_error *
 diff_deleted_blob(struct got_object_id *id, const char *label,
-    time_t time, int diff_context, struct got_repository *repo, FILE *outfile)
+    int diff_context, struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err;
 	struct got_blob_object  *blob = NULL;
@@ -302,8 +256,7 @@ diff_deleted_blob(struct got_object_id *id, const char
 	err = got_object_blob_open(&blob, repo, obj, 8192);
 	if (err)
 		goto done;
-	err = got_diff_blob(blob, NULL, label, NULL, time, 0, diff_context,
-	    outfile);
+	err = got_diff_blob(blob, NULL, label, NULL, diff_context, outfile);
 done:
 	got_object_close(obj);
 	if (blob)
@@ -312,7 +265,7 @@ done:
 }
 
 static const struct got_error *
-diff_added_tree(struct got_object_id *id, const char *label, time_t time,
+diff_added_tree(struct got_object_id *id, const char *label,
     int diff_context, struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err = NULL;
@@ -332,8 +285,8 @@ diff_added_tree(struct got_object_id *id, const char *
 	if (err)
 		goto done;
 
-	err = got_diff_tree(NULL, tree, NULL, label, 0, time,
-	    diff_context, repo, outfile);
+	err = got_diff_tree(NULL, tree, NULL, label, diff_context, repo,
+	    outfile);
 
 done:
 	if (tree)
@@ -345,8 +298,8 @@ done:
 
 static const struct got_error *
 diff_modified_tree(struct got_object_id *id1, struct got_object_id *id2,
-    const char *label1, const char *label2, time_t time1, time_t time2,
-    int diff_context, struct got_repository *repo, FILE *outfile)
+    const char *label1, const char *label2, int diff_context,
+    struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err;
 	struct got_object *treeobj1 = NULL;
@@ -380,8 +333,8 @@ diff_modified_tree(struct got_object_id *id1, struct g
 	if (err)
 		goto done;
 
-	err = got_diff_tree(tree1, tree2, label1, label2, time1, time2,
-	    diff_context, repo, outfile);
+	err = got_diff_tree(tree1, tree2, label1, label2, diff_context, repo,
+	    outfile);
 
 done:
 	if (tree1)
@@ -396,7 +349,7 @@ done:
 }
 
 static const struct got_error *
-diff_deleted_tree(struct got_object_id *id, const char *label, time_t time,
+diff_deleted_tree(struct got_object_id *id, const char *label,
     int diff_context, struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err;
@@ -416,8 +369,8 @@ diff_deleted_tree(struct got_object_id *id, const char
 	if (err)
 		goto done;
 
-	err = got_diff_tree(tree, NULL, label, NULL, time, 0, diff_context,
-	    repo, outfile);
+	err = got_diff_tree(tree, NULL, label, NULL, diff_context, repo,
+	    outfile);
 done:
 	if (tree)
 		got_object_tree_close(tree);
@@ -436,19 +389,19 @@ diff_kind_mismatch(struct got_object_id *id1, struct g
 
 static const struct got_error *
 diff_entry_old_new(struct got_tree_entry *te1, struct got_tree_entry *te2,
-    const char *label1, const char *label2, time_t time1, time_t time2,
-    int diff_context, struct got_repository *repo, FILE *outfile)
+    const char *label1, const char *label2, int diff_context,
+    struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err = NULL;
 	int id_match;
 
 	if (te2 == NULL) {
 		if (S_ISDIR(te1->mode))
-			err = diff_deleted_tree(te1->id, label1, time1,
-			    diff_context, repo, outfile);
+			err = diff_deleted_tree(te1->id, label1, diff_context,
+			    repo, outfile);
 		else
-			err = diff_deleted_blob(te1->id, label1, time1,
-			    diff_context, repo, outfile);
+			err = diff_deleted_blob(te1->id, label1, diff_context,
+			    repo, outfile);
 		return err;
 	}
 
@@ -456,13 +409,11 @@ diff_entry_old_new(struct got_tree_entry *te1, struct 
 	if (S_ISDIR(te1->mode) && S_ISDIR(te2->mode)) {
 		if (!id_match)
 			return diff_modified_tree(te1->id, te2->id,
-			    label1, label2, time1, time2, diff_context,
-			    repo, outfile);
+			    label1, label2, diff_context, repo, outfile);
 	} else if (S_ISREG(te1->mode) && S_ISREG(te2->mode)) {
 		if (!id_match)
 			return diff_modified_blob(te1->id, te2->id,
-			    label1, label2, time1, time2, diff_context,
-			    repo, outfile);
+			    label1, label2, diff_context, repo, outfile);
 	}
 
 	if (id_match)
@@ -473,24 +424,23 @@ diff_entry_old_new(struct got_tree_entry *te1, struct 
 
 static const struct got_error *
 diff_entry_new_old(struct got_tree_entry *te2, struct got_tree_entry *te1,
-    const char *label2, time_t time2, int diff_context,
-    struct got_repository *repo, FILE *outfile)
+    const char *label2, int diff_context, struct got_repository *repo,
+    FILE *outfile)
 {
 	if (te1 != NULL) /* handled by diff_entry_old_new() */
 		return NULL;
 
 	if (S_ISDIR(te2->mode))
-		return diff_added_tree(te2->id, label2, time2, diff_context,
-		    repo, outfile);
+		return diff_added_tree(te2->id, label2, diff_context, repo,
+		    outfile);
 
-	return diff_added_blob(te2->id, label2, time2, diff_context, repo,
-	    outfile);
+	return diff_added_blob(te2->id, label2, diff_context, repo, outfile);
 }
 
 const struct got_error *
 got_diff_tree(struct got_tree_object *tree1, struct got_tree_object *tree2,
-    const char *label1, const char *label2, time_t time1, time_t time2,
-    int diff_context, struct got_repository *repo, FILE *outfile)
+    const char *label1, const char *label2, int diff_context,
+    struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err = NULL;
 	struct got_tree_entry *te1 = NULL;
@@ -526,8 +476,8 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 				    label2[0] ? "/" : "", te->name) == -1)
 					return got_error_from_errno();
 			}
-			err = diff_entry_old_new(te1, te, l1, l2, time1, time2,
-			    diff_context, repo, outfile);
+			err = diff_entry_old_new(te1, te, l1, l2, diff_context,
+			    repo, outfile);
 			if (err)
 				break;
 		}
@@ -546,8 +496,8 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 				    label2[0] ? "/" : "", te2->name) == -1)
 					return got_error_from_errno();
 			}
-			err = diff_entry_new_old(te2, te, l2, time2,
-			    diff_context, repo, outfile);
+			err = diff_entry_new_old(te2, te, l2, diff_context,
+			    repo, outfile);
 			if (err)
 				break;
 		}
@@ -577,8 +527,8 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 
 const struct got_error *
 got_diff_objects_as_blobs(struct got_object_id *id1, struct got_object_id *id2,
-    const char *label1, const char *label2, time_t time1, time_t time2,
-    int diff_context, struct got_repository *repo, FILE *outfile)
+    const char *label1, const char *label2, int diff_context,
+    struct got_repository *repo, FILE *outfile)
 {
 	const struct got_error *err;
 	struct got_blob_object *blob1 = NULL, *blob2 = NULL;
@@ -596,8 +546,8 @@ got_diff_objects_as_blobs(struct got_object_id *id1, s
 		if (err)
 			goto done;
 	}
-	err = got_diff_blob(blob1, blob2, label1, label2, time1, time2,
-	    diff_context, outfile);
+	err = got_diff_blob(blob1, blob2, label1, label2, diff_context,
+	    outfile);
 done:
 	if (blob1)
 		got_object_blob_close(blob1);
@@ -608,8 +558,8 @@ done:
 
 const struct got_error *
 got_diff_objects_as_trees(struct got_object_id *id1, struct got_object_id *id2,
-    char *label1, char *label2, time_t time1, time_t time2,
-    int diff_context, struct got_repository *repo, FILE *outfile)
+    char *label1, char *label2, int diff_context, struct got_repository *repo,
+    FILE *outfile)
 {
 	const struct got_error *err;
 	struct got_tree_object *tree1 = NULL, *tree2 = NULL;
@@ -627,8 +577,8 @@ got_diff_objects_as_trees(struct got_object_id *id1, s
 		if (err)
 			goto done;
 	}
-	err = got_diff_tree(tree1, tree2, label1, label2, time1, time2,
-	    diff_context, repo, outfile);
+	err = got_diff_tree(tree1, tree2, label1, label2, diff_context,
+	   repo, outfile);
 done:
 	if (tree1)
 		got_object_tree_close(tree1);
@@ -660,11 +610,8 @@ got_diff_objects_as_commits(struct got_object_id *id1,
 
 	err = got_diff_objects_as_trees(
 	    commit1 ? got_object_commit_get_tree_id(commit1) : NULL,
-	    got_object_commit_get_tree_id(commit2), "", "",
-	    commit1 ? got_object_commit_get_committer_time(commit1) : 0,
-	    got_object_commit_get_committer_time(commit2),
-	    diff_context,
-	    repo, outfile);
+	    got_object_commit_get_tree_id(commit2), "", "", diff_context, repo,
+	    outfile);
 done:
 	if (commit1)
 		got_object_commit_close(commit1);
blob - b04f1979bb2f42847f9308fdd2a6a92de6af4a1e
blob + b06a8e52157c5f52dce914f374c258995ac0dcb8
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
@@ -321,7 +321,7 @@ repo_diff_blob(const char *repo_path)
 	outfile = got_opentemp();
 	if (outfile == NULL)
 		return 0;
-	got_diff_blob(blob1, blob2, NULL, NULL, 0, 0, 3, outfile);
+	got_diff_blob(blob1, blob2, NULL, NULL, 3, outfile);
 	rewind(outfile);
 	i = 0;
 	while ((line = fparseln(outfile, &len, NULL, delim, 0)) != NULL) {
@@ -388,7 +388,7 @@ repo_diff_tree(const char *repo_path)
 	} else
 		outfile = stdout;
 	test_printf("\n");
-	got_diff_tree(tree1, tree2, "", "", 0, 0, 3, repo, outfile);
+	got_diff_tree(tree1, tree2, "", "", 3, repo, outfile);
 	test_printf("\n");
 
 	got_object_tree_close(tree1);
blob - beb39332ea4ed819e99f2d96fcffe37fce09c987
blob + e6c12b6914a3e45988975730c905d96a0b10cd33
--- tog/tog.c
+++ tog/tog.c
@@ -1879,10 +1879,10 @@ create_diff(struct tog_diff_view_state *s)
 	switch (obj_type) {
 	case GOT_OBJ_TYPE_BLOB:
 		err = got_diff_objects_as_blobs(s->id1, s->id2, NULL, NULL,
-		    0, 0, s->diff_context, s->repo, f);
+		    s->diff_context, s->repo, f);
 		break;
 	case GOT_OBJ_TYPE_TREE:
-		err = got_diff_objects_as_trees(s->id1, s->id2, "", "", 0, 0,
+		err = got_diff_objects_as_trees(s->id1, s->id2, "", "",
 		    s->diff_context, s->repo, f);
 		break;
 	case GOT_OBJ_TYPE_COMMIT: {