commit - 4ba1413314ad741dd3eec3b6672b127f2e03428e
commit + 1f03b8da6be221784414918f66390ccb0eb67908
blob - 4ba89fc33d869f104e24016016d6818deca6517d
blob + d0e6d7f2e6b486b9103d7efb0dd24322773ab138
--- got/got.c
+++ got/got.c
error = got_error_from_errno("getcwd");
goto done;
}
- error = got_worktree_open(&worktree, cwd);
- if (error && error->code != GOT_ERR_NOT_WORKTREE)
- goto done;
if (argc <= 1) {
- if (worktree == NULL) {
- error = got_error(GOT_ERR_NOT_WORKTREE);
- goto done;
- }
if (repo_path)
errx(1,
"-r option can't be used when diffing a work tree");
+ error = got_worktree_open(&worktree, cwd);
+ if (error)
+ goto done;
repo_path = strdup(got_worktree_get_repo_path(worktree));
if (repo_path == NULL) {
error = got_error_from_errno("strdup");
"objects in repository");
id_str1 = argv[0];
id_str2 = argv[1];
- if (worktree && repo_path == NULL) {
- repo_path =
- strdup(got_worktree_get_repo_path(worktree));
- if (repo_path == NULL) {
- error = got_error_from_errno("strdup");
+ if (repo_path == NULL) {
+ error = got_worktree_open(&worktree, cwd);
+ if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
+ if (worktree) {
+ repo_path = strdup(
+ got_worktree_get_repo_path(worktree));
+ if (repo_path == NULL) {
+ error = got_error_from_errno("strdup");
+ goto done;
+ }
+ } else {
+ repo_path = strdup(cwd);
+ if (repo_path == NULL) {
+ error = got_error_from_errno("strdup");
+ goto done;
+ }
}
}
} else
usage_diff();
-
- if (repo_path == NULL) {
- repo_path = getcwd(NULL, 0);
- if (repo_path == NULL)
- return got_error_from_errno("getcwd");
- }
error = got_repo_open(&repo, repo_path, NULL);
free(repo_path);
if (worktree) {
repo_path =
strdup(got_worktree_get_repo_path(worktree));
- if (repo_path == NULL)
+ if (repo_path == NULL) {
error = got_error_from_errno("strdup");
- if (error)
- goto done;
+ if (error)
+ goto done;
+ }
} else {
repo_path = strdup(cwd);
if (repo_path == NULL) {