diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2026-04-05 10:00:18 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2026-04-05 10:00:18 +0800 |
| commit | eb93a00ae4faafd7b6b3907546515d471c5cc30a (patch) | |
| tree | 9c578fcb246a071d35f75a9b34c517526fcaf6a8 | |
| parent | 2ca21847adfbc38e83738010f44c854e45e590d5 (diff) | |
| download | cvn-eb93a00ae4faafd7b6b3907546515d471c5cc30a.tar.gz | |
Clean up.
| -rw-r--r-- | vcx | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -70,12 +70,13 @@ sub run_init { } sub run_status { - open my $fh, '<', HEAD or die "VCX not initialized.\n"; + open my $fh, '<', HEAD or die "Not a repository.\n"; my $head = <$fh>; chomp $head; close $fh; print "On revision [$head]\n"; my %staged_diffs; my $staged_diff_bundle = TMP_DIFF; + if (-e TMP_DIFF) { my @list = qx(tar -tf '$staged_diff_bundle'); foreach (@list) { @@ -86,18 +87,21 @@ sub run_status { my ($tree_ptr) = bsd_glob(File::Spec->catfile(REV_DIR, $head, "tree-*")); my ($tree_hash) = $tree_ptr =~ /tree-([a-f0-9]{40})$/; - my $latest_tree_dir = File::Spec->catdir(OBJ_DIR, $tree_hash); + my $latest_tree = File::Spec->catdir(OBJ_DIR, $tree_hash); # Pass 1: Workspace -> History (Detects New and Modified) find({ wanted => sub { - return if $File::Find::name =~ /^\.\/\Q${\VCX_DIR}\E/; + if ($File::Find::name =~ /\/\Q${\VCX_DIR}\E$/ || $_ eq VCX_DIR) { + $File::Find::prune = 1; + return; + } return if -d $File::Find::name; my $rel = File::Spec->abs2rel($File::Find::name, '.'); $rel =~ s|^\./||; - my $base_in_tree = File::Spec->catfile($latest_tree_dir, $rel); + my $base_in_tree = File::Spec->catfile($latest_tree, $rel); my $path_hash = sha1_hex($rel); if (-e $base_in_tree || -l $base_in_tree) { @@ -116,11 +120,11 @@ sub run_status { }, '.'); # Pass 2: History -> Workspace (Detects Deletions) - if (-d $latest_tree_dir) { + if (-d $latest_tree) { find({ wanted => sub { return if -d $_; - my $rel = File::Spec->abs2rel($_, $latest_tree_dir); + my $rel = File::Spec->abs2rel($_, $latest_tree); # If it's in the commit tree but GONE from the workspace if (!-e $rel && !-l $rel) { @@ -130,7 +134,7 @@ sub run_status { } }, no_chdir => 1 - }, $latest_tree_dir); + }, $latest_tree); } } |
