Default GIT_COMMITTER_NAME to login name in recieve-pack.
If GIT_COMMITTER_NAME is not available in receive-pack but reflogs are enabled we would normally die out with an error message asking the user to correct their environment settings. Now that reflogs are enabled by default in (what we guessed to be) non-bare Git repositories this may cause problems for some users who don't have their full name in the gecos field and who don't have access to the remote system to correct the problem. So rather than die()'ing out in receive-pack when we try to log a ref change and have no committer name we default to the username, as obtained from the host's password database. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
Dec 17, 2006 at 03:15 UTC
a7f196a74650e45ce240754e2caa483752651063
3 files changed
+18
cache.h
+1
@@ -309,6 +309,7 @@ void datestamp(char *buf, int bufsize);
309
unsigned long approxidate(const char *);
310
311
extern int setup_ident(void);
312
+extern void ignore_missing_committer_name();
313
extern const char *git_author_info(int);
314
extern const char *git_committer_info(int);
315
ident.c
+15
@@ -221,3 +221,18 @@ const char *git_committer_info(int error_on_no_name)
221
getenv("GIT_COMMITTER_DATE"),
222
error_on_no_name);
223
}
224
+
225
+void ignore_missing_committer_name()
226
+{
227
+ /* If we did not get a name from the user's gecos entry then
228
+ * git_default_name is empty; so instead load the username
229
+ * into it as a 'good enough for now' approximation of who
230
+ * this user is.
231
+ */
232
+ if (!*git_default_name) {
233
+ struct passwd *pw = getpwuid(getuid());
234
+ if (!pw)
235
+ die("You don't exist. Go away!");
236
+ strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name));
237
+ }
238
+}
receive-pack.c
+2
@@ -420,6 +420,8 @@ int main(int argc, char **argv)
420
die("'%s': unable to chdir or not a git archive", dir);
421
422
setup_ident();
423
+ /* don't die if gecos is empty */
424
+ ignore_missing_committer_name();
425
git_config(receive_pack_config);
426
427
write_head_info();