From aff14724af363e95293493492ddf56c9aa5f9f76 Mon Sep 17 00:00:00 2001 From: rsteube Date: Sat, 17 Aug 2024 13:16:41 +0200 Subject: [PATCH] git: update-index --- completers/git_completer/cmd/updateIndex.go | 69 +++++++++++++++++++ .../cmd/update_index_generated.go | 52 -------------- 2 files changed, 69 insertions(+), 52 deletions(-) create mode 100644 completers/git_completer/cmd/updateIndex.go delete mode 100644 completers/git_completer/cmd/update_index_generated.go diff --git a/completers/git_completer/cmd/updateIndex.go b/completers/git_completer/cmd/updateIndex.go new file mode 100644 index 0000000000..3b8458aa7b --- /dev/null +++ b/completers/git_completer/cmd/updateIndex.go @@ -0,0 +1,69 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var updateIndexCmd = &cobra.Command{ + Use: "update-index", + Short: "Register file contents in the working tree to the index", + Run: func(cmd *cobra.Command, args []string) {}, + GroupID: groups[group_low_level_manipulator].ID, +} + +func init() { + carapace.Gen(updateIndexCmd).Standalone() + + updateIndexCmd.Flags().Bool("add", false, "if a specified file isn’t in the index already then it’s added") + updateIndexCmd.Flags().BoolP("again", "g", false, "runs git update-index itself on the paths whose index entries differ from HEAD") + updateIndexCmd.Flags().Bool("assume-unchanged", false, "set the \"assume unchanged\" bit for paths") + updateIndexCmd.Flags().String("cacheinfo", "", "directly insert the specified info into the index") + updateIndexCmd.Flags().String("chmod", "", "set the execute permissions on the updated files") + updateIndexCmd.Flags().Bool("force-remove", false, "remove the file from the index even when the working directory still has such a file") + updateIndexCmd.Flags().Bool("force-untracked-cache", false, "same as --untracked-cache") + updateIndexCmd.Flags().Bool("fsmonitor", false, "enable files system monitor feature") + updateIndexCmd.Flags().Bool("fsmonitor-valid", false, "set the \"fsmonitor valid\" bit for paths") + updateIndexCmd.Flags().Bool("ignore-missing", false, "ignores missing files during a --refresh") + updateIndexCmd.Flags().Bool("ignore-skip-worktree-entries", false, "do not remove skip-worktree (AKA \"index-only\") entries") + updateIndexCmd.Flags().Bool("ignore-submodules", false, "do not try to update submodules") + updateIndexCmd.Flags().Bool("index-info", false, "read index information from stdin") + updateIndexCmd.Flags().String("index-version", "", "write the resulting index out in the named on-disk format version") + updateIndexCmd.Flags().Bool("info-only", false, "just insert object IDs into the index for following files") + updateIndexCmd.Flags().Bool("no-assume-unchanged", false, "unset the \"assume unchanged\" bit for paths") + updateIndexCmd.Flags().Bool("no-fsmonitor", false, "disable files system monitor feature") + updateIndexCmd.Flags().Bool("no-fsmonitor-valid", false, "unset the \"fsmonitor valid\" bit for paths") + updateIndexCmd.Flags().Bool("no-ignore-skip-worktree-entries", false, "remove skip-worktree (AKA \"index-only\") entries") + updateIndexCmd.Flags().Bool("no-skip-worktree", false, "unset the \"skip-worktree\" bit for paths") + updateIndexCmd.Flags().Bool("no-split-index", false, "disable split index mode") + updateIndexCmd.Flags().Bool("no-untracked-cache", false, "disable untracked cache feature") + updateIndexCmd.Flags().BoolS("q", "q", false, "quiet") + updateIndexCmd.Flags().Bool("really-refresh", false, "like --refresh, but checks stat information unconditionally") + updateIndexCmd.Flags().Bool("refresh", false, "looks at the current index and checks to see if merges or updates are needed") + updateIndexCmd.Flags().Bool("remove", false, "if a specified file is in the index but is missing then it’s removed") + updateIndexCmd.Flags().Bool("replace", false, "existing entries that conflict with the entry being added are automatically removed") + updateIndexCmd.Flags().Bool("show-index-version", false, "report the index format version used by the on-disk index file") + updateIndexCmd.Flags().Bool("skip-worktree", false, "set the \"skip-worktree\" bit for paths") + updateIndexCmd.Flags().Bool("split-index", false, "enable split index mode") + updateIndexCmd.Flags().Bool("stdin", false, "read a list of paths from the standard input") + updateIndexCmd.Flags().Bool("test-untracked-cache", false, "only perform tests on the working directory to make sure untracked cache can be used") + updateIndexCmd.Flags().Bool("unmerged", false, "continue if --refresh finds unmerged changes in the index") + updateIndexCmd.Flags().Bool("unresolve", false, "restores the unmerged or needs updating state of a file during a merge") + updateIndexCmd.Flags().Bool("untracked-cache", false, "enable untracked cache feature") + updateIndexCmd.Flags().Bool("verbose", false, "report what is being added and removed from the index") + updateIndexCmd.Flags().BoolS("z", "z", false, "paths are separated with NUL character instead of LF") + rootCmd.AddCommand(updateIndexCmd) + + carapace.Gen(updateIndexCmd).FlagCompletion(carapace.ActionMap{ + "chmod": carapace.ActionValues("+x", "-x"), + "index-version": carapace.ActionValues("2", "3", "4"), + }) + + carapace.Gen(updateIndexCmd).PositionalAnyCompletion( + carapace.ActionFiles(), + ) + + carapace.Gen(updateIndexCmd).DashAnyCompletion( + carapace.ActionPositional(updateIndexCmd), + ) +} diff --git a/completers/git_completer/cmd/update_index_generated.go b/completers/git_completer/cmd/update_index_generated.go deleted file mode 100644 index 9cb5663853..0000000000 --- a/completers/git_completer/cmd/update_index_generated.go +++ /dev/null @@ -1,52 +0,0 @@ -package cmd - -import ( - "github.com/carapace-sh/carapace" - "github.com/spf13/cobra" -) - -var update_indexCmd = &cobra.Command{ - Use: "update-index", - Short: "Register file contents in the working tree to the index", - Run: func(cmd *cobra.Command, args []string) {}, - GroupID: groups[group_low_level_manipulator].ID, -} - -func init() { - carapace.Gen(update_indexCmd).Standalone() - update_indexCmd.Flags().Bool("add", false, "do not ignore new files") - update_indexCmd.Flags().BoolP("again", "g", false, "only update entries that differ from HEAD") - update_indexCmd.Flags().Bool("assume-unchanged", false, "mark files as \"not changing\"") - update_indexCmd.Flags().String("cacheinfo", "", "add the specified entry to the index") - update_indexCmd.Flags().String("chmod", "", "override the executable bit of the listed files") - update_indexCmd.Flags().Bool("clear-resolve-undo", false, "(for porcelains) forget saved unresolved conflicts") - update_indexCmd.Flags().Bool("force-remove", false, "remove named paths even if present in worktree") - update_indexCmd.Flags().Bool("force-untracked-cache", false, "enable untracked cache without testing the filesystem") - update_indexCmd.Flags().Bool("force-write-index", false, "write out the index even if is not flagged as changed") - update_indexCmd.Flags().Bool("fsmonitor", false, "enable or disable file system monitor") - update_indexCmd.Flags().Bool("fsmonitor-valid", false, "mark files as fsmonitor valid") - update_indexCmd.Flags().Bool("ignore-missing", false, "ignore files missing from worktree") - update_indexCmd.Flags().Bool("ignore-skip-worktree-entries", false, "do not touch index-only entries") - update_indexCmd.Flags().Bool("ignore-submodules", false, "refresh: ignore submodules") - update_indexCmd.Flags().Bool("index-info", false, "add entries from standard input to the index") - update_indexCmd.Flags().String("index-version", "", "write index in this format") - update_indexCmd.Flags().Bool("info-only", false, "add to index only; do not add content to object database") - update_indexCmd.Flags().Bool("no-assume-unchanged", false, "clear assumed-unchanged bit") - update_indexCmd.Flags().Bool("no-fsmonitor-valid", false, "clear fsmonitor valid bit") - update_indexCmd.Flags().Bool("no-skip-worktree", false, "clear skip-worktree bit") - update_indexCmd.Flags().BoolS("q", "q", false, "continue refresh even when index needs update") - update_indexCmd.Flags().Bool("really-refresh", false, "like --refresh, but ignore assume-unchanged setting") - update_indexCmd.Flags().Bool("refresh", false, "refresh stat information") - update_indexCmd.Flags().Bool("remove", false, "notice files missing from worktree") - update_indexCmd.Flags().Bool("replace", false, "let files replace directories and vice-versa") - update_indexCmd.Flags().Bool("skip-worktree", false, "mark files as \"index-only\"") - update_indexCmd.Flags().Bool("split-index", false, "enable or disable split index") - update_indexCmd.Flags().Bool("stdin", false, "read list of paths to be updated from standard input") - update_indexCmd.Flags().Bool("test-untracked-cache", false, "test if the filesystem supports untracked cache") - update_indexCmd.Flags().Bool("unmerged", false, "refresh even if index contains unmerged entries") - update_indexCmd.Flags().Bool("unresolve", false, "repopulate stages #2 and #3 for the listed paths") - update_indexCmd.Flags().Bool("untracked-cache", false, "enable/disable untracked cache") - update_indexCmd.Flags().Bool("verbose", false, "report actions to standard output") - update_indexCmd.Flags().BoolS("z", "z", false, "with --stdin: input lines are terminated by null bytes") - rootCmd.AddCommand(update_indexCmd) -}