diff --git a/cache.h b/cache.h index 611e554dea..67e74b7f75 100644 --- a/cache.h +++ b/cache.h @@ -1493,7 +1493,6 @@ extern int is_terminal_dumb(void); extern int git_ident_config(const char *, const char *, void *); /* * Prepare an ident to fall back on if the user didn't configure it. - * Must be called before any other function from the ident API. */ void prepare_fallback_ident(const char *name, const char *email); extern void reset_ident_date(void); diff --git a/ident.c b/ident.c index f30bd623f0..bce20e8652 100644 --- a/ident.c +++ b/ident.c @@ -507,9 +507,7 @@ int git_ident_config(const char *var, const char *value, void *data) static void set_env_if(const char *key, const char *value, int *given, int bit) { - if (*given & bit) - BUG("%s was checked before prepare_fallback got called", key); - if (getenv(key)) + if ((*given & bit) || getenv(key)) return; /* nothing to do */ setenv(key, value, 0); *given |= bit; diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 5f8272b6f9..2115e8767e 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -1096,6 +1096,12 @@ test_expect_success 'stash -- works with binary files' ' test_path_is_file subdir/untracked ' +test_expect_success 'stash with user.name and user.email set works' ' + test_config user.name "A U Thor" && + test_config user.email "a.u@thor" && + git stash +' + test_expect_success 'stash works when user.name and user.email are not set' ' git reset && >1 &&