mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
git-save: improve commit authorship data
We used to always just commit as "subsurface@hohndel.org" because libgit-19 doesn't have the interfaces to do user name lookup. This does better if you have libgit-20, using "git_signature_default()" to get the actual user that does the saving. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7e1d8724c5
commit
a3aacfc6c2
5 changed files with 56 additions and 2 deletions
23
linux.c
23
linux.c
|
@ -2,16 +2,39 @@
|
|||
/* implements Linux specific functions */
|
||||
#include "dive.h"
|
||||
#include "display.h"
|
||||
#include "membuffer.h"
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <fnmatch.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
|
||||
const char system_divelist_default_font[] = "Sans";
|
||||
const int system_divelist_default_font_size = 8;
|
||||
|
||||
void subsurface_user_info(struct user_info *user)
|
||||
{
|
||||
struct passwd *pwd = getpwuid(getuid());
|
||||
const char *username = getenv("USER");
|
||||
|
||||
if (pwd) {
|
||||
if (pwd->pw_gecos && *pwd->pw_gecos)
|
||||
user->name = pwd->pw_gecos;
|
||||
if (!username)
|
||||
username = pwd->pw_name;
|
||||
}
|
||||
if (username && *username) {
|
||||
char hostname[64];
|
||||
struct membuffer mb = { 0 };
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
put_format(&mb, "%s@%s", username, hostname);
|
||||
user->email = mb_cstring(&mb);
|
||||
}
|
||||
}
|
||||
|
||||
const char *system_default_filename(void)
|
||||
{
|
||||
const char *home, *user;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue