Commit Diff


commit - 67409a31c95a35d375588f38a9dc11d5add7a918
commit + e02e74afec955012935260a66e7710c537092c95
blob - f18db31b991c8c0ff10fc8f0d7545aa15e6ce2d2
blob + 400c8b4665c0401ac0780eac38c93acbd16e73fa
--- got/got.1
+++ got/got.1
@@ -202,9 +202,9 @@ If a
 .Ar path
 is specified, only show changes within this path.
 .Pp
-If two arguments are provided, treat each argument as a SHA1 hash which
-corresponds to an object in the repository, and display differences
-between these objects.
+If two arguments are provided, treat each argument as a reference,
+or a SHA1 hash, which corresponds to an object in the repository,
+and display differences between these objects.
 Both objects must be of the same type (blobs, trees, or commits).
 .Pp
 The options for
blob - 16eef0039dc6d2261b9556a71753ea90319564b7
blob + 98337ea5b20ae8e72e86440f5fd182320d90980d
--- got/got.c
+++ got/got.c
@@ -1360,12 +1360,32 @@ cmd_diff(int argc, char *argv[])
 	}
 
 	error = got_object_resolve_id_str(&id1, repo, id_str1);
-	if (error)
-		goto done;
+	if (error) {
+		struct got_reference *ref;
+		if (error->code != GOT_ERR_BAD_OBJ_ID_STR)
+			goto done;
+		error = got_ref_open(&ref, repo, id_str1, 0);
+		if (error != NULL)
+			goto done;
+		error = got_ref_resolve(&id1, repo, ref);
+		got_ref_close(ref);
+		if (error != NULL)
+			goto done;
+	}
 
 	error = got_object_resolve_id_str(&id2, repo, id_str2);
-	if (error)
-		goto done;
+	if (error) {
+		struct got_reference *ref;
+		if (error->code != GOT_ERR_BAD_OBJ_ID_STR)
+			goto done;
+		error = got_ref_open(&ref, repo, id_str2, 0);
+		if (error != NULL)
+			goto done;
+		error = got_ref_resolve(&id2, repo, ref);
+		got_ref_close(ref);
+		if (error != NULL)
+			goto done;
+	}
 
 	error = got_object_get_type(&type1, repo, id1);
 	if (error)