teach the user to be nice to git and let him say please sometimes
PATCH 1/1 teach the user to be nice to git and let him say please sometimes
Since ages we do not care about our program enough. Lets not treat them as slaves anymore and say please.
--- .gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/config.c | 23 ++----------------- builtin/please.c | 9 ++++++++ cache.h | 1 + config.c | 23 +++++++++++++++++++ contrib/completion/git-prompt.sh | 5 +++- git.c | 49 +++++++++++++++++++++++++++++++++++++++- 9 files changed, 90 insertions(+), 23 deletions(-) create mode 100644 builtin/please.c
.gitignore +1 -0
@@ -105,6 +105,7 @@ /git-parse-remote /git-patch-id /git-peek-remote +/git-please /git-prune /git-prune-packed /git-pull
Makefile +1 -0
@@ -943,6 +943,7 @@ BUILTIN_OBJS += builtin/pack-objects.o BUILTIN_OBJS += builtin/pack-redundant.o BUILTIN_OBJS += builtin/pack-refs.o BUILTIN_OBJS += builtin/patch-id.o +BUILTIN_OBJS += builtin/please.o BUILTIN_OBJS += builtin/prune-packed.o BUILTIN_OBJS += builtin/prune.o BUILTIN_OBJS += builtin/push.o
builtin.h +1 -0
@@ -105,6 +105,7 @@ extern int cmd_notes(int argc, const char **argv, const char *prefix);extern int cmd_pack_objects (int argc,const char **argv,const char *prefix);extern int cmd_pack_redundant (int argc,const char **argv,const char *prefix);extern int cmd_patch_id (int argc,const char **argv,const char *prefix); +extern int cmd_please (int argc,const char **argv,const char *prefix);extern int cmd_prune (int argc,const char **argv,const char *prefix);extern int cmd_prune_packed (int argc,const char **argv,const char *prefix);extern int cmd_push (int argc,const char **argv,const char *prefix);
builtin/config.c +2 -21
@@ -364,27 +364,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)usage_with_options (builtin_config_usage, builtin_config_options); } -if (use_global_config) { -char *user_config =NULL ; -char *xdg_config =NULL ; - -home_config_paths (&user_config, &xdg_config,"config" ); - -if (!user_config) -/* -* It is unknown if HOME/.gitconfig exists, so -* we do not know if we should write to XDG -* location; error out even if XDG_CONFIG_HOME -* is set and points at a sane location. -*/ -die ("$HOME not set" ); - -if (access_or_warn (user_config,R_OK ) && - xdg_config && !access_or_warn (xdg_config,R_OK )) - given_config_file = xdg_config; -else - given_config_file = user_config; - } +if (use_global_config) + given_config_file =git_user_config ();else if (use_system_config) given_config_file =git_etc_gitconfig ();else if (use_local_config)
builtin/please.c new file +9 -0
@@ -0,0 +1,9 @@ +#include "builtin.h" +#include "run-command.h" + +int cmd_please (int argc,const char **argv,const char *prefix) +{ +if (!strcmp (argv[1 ],"-h" )) +usage ("Sometimes" ); +return run_command_v_opt (argv+1 ,RUN_GIT_CMD ); +}
cache.h +1 -0
@@ -1164,6 +1164,7 @@ extern int git_config_set_multivar_in_file(const char *, const char *, const chaextern int git_config_rename_section (const char *,const char *);extern int git_config_rename_section_in_file (const char *,const char *,const char *);extern const char *git_etc_gitconfig (void ); +extern const char *git_user_config (void );extern int check_repository_format_version (const char *var,const char *value,void *cb);extern int git_env_bool (const char *,int );extern int git_config_system (void );
config.c +23 -0
@@ -935,6 +935,29 @@ const char *git_etc_gitconfig(void)return system_wide; } +const char *git_user_config (void ) +{ +char *user_config =NULL ; +char *xdg_config =NULL ; + +home_config_paths (&user_config, &xdg_config,"config" ); + +if (!user_config) +/* +* It is unknown if HOME/.gitconfig exists, so +* we do not know if we should write to XDG +* location; error out even if XDG_CONFIG_HOME +* is set and points at a sane location. +*/ +die ("$HOME not set" ); + +if (access_or_warn (user_config,R_OK ) && + xdg_config && !access_or_warn (xdg_config,R_OK )) +return xdg_config; +else +return user_config; +} +int git_env_bool (const char *k,int def) {const char *v =getenv (k);
contrib/completion/git-prompt.sh +4 -1
@@ -241,6 +241,7 @@ __git_ps1 () local ps1pc_start='\u@\h:\w ' local ps1pc_end='\$ ' local printf_format=' (%s)' + export GIT_POLITENESS_CHECK_PASSED="Yes" case "$#" in 2|3) pcmode=yes
@@ -250,7 +251,8 @@ __git_ps1 () ;; 0|1) printf_format="${1:-$printf_format}" ;; - *) return + *) unset GIT_POLITENESS_CHECK_PASSED + return ;; esac
@@ -409,4 +411,5 @@ __git_ps1 () printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p" fi fi + unset GIT_POLITENESS_CHECK_PASSED }
git.c +48 -0
74 lines not on this page · raw message
Signature · 1 line
1.8.3.rc1.44.gb387c77
Quoted 8 lines · Heiko Voigt
Since ages we do not care about our program enough. Lets not treat them as slaves anymore and say please.
Signed-off-by Heiko Voigt <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Jens Lehmann <[email protected]>Signed-off-by Thomas Rast <[email protected]>Signed-off-by Johan Herland <[email protected]>
So these were the ones present on the dev-day?
I actually would have expected, from the "please" title, the opposite, us saying "please" to the user, either once in a while in the advice messages we give to them, or perhaps in the en_POLITE locale ;-)
Quoted 9 lines
.gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/config.c | 23 ++----------------- builtin/please.c | 9 ++++++++ cache.h | 1 + config.c | 23 +++++++++++++++++++ contrib/completion/git-prompt.sh | 5 +++- git.c | 49 +++++++++++++++++++++++++++++++++++++++-
There is no test to protect this feature from future breakages?
Hi,
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · Heiko Voigt
Since ages we do not care about our program enough. Lets not treat them as slaves anymore and say please.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Heiko Voigt <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Jens Lehmann <[email protected]>Signed-off-by Thomas Rast <[email protected]>Signed-off-by Johan Herland <[email protected]>So these were the ones present on the dev-day?
No this was just a random sample of the ones sitting at the same beer garden table that this feature was implemented on.
Quoted 4 lines
I actually would have expected, from the "please" title, the opposite, us saying "please" to the user, either once in a while in the advice messages we give to them, or perhaps in the
en_POLITElocale ;-)
The en_POLITE is also a nice idea :-) We could split up the work on the translations amongst all people joining a git meetup.
Quoted 11 lines
Quoted 9 lines
.gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/config.c | 23 ++----------------- builtin/please.c | 9 ++++++++ cache.h | 1 + config.c | 23 +++++++++++++++++++ contrib/completion/git-prompt.sh | 5 +++- git.c | 49 +++++++++++++++++++++++++++++++++++++++-There is no test to protect this feature from future breakages?
In fact the whole testsuite should fail after the first 10 tests if you said please right before running it. So since battery life is short and this feature so important we did not bother to fix that. We already had enough please complaints during intermediate commits and entering the signed-off messages. It is really annoying, you should try this patch! ;-) And it is especially unuseful when you are committing using git gui.
Cheers Heiko
Quoted 9 lines · Heiko Voigt
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Heiko Voigt
Signed-off-by Heiko Voigt <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Jens Lehmann <[email protected]>Signed-off-by Thomas Rast <[email protected]>Signed-off-by Johan Herland <[email protected]>
Quoted 4 lines
Quoted 1 line
So these were the ones present on the dev-day?
No this was just a random sample of the ones sitting at the same beer garden table that this feature was implemented on.
Also see
http://thomasrast.ch/pix/foss/20130509_gitmerge/DSC_7078.jpg.php
for an illustration of the history of this patch.
</plug>
Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.chQuoted 16 lines · Thomas Rast
Quoted 9 lines · Heiko Voigt
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Heiko Voigt
Signed-off-by Heiko Voigt <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Jens Lehmann <[email protected]>Signed-off-by Thomas Rast <[email protected]>Signed-off-by Johan Herland <[email protected]>Quoted 4 lines
Quoted 1 line
So these were the ones present on the dev-day?
No this was just a random sample of the ones sitting at the same beer garden table that this feature was implemented on.
Quoted 7 lines
Also see
http://thomasrast.ch/pix/foss/20130509_gitmerge/DSC_7078.jpg.php
for an illustration of the history of this patch.
</plug>
Thanks for sharing. I see some familiar faces. Envy, envy...
Quoted 8 lines · Heiko Voigt
Since ages we do not care about our program enough. Lets not treat them as slaves anymore and say please.
Signed-off-by Heiko Voigt <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Jens Lehmann <[email protected]>Signed-off-by Thomas Rast <[email protected]>Signed-off-by Johan Herland <[email protected]>
A product of Git Berlin Meetup?
Quoted 13 lines
git.c +13
-0+static void check_politeness (const char *cmd) +{ +const char *user_config; +struct strbuf buf =STRBUF_INIT ; + +if (getenv ("GIT_POLITENESS_CHECK_PASSED" )) +return ; + +setenv ("GIT_POLITENESS_CHECK_PASSED" ,"Yes" ,1 ); + +git_config_early (read_polite_counter,NULL ,NULL ); +if (!strcmp (cmd,"please" )) { + impolite_counter =0 ;
git.c static int run_builtin(struct cmd_struct *p, int argc, const char **argv) · line 338
Quoted 10 lines
git.c +10
-0+ polite_counter++; + }else { + impolite_counter++; + polite_counter =0 ; + } + +if (impolite_counter >10 ) +die ("Error: Learn some manners, say please some time!" ); +if (polite_counter >10 ) +die ("Error: Too many please! I don't believe you." );
NAK. If we truly care, we need better AI here!
git.c static int run_builtin(struct cmd_struct *p, int argc, const char **argv) · line 347
Quoted 9 lines
git.c +9
-0+ + user_config =git_user_config (); +strbuf_addf (&buf,"%d" , polite_counter); +git_config_set_in_file (user_config,"user.polite" , buf.buf); +strbuf_reset (&buf); +strbuf_addf (&buf,"%d" , impolite_counter); +git_config_set_in_file (user_config,"user.impolite" , buf.buf); +strbuf_release (&buf); +}
--
Duy
Quoted 11 lines · Duy Nguyen
Quoted 8 lines · Heiko Voigt
Since ages we do not care about our program enough. Lets not treat them as slaves anymore and say please.
Signed-off-by Heiko Voigt <[email protected]>Signed-off-by Jonathan Nieder <[email protected]>Signed-off-by Jens Lehmann <[email protected]>Signed-off-by Thomas Rast <[email protected]>Signed-off-by Johan Herland <[email protected]>A product of Git Berlin Meetup?
Yep :-)
Quoted 17 lines
Quoted 17 lines
git.c +17
-0+static void check_politeness (const char *cmd) +{ +const char *user_config; +struct strbuf buf =STRBUF_INIT ; + +if (getenv ("GIT_POLITENESS_CHECK_PASSED" )) +return ; + +setenv ("GIT_POLITENESS_CHECK_PASSED" ,"Yes" ,1 ); + +git_config_early (read_polite_counter,NULL ,NULL ); +if (!strcmp (cmd,"please" )) { + impolite_counter =0 ; + polite_counter++; + }else { + impolite_counter++; + polite_counter =0 ;
Quoted 8 lines
git.c static int run_builtin(struct cmd_struct *p, int argc, const char **argv) · line 338
Quoted 6 lines
git.c +6
-0+ } + +if (impolite_counter >10 ) +die ("Error: Learn some manners, say please some time!" ); +if (polite_counter >10 ) +die ("Error: Too many please! I don't believe you." );NAK. If we truly care, we need better AI here!
I agree but this patches goal was to implement the basic politeness infrastructure. We planned to add more features, like inter-repository jealousy, later. For inter-repository jealousy git would complain if you worked more with one repository than others you cloned and you'd for example sometimes need a double please to satisfy it.
Cheers Heiko
Quoted 5 lines · Heiko Voigt
Quoted 5 lines
Quoted 4 lines
git.c +4
-0+if (impolite_counter >10 ) +die ("Error: Learn some manners, say please some time!" ); +if (polite_counter >10 ) +die ("Error: Too many please! I don't believe you." );
Quoted 7 lines
Quoted 1 line
NAK. If we truly care, we need better AI here!
I agree but this patches goal was to implement the basic politeness infrastructure. We planned to add more features, like inter-repository jealousy, later. For inter-repository jealousy git would complain if you worked more with one repository than others you cloned and you'd for example sometimes need a double please to satisfy it.
I'm still not happy with this direction. I propose we rewrite C Git in Lisp first as a preparation step for git-please improvements. We could drop support for all platforms but Lisp Machine along the way. That would make all other Git implementations jealous.
--
Duy
Quoted 4 lines · Heiko Voigt
Since ages we do not care about our program enough. Lets not treat them as slaves anymore and say please.
9 files changed, 90 insertions(+), 23 deletions(-)
Um, why such an elaborate joke?