diff --git a/.gitignore b/.gitignore index 24635cf2d6f4a3..8afefb6e6ac5db 100644 --- a/.gitignore +++ b/.gitignore @@ -126,6 +126,7 @@ /git-prune-packed /git-pull /git-push +/git-psuh /git-quiltimport /git-range-diff /git-read-tree diff --git a/Documentation/git-psuh.adoc b/Documentation/git-psuh.adoc new file mode 100644 index 00000000000000..0df2e5bbd619e2 --- /dev/null +++ b/Documentation/git-psuh.adoc @@ -0,0 +1,27 @@ +git-psuh(1) +=========== + +NAME +---- +git-psuh - Delight users' typo with a shy horse + + +SYNOPSIS +-------- +[verse] +'git psuh [...]' + +DESCRIPTION +----------- +this program is cool + +OPTIONS[[OPTIONS]] +------------------ +-n:: +--dry-run:: + Don't actually remove any objects, only show those that would have been + removed. + +GIT +--- +Part of the linkgit:git[1] suite diff --git a/Documentation/meson.build b/Documentation/meson.build index d6365b888bbed3..2b8e567c739005 100644 --- a/Documentation/meson.build +++ b/Documentation/meson.build @@ -103,6 +103,7 @@ manpages = { 'git-patch-id.adoc' : 1, 'git-prune-packed.adoc' : 1, 'git-prune.adoc' : 1, + 'git-psuh.adoc' : 1, 'git-pull.adoc' : 1, 'git-push.adoc' : 1, 'git-quiltimport.adoc' : 1, diff --git a/Makefile b/Makefile index dbf00220541ce1..3c5f39984e1142 100644 --- a/Makefile +++ b/Makefile @@ -1459,6 +1459,7 @@ BUILTIN_OBJS += builtin/patch-id.o BUILTIN_OBJS += builtin/prune-packed.o BUILTIN_OBJS += builtin/prune.o BUILTIN_OBJS += builtin/pull.o +BUILTIN_OBJS += builtin/psuh.o BUILTIN_OBJS += builtin/push.o BUILTIN_OBJS += builtin/range-diff.o BUILTIN_OBJS += builtin/read-tree.o diff --git a/builtin.h b/builtin.h index 235c51f30e5380..eb658ea8d75618 100644 --- a/builtin.h +++ b/builtin.h @@ -282,5 +282,6 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix, struct repo int cmd_show_ref(int argc, const char **argv, const char *prefix, struct repository *repo); int cmd_pack_refs(int argc, const char **argv, const char *prefix, struct repository *repo); int cmd_replace(int argc, const char **argv, const char *prefix, struct repository *repo); +int cmd_psuh(int argc, const char **argv, const char *prefix, struct repository *repo); #endif diff --git a/builtin/psuh.c b/builtin/psuh.c new file mode 100644 index 00000000000000..df5d073e8cd9ec --- /dev/null +++ b/builtin/psuh.c @@ -0,0 +1,62 @@ +#include "builtin.h" +#include "gettext.h" +#include "config.h" +#include "repository.h" +#include "environment.h" +#include "wt-status.h" +#include "commit.h" +#include "pretty.h" +#include "strbuf.h" +#include "parse-options.h" + +static const char * const psuh_usage[] = { + N_("git psuh [...]"), + NULL, +}; + +int cmd_psuh(int argc, const char **argv, + const char *prefix, struct repository *repo) { + int i; + const char *config_name; + struct wt_status status; + struct commit *c = NULL; + struct strbuf commitline = STRBUF_INIT; + struct option options[] = { + OPT_END() + }; + argc = parse_options(argc, argv, prefix, options, psuh_usage, 0); + printf(_("Pony saying hello goes here.\n")); + + + wt_status_prepare(repo, &status); + repo_config(repo, git_default_config, &status); + + printf(Q_("Your args (there is %d):\n", + "Your args (there are %d):\n", + argc), + argc); + for (i = 0; i < argc; i++) + printf("%d: %s\n", i, argv[i]); + + printf(_("Your current working directory:\n%s%s\n"), + prefix ? "/" : "", prefix ? prefix : ""); + + repo_config(repo, git_default_config, NULL); + + if (repo_config_get_string_tmp(repo, "user.name", &config_name)) + printf(_("No name is found in config\n")); + else + printf(_("Your name: %s\n"), config_name); + + printf(_("Your current branch: %s\n"), status.branch); + + c = lookup_commit_reference_by_name("refs/heads/psuh"); + + if (c) { + pp_commit_easy(CMIT_FMT_ONELINE, c, &commitline); + printf(_("Current commit: %s\n"), commitline.buf); + } + + + return 0; +} diff --git a/command-list.txt b/command-list.txt index f9005cf45979f1..e7a94eca8041d3 100644 --- a/command-list.txt +++ b/command-list.txt @@ -153,6 +153,7 @@ git-pack-refs ancillarymanipulators git-patch-id purehelpers git-prune ancillarymanipulators complete git-prune-packed plumbingmanipulators +git-psuh mainporcelain info git-pull mainporcelain remote git-push mainporcelain remote git-quiltimport foreignscminterface diff --git a/git.c b/git.c index 5a40eab8a26a66..ad88c5930b1a2b 100644 --- a/git.c +++ b/git.c @@ -627,6 +627,7 @@ static struct cmd_struct commands[] = { { "prune-packed", cmd_prune_packed, RUN_SETUP }, { "pull", cmd_pull, RUN_SETUP | NEED_WORK_TREE }, { "push", cmd_push, RUN_SETUP }, + { "psuh", cmd_psuh, RUN_SETUP }, { "range-diff", cmd_range_diff, RUN_SETUP | USE_PAGER }, { "read-tree", cmd_read_tree, RUN_SETUP }, { "rebase", cmd_rebase, RUN_SETUP | NEED_WORK_TREE }, diff --git a/t/meson.build b/t/meson.build index 7528e5cda5fef0..992dc5285f2838 100644 --- a/t/meson.build +++ b/t/meson.build @@ -1114,6 +1114,7 @@ integration_tests = [ 't9901-git-web--browse.sh', 't9902-completion.sh', 't9903-bash-prompt.sh', + 't9999-psuh-tutorial.sh', ] benchmarks = [ diff --git a/t/t9999-psuh-tutorial.sh b/t/t9999-psuh-tutorial.sh new file mode 100755 index 00000000000000..a3602b769d88e4 --- /dev/null +++ b/t/t9999-psuh-tutorial.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +test_description='git-psuh test + +This test runs git-psuh and makes sure it does not crash.' + +. ./test-lib.sh + +test_expect_success 'runs correctly with no args and good output' ' + git psuh >actual && + grep Pony actual +' + +test_done