diff --git a/.gitignore b/.gitignore index 89b3b79c1a2278..e99e500326accb 100644 --- a/.gitignore +++ b/.gitignore @@ -118,6 +118,7 @@ /git-prune /git-prune-packed /git-pull +/git-psuh /git-push /git-quiltimport /git-range-diff diff --git a/Documentation/git-psuh.txt b/Documentation/git-psuh.txt new file mode 100644 index 00000000000000..c8feb8e69d249e --- /dev/null +++ b/Documentation/git-psuh.txt @@ -0,0 +1,28 @@ +git-psuh(1) +=========== + +NAME +---- +git-psuh - Delight users' typo with a shy horse + + +SYNOPSIS +-------- +[verse] +'git-psuh [...]' + +DESCRIPTION +----------- +... + +OPTIONS[[OPTIONS]] +------------------ +... + +OUTPUT +------ +... + +GIT +--- +Part of the git[1] suite \ No newline at end of file diff --git a/Makefile b/Makefile index c99361e719776c..3ab58077805914 100644 --- a/Makefile +++ b/Makefile @@ -1108,6 +1108,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 5cf5df69f72fd5..59532cdc99ff4a 100644 --- a/builtin.h +++ b/builtin.h @@ -202,6 +202,7 @@ int cmd_patch_id(int argc, const char **argv, const char *prefix); int cmd_prune(int argc, const char **argv, const char *prefix); int cmd_prune_packed(int argc, const char **argv, const char *prefix); int cmd_pull(int argc, const char **argv, const char *prefix); +int cmd_psuh(int argc, const char **argv, const char *prefix); int cmd_push(int argc, const char **argv, const char *prefix); int cmd_range_diff(int argc, const char **argv, const char *prefix); int cmd_read_tree(int argc, const char **argv, const char *prefix); diff --git a/builtin/psuh.c b/builtin/psuh.c new file mode 100644 index 00000000000000..4ce79b73df73a6 --- /dev/null +++ b/builtin/psuh.c @@ -0,0 +1,60 @@ +#include "builtin.h" +#include "config.h" +#include "wt-status.h" +#include "commit.h" +#include "pretty.h" +#include "parse-options.h" + +int cmd_psuh(int argc, const char **argv, const char *prefix) +{ + + int i; + const char *cfg_name; + struct wt_status status; + struct commit *c = NULL; + struct strbuf commitline = STRBUF_INIT; + + static const char * const psuh_usage[] = { + N_("git psuh [...]"), + NULL, + }; + + struct option options[] = { + OPT_END() + }; + + argc = parse_options(argc, argv, prefix, options, psuh_usage, 0); + + printf(_("pedro eats an apple.\n")); + + 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 : ""); + + git_config(git_default_config, NULL); + + if (git_config_get_string_const("user.name", &cfg_name) > 0) + printf(_("No name is found in config\n")); + else + printf(_("Your name: %s\n"), cfg_name); + + wt_status_prepare(the_repository, &status); + git_config(git_default_config, &status); + printf(_("Your current branch: %s\n"), status.branch); + + c = lookup_commit_reference_by_name("origin/master"); + + if (c != NULL) { + pp_commit_easy(CMIT_FMT_ONELINE, c, &commitline); + printf(_("Current commit: %s\n"), commitline.buf); + } + + return 0; +} + diff --git a/git.c b/git.c index ce6ab0ece2cc6d..3ba839300ba54f 100644 --- a/git.c +++ b/git.c @@ -547,7 +547,8 @@ static struct cmd_struct commands[] = { { "prune", cmd_prune, RUN_SETUP }, { "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 }, + { "push", cmd_push, RUN_SETUP }, { "range-diff", cmd_range_diff, RUN_SETUP | USE_PAGER }, { "read-tree", cmd_read_tree, RUN_SETUP | SUPPORT_SUPER_PREFIX}, { "rebase", cmd_rebase, RUN_SETUP | NEED_WORK_TREE }, diff --git a/t/t9999-psuh-tutorial.sh b/t/t9999-psuh-tutorial.sh new file mode 100755 index 00000000000000..a37d50522196e7 --- /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 && + test_i18ngrep pedro actual +' + +test_done