added several commands

This commit is contained in:
2026-08-11 20:50:08 +02:00
parent 1c7d71ab07
commit c45f666f23
14 changed files with 403 additions and 2781 deletions
+42 -1
View File
@@ -18,6 +18,9 @@ The short form is intended for build scripts and interactive use:
(git 'diff)
(git 'diff '--cached)
(git 'add "main.rkt" "info.rkt")
(git 'restore '--staged "scratch.rkt")
(git 'reset 'HEAD "--" "main.rkt")
(git 'grep '-i '-n "todo")
(git 'commit "Implement raco support")
(git 'tag "v0.1")
(git 'checkout "main")
@@ -40,7 +43,7 @@ Calls @racket[git], displays its result in a compact human-readable form, and re
@defproc[(git-version) string?]{Returns the package version from @tt{info.rkt}. The command form is @racket[(git 'version)]. The version is not duplicated in @tt{main.rkt}; @tt{info.rkt} is the single source of truth.}
@racketblock[
(git 'version) ; => "0.2.11"
(git 'version) ; => "0.2.12"
]
@section{Repository}
@@ -75,6 +78,39 @@ Calls @racket[git], displays its result in a compact human-readable form, and re
(git 'commit "Update all changed files")
]
@defproc[(git-restore [argument any/c] ...) void?]{Restores paths using Git-like command arguments. With only paths, the worktree is restored from the index, as in @tt{git restore path}. With @racket['--staged], matching index entries are restored from HEAD while the worktree is left untouched. @racket['--worktree] can be combined with @racket['--staged], and @racket['--source] selects another revision.}
@racketblock[
(git 'restore "main.rkt")
(git 'restore '--staged "scrbl/racket-makefile.bak")
(git 'restore '--source "HEAD~1" "main.rkt")
]
@defproc[(git-reset [argument any/c] ...) void?]{Resets HEAD, the index, or selected paths using Git-like command arguments. With @racket['--soft], @racket['--mixed], or @racket['--hard], the corresponding whole-repository reset is performed. Path resets use the familiar @tt{--} separator.}
@racketblock[
(git 'reset 'HEAD "--" "main.rkt")
(git 'reset '--mixed 'HEAD)
(git 'reset '--hard 'HEAD)
]
@section{Grep}
@defstruct*[git-grep-entry ([path string?] [line-number exact-positive-integer?] [line string?])]{Describes one line selected by @racket[git-grep]. Results are always structured this way, regardless of display-oriented flags such as @racket['-n], @racket['-l], or @racket['-c].}
@defproc[(git-grep [argument any/c] ...) (listof git-grep-entry?)]{Searches tracked files in the current worktree, or in an optional revision supplied after the pattern. String patterns are regular expressions. @racket['-i] makes matching case-insensitive and @racket['-v] inverts the match. The flags @racket['-n], @racket['-l], and @racket['-c] do not change the structured result; they control how @racket[dgit] displays it. Binary files are skipped.}
@racketblock[
(git 'grep "TODO")
(git 'grep '-i "todo")
(git 'grep '-v "generated")
(git 'grep "old-name" 'HEAD~1)
(dgit 'grep '-n "TODO") ; path:line-number:text
(dgit 'grep '-l "TODO") ; matching file names only
(dgit 'grep '-c "TODO") ; number of matching lines per file
]
@section{Configuration and commits}
@defproc*[([(git-config [key string?]) string?]
@@ -84,6 +120,9 @@ Calls @racket[git], displays its result in a compact human-readable form, and re
@defproc[(git-commit [message string?]) string?]{Creates a commit from the index and returns its full OID. The author and committer are read from the repository configuration.}
@defproc[(git-prompt [message string? #f]) string?]{Returns @racket[message] when supplied. Without an argument, displays @tt{Give (commit) message: }, reads one line from the current input port, and returns it. This is convenient in interactive make targets before staging and committing changes.}
@section{Branches, checkout, and tags}
@defproc[(git-current-branch) (or/c string? #f)]{Returns the current local branch name, or @racket[#f] for detached HEAD. The command form is @racket[(git 'branch-current)].}
@@ -162,6 +201,8 @@ The following command-like forms are supported directly:
(git 'status)
(git 'add "file.rkt")
(git 'add '-A)
(git 'restore '--staged "file.rkt")
(git 'reset 'HEAD "--" "file.rkt")
(git 'config "user.name" "Name")
(git 'commit "message")
(git 'branch-current)