contrib: add pijul-status script

laumann
Sep 27, 2022, 9:59 AM
4DUOW3T334XG5GYSY4HTQJAZ2JCBAYUBHWLKJ7PKQXGVMA2WZFWQC

Dependencies

Change contents

  • file addition: contrib (d--r------)
    [2.1]
  • file addition: pijul-status (---r------)
    [0.19]
    #!/bin/bash
    set -euo pipefail
    # On branch master
    # Your branch is up to date with 'origin/master'.
    #
    # Changes not staged for commit:
    # (use "git add <file>..." to update what will be committed)
    # (use "git restore <file>..." to discard changes in working directory)
    # modified: change.c
    #
    # Untracked files:
    # (use "git add <file>..." to include in what will be committed)
    # .gitignore
    # PIJUL
    # PLAN
    # ani
    # atom.h
    # base32
    # changeid.h
    # dev.log
    # graph.png
    # hunk.h
    # meson.build
    # reccom.sh
    # vertex.h
    #
    # no changes added to commit (use "git add" and/or "git commit -a")
    current_channel() {
    local c=$(pijul channel |grep '^\*')
    printf "On channel %s\n" "${c:2}"
    }
    pijul_status() {
    pijul diff --short --untracked | awk -f <(cat - <<-'EOD'
    BEGIN {
    ci = 0
    ui = 0
    }
    /^M .*/ {
    changes[ci++] = "modified" substr($0, 2)
    }
    /^A .*/ {
    changes[ci++] = "added" substr($0, 2)
    }
    /^D .*/ {
    changes[ci++] = "deleted" substr($0, 2)
    }
    /^U .*/ {
    untracked[ui++] = substr($0, 3)
    }
    END {
    if (ci > 0) {
    printf("\nUnrecorded changes:\n")
    printf(" (use 'pijul record' to record a new patch)\n")
    printf(" (use 'pijul reset' to discard changes)\n")
    for (c in changes) {
    printf(" %s\n", changes[c])
    }
    }
    if (ui > 0) {
    printf("\nUntracked files:\n")
    for (u in untracked) {
    printf(" %s\n", untracked[u])
    }
    }
    }
    EOD
    )
    }
    current_channel
    pijul_status