From 5d19dc06cf3760d0300c90959bb4e392eb02dcbe Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sun, 19 Apr 2026 11:16:54 +0800 Subject: Fix undefined paths in status command. --- urn | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/urn b/urn index c9d8e14..7e6a07c 100644 --- a/urn +++ b/urn @@ -91,16 +91,21 @@ sub run_status { # Iterate while any of the three sources have entries while ($idx || $wrk || $old) { + # Extract paths safely to avoid "uninitialized" errors on undef iterators + my $p_idx = $idx ? $idx->{path} : undef; + my $p_wrk = $wrk ? $wrk->{path} : undef; + my $p_old = $old ? $old->{path} : undef; + # Find the alphabetically "lowest" path among the three streams - my $path = (sort grep { defined } ($idx->{path}, $wrk->{path}, $old->{path}))[0]; + my $path = (sort grep { defined } ($p_idx, $p_wrk, $p_old))[0]; my $flag = ""; my $suffix = ""; - # Logical check for Deletions (In Old Tree, but missing elsewhere) - my $in_old = (defined $old && $old->{path} eq $path); - my $in_idx = (defined $idx && $idx->{path} eq $path); - my $in_wrk = (defined $wrk && $wrk->{path} eq $path); + # Logical check using extracted path strings + my $in_old = (defined $p_old && $p_old eq $path); + my $in_idx = (defined $p_idx && $p_idx eq $path); + my $in_wrk = (defined $p_wrk && $p_wrk eq $path); if ($in_old && !$in_idx) { # File existed in last commit but is gone from index -> Staged for Deletion -- cgit v1.2.3