git-wad

Manage files via git but not their content
git clone git://git.meso-star.fr/git-wad.git
Log | Files | Refs | README | LICENSE

commit 527ab995e78d293eeb381b8a266432d9b25d5091
parent a9dbcb373c61451ff85af5672bf4621f9cf461e8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sun, 12 Jan 2025 15:19:22 +0100

Fix issues in "git-wad status"

Reports git-wad initialization status before checking if a commit
exists. This gives the caller the information that git-wad can be used,
or not, on the files he wants, regardless of whether a commit exists or
not. This last constraint remains necessary, but only to list the files
managed by git-wad, which do not exist in the absence of a commit.

Corrects as the number of WADs not referenced is evaluated.

Diffstat:
Mgit-wad | 23++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/git-wad b/git-wad @@ -476,9 +476,17 @@ prune() # [-1a] # Print WAD management status status() # [-1a] { - # First, we need to check that a commit exists, otherwise there's no - # active HEAD and therefore no status to report. In fact, the function - # would return an error if it queried the HEAD object. + # First, report the static of git wad initialization. + # shellcheck disable=SC2310 + if ! is_init; then + printf "\e[0;31mgit-wad is not initialized\e[0m\n" + printf " (use \"git wad init\" to enable WAD management)\n" + printf "\n" + fi + + # Check that a commit exists, otherwise there's no active HEAD and + # therefore no more status to report. In fact, the function would + # return an error if it queried the HEAD object. if ! git rev-parse HEAD > /dev/null 2>&1; then >&2 printf "No commits yet\n" return @@ -516,13 +524,6 @@ status() # [-1a] fi done - # shellcheck disable=SC2310 - if ! is_init; then - printf "\e[0;31mgit-wad is not initialized\e[0m\n" - printf " (use \"git wad init\" to enable WAD management)\n" - printf "\n" - fi - # List resolved WADs, if any if [ -s "${resolved}" ]; then printf "Resolved WADs:\n" @@ -549,7 +550,7 @@ status() # [-1a] # Print number of WADs not referenced in current work tree unreferenced="${git_wad_tmpdir}/unreferenced" unreferenced_objects "$@" > "${unreferenced}" - n="$(wc -l < "${unreferenced}")" + n="$(wc -l < "${unreferenced}" | cut -d' ' -f1)" if [ "${n}" -gt 0 ]; then printf "There are %d WADs not use in the current working tree\n" "${n}" printf " (use \"git wad prune\" to remove them)\n"