summaryrefslogtreecommitdiff
path: root/t/t4101/diff.2-0
diff options
context:
space:
mode:
authorLibravatar Eric Sunshine <sunshine@sunshineco.com>2020-06-24 15:05:41 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-06-24 17:39:28 -0700
commit5f4ee57ad9513f96db8d936816f5ce916b4eddcd (patch)
treee40486e62a04adeb1028f0f5b1b593729aed5297 /t/t4101/diff.2-0
parentGit 2.26.2 (diff)
downloadtgif-5f4ee57ad9513f96db8d936816f5ce916b4eddcd.tar.xz
worktree: avoid dead-code in conditional
get_worktrees() retrieves a list of all worktrees associated with a repository, including the main worktree. The location of the main worktree is determined by get_main_worktree() which needs to handle three distinct cases for the main worktree after absolute-path conversion: * <bare-repository>/. * <main-worktree>/.git/. (when $CWD is .git) * <main-worktree>/.git (when $CWD is any worktree) They all need to be normalized to just the <path> portion, dropping any "/." or "/.git" suffix. It turns out, however, that get_main_worktree() was only handling the first and last cases, i.e.: if (!strip_suffix(path, "/.git")) strip_suffix(path, "/."); This shortcoming was addressed by 45f274fbb1 (get_main_worktree(): allow it to be called in the Git directory, 2020-02-23) by changing the logic to: strip_suffix(path, "/."); if (!strip_suffix(path, "/.git")) strip_suffix(path, "/."); which makes the final strip_suffix() invocation dead-code. Fix this oversight by enumerating the three distinct cases explicitly rather than attempting to strip the suffix(es) incrementally. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4101/diff.2-0')
0 files changed, 0 insertions, 0 deletions