commit 1a1242a9a15f34878343aebfb28a71e0c5d9b904 from: Klemens Nanni date: Thu Apr 01 19:28:57 2021 UTC diff: reduce duplicate code Condense error checking to reduce a future diff moving those lines around; this pattern is already used in other parts of the tree. fine stsp ok tracey commit - ac62b7128d19ff467525fe11e07efdbc47c53bb5 commit + 1a1242a9a15f34878343aebfb28a71e0c5d9b904 blob - 5d1639cc92038e9f33eb3ea515cd83b8469b4fb0 blob + 192b847bcb16c4c5fe215175d5a8109d0712f76b --- got/got.c +++ got/got.c @@ -4381,19 +4381,11 @@ cmd_diff(int argc, char *argv[]) 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; - } + repo_path = strdup(worktree ? + got_worktree_get_repo_path(worktree) : cwd); + if (repo_path == NULL) { + error = got_error_from_errno("strdup"); + goto done; } } } else