commit 3f8b7d6a05bca2370be722ebddb8b2418a30ffd2 from: Stefan Sperling date: Sun Apr 01 18:03:30 2018 UTC document diff command and make the repo path optional commit - 64a96a6df6285a6c0804e1207eac3e6e636e7fa8 commit + 3f8b7d6a05bca2370be722ebddb8b2418a30ffd2 blob - 971ecdd719a3ce535e5b243e716db49bf1ebd27b blob + d36fc503a75e6b75dd91939608912122f22629a9 --- got/got.1 +++ got/got.1 @@ -93,6 +93,12 @@ commits. If the .Ar repository path is omitted, use the current working directory. +.It Cm diff [ Ar repository-path ] Ar object1 Ar object2 +Display the differences between two objects in the repository. +Both objects must be of the same type (blobs, trees, or commits). +If the +.Ar repository path +is omitted, use the current working directory. .El .Sh EXIT STATUS .Ex -std got blob - dfaf97f3a912622429e8a29da96e518bacf65c30 blob + cb7b07e018311bd5ab62a53272627215b79aad96 --- got/got.c +++ got/got.c @@ -496,14 +496,6 @@ cmd_log(int argc, char *argv[]) return error; } -__dead void -usage_diff(void) -{ - fprintf(stderr, "usage: %s diff repository-path object1 object2\n", - getprogname()); - exit(1); -} - static const struct got_error * diff_blobs(struct got_object *obj1, struct got_object *obj2, struct got_repository *repo) @@ -584,6 +576,14 @@ done: got_object_commit_close(commit2); return err; +} + +__dead void +usage_diff(void) +{ + fprintf(stderr, "usage: %s diff [repository-path] object1 object2\n", + getprogname()); + exit(1); } const struct got_error * @@ -615,6 +615,12 @@ cmd_diff(int argc, char *argv[]) if (argc == 0) { usage_diff(); /* TODO show local worktree changes */ + } else if (argc == 2) { + repo_path = getcwd(NULL, 0); + if (repo_path == NULL) + err(1, "getcwd"); + obj_id_str1 = argv[0]; + obj_id_str2 = argv[1]; } else if (argc == 3) { repo_path = argv[0]; obj_id_str1 = argv[1];