]> Kevux Git Server - rit/commit
has_dir_name(): make code more obvious
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 15 May 2025 13:11:43 +0000 (13:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 May 2025 20:46:46 +0000 (13:46 -0700)
commit655268452cafd061c6c38541a719b6f5b9d528e3
tree06545163b21c41d92e7687aa3a73eb603f3ff98f
parentbf0468e2ba64ac358a61cb01a675b7c5919d64fd
has_dir_name(): make code more obvious

One thing that might be non-obvious to readers (or to analyzers like
CodeQL) is that the function essentially does nothing when the Git index
is empty, and in particular that it does not look at the value of
`len_eq_last` (which would be uninitialized at that point).

Let's make this much easier to understand, by returning early if the Git
index is empty, and by avoiding empty `else` blocks.

This commit changes indentation and is hence best viewed using
`--ignore-space-change`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c