core.excludesfile::
In addition to '.gitignore' (per-directory) and
'.git/info/exclude', git looks into this file for patterns
- of files which are not meant to be tracked. "~/" and "~user/"
- are expanded to the specified user's home directory. See
- linkgit:gitignore[5].
+ of files which are not meant to be tracked. "~/" is expanded
+ to the value of `$HOME` and "~user/" to the specified user's
+ home directory. See linkgit:gitignore[5].
core.editor::
Commands such as `commit` and `tag` that lets you edit
commit.template::
Specify a file to use as the template for new commit messages.
- "~/" and "~user/" are expanded to the specified user's home directory.
+ "~/" is expanded to the value of `$HOME` and "~user/" to the
+ specified user's home directory.
diff.autorefreshindex::
When using 'git-diff' to compare with work tree
if (path[0] == '~') {
const char *username = path + 1;
size_t username_len = first_slash - username;
- struct passwd *pw = getpw_str(username, username_len);
- if (!pw)
- goto return_null;
- strbuf_add(&user_path, pw->pw_dir, strlen(pw->pw_dir));
+ if (username_len == 0) {
+ const char *home = getenv("HOME");
+ strbuf_add(&user_path, home, strlen(home));
+ } else {
+ struct passwd *pw = getpw_str(username, username_len);
+ if (!pw)
+ goto return_null;
+ strbuf_add(&user_path, pw->pw_dir, strlen(pw->pw_dir));
+ }
to_copy = first_slash;
}
strbuf_add(&user_path, to_copy, strlen(to_copy));