summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd73423)
raw | patch | inline | side by side (parent: fd73423)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 26 Jan 2007 03:05:01 +0000 (19:05 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 26 Jan 2007 05:16:58 +0000 (21:16 -0800) |
The code that uses committer_info() in reflog can barf and die
whenever it is asked to update a ref. And I do not think
calling ignore_missing_committer_name() upfront like recent
receive-pack did in the aplication is a reasonable workaround.
What the patch does.
- git_committer_info() takes one parameter. It used to be "if
this is true, then die() if the name is not available due to
bad GECOS, otherwise issue a warning once but leave the name
empty". The reason was because we wanted to prevent bad
commits from being made by git-commit-tree (and its
callers). The value 0 is only used by "git var -l".
Now it takes -1, 0 or 1. When set to -1, it does not
complain but uses the pw->pw_name when name is not
available. Existing 0 and 1 values mean the same thing as
they used to mean before. 0 means issue warnings and leave
it empty, 1 means barf and die.
- ignore_missing_committer_name() and its existing caller
(receive-pack, to set the reflog) have been removed.
- git-format-patch, to come up with the phoney message ID when
asked to thread, now passes -1 to git_committer_info(). This
codepath uses only the e-mail part, ignoring the name. It
used to barf and die. The other call in the same program
when asked to add signed-off-by line based on committer
identity still passes 1 to make sure it barfs instead of
adding a bogus s-o-b line.
- log_ref_write in refs.c, to come up with the name to record
who initiated the ref update in the reflog, passes -1. It
used to barf and die.
The last change means that git-update-ref, git-branch, and
commit walker backends can now be used in a repository with
reflog by somebody who does not have the user identity required
to make a commit. They all used to barf and die.
I've run tests and all of them seem to pass, and also tried "git
clone" as a user whose GECOS is empty -- git clone works again
now (it was broken when reflog was enabled by default).
But this definitely needs extra sets of eyeballs.
Signed-off-by: Junio C Hamano <junkio@cox.net>
whenever it is asked to update a ref. And I do not think
calling ignore_missing_committer_name() upfront like recent
receive-pack did in the aplication is a reasonable workaround.
What the patch does.
- git_committer_info() takes one parameter. It used to be "if
this is true, then die() if the name is not available due to
bad GECOS, otherwise issue a warning once but leave the name
empty". The reason was because we wanted to prevent bad
commits from being made by git-commit-tree (and its
callers). The value 0 is only used by "git var -l".
Now it takes -1, 0 or 1. When set to -1, it does not
complain but uses the pw->pw_name when name is not
available. Existing 0 and 1 values mean the same thing as
they used to mean before. 0 means issue warnings and leave
it empty, 1 means barf and die.
- ignore_missing_committer_name() and its existing caller
(receive-pack, to set the reflog) have been removed.
- git-format-patch, to come up with the phoney message ID when
asked to thread, now passes -1 to git_committer_info(). This
codepath uses only the e-mail part, ignoring the name. It
used to barf and die. The other call in the same program
when asked to add signed-off-by line based on committer
identity still passes 1 to make sure it barfs instead of
adding a bogus s-o-b line.
- log_ref_write in refs.c, to come up with the name to record
who initiated the ref update in the reflog, passes -1. It
used to barf and die.
The last change means that git-update-ref, git-branch, and
commit walker backends can now be used in a repository with
reflog by somebody who does not have the user identity required
to make a commit. They all used to barf and die.
I've run tests and all of them seem to pass, and also tried "git
clone" as a user whose GECOS is empty -- git clone works again
now (it was broken when reflog was enabled by default).
But this definitely needs extra sets of eyeballs.
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-log.c | patch | blob | history | |
cache.h | patch | blob | history | |
ident.c | patch | blob | history | |
receive-pack.c | patch | blob | history | |
refs.c | patch | blob | history |
diff --git a/builtin-log.c b/builtin-log.c
index 503cd1e2be64a65032fd43dffa71f0340a94ed1f..56acc137f0bf73d30961da7350200e1c6f3b48bf 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -352,7 +352,7 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options, co
static void gen_message_id(char *dest, unsigned int length, char *base)
{
- const char *committer = git_committer_info(1);
+ const char *committer = git_committer_info(-1);
const char *email_start = strrchr(committer, '<');
const char *email_end = strrchr(committer, '>');
if(!email_start || !email_end || email_start > email_end - 1)
index 473197ded840dcd05824a54e099522f38796371b..9486132ac53f7afd21ba73551d12270384a71ba6 100644 (file)
--- a/cache.h
+++ b/cache.h
unsigned long approxidate(const char *);
extern int setup_ident(void);
-extern void ignore_missing_committer_name(void);
extern const char *git_author_info(int);
extern const char *git_committer_info(int);
index 6ad8fedd60ba1461d77dc2b1d66e52cf56158c6f..f9677905e5aa64c94d912ea90f51d10a7f34bd39 100644 (file)
--- a/ident.c
+++ b/ident.c
email = git_default_email;
if (!*name) {
- if (name == git_default_name && env_hint) {
+ struct passwd *pw;
+
+ if (0 <= error_on_no_name &&
+ name == git_default_name && env_hint) {
fprintf(stderr, env_hint, au_env, co_env);
env_hint = NULL; /* warn only once, for "git-var -l" */
}
- if (error_on_no_name)
+ if (0 < error_on_no_name)
die("empty ident %s <%s> not allowed", name, email);
+ pw = getpwuid(getuid());
+ if (!pw)
+ die("You don't exist. Go away!");
+ strlcpy(git_default_name, pw->pw_name,
+ sizeof(git_default_name));
+ name = git_default_name;
}
strcpy(date, git_default_date);
getenv("GIT_COMMITTER_DATE"),
error_on_no_name);
}
-
-void ignore_missing_committer_name()
-{
- /* If we did not get a name from the user's gecos entry then
- * git_default_name is empty; so instead load the username
- * into it as a 'good enough for now' approximation of who
- * this user is.
- */
- if (!*git_default_name) {
- struct passwd *pw = getpwuid(getuid());
- if (!pw)
- die("You don't exist. Go away!");
- strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name));
- }
-}
diff --git a/receive-pack.c b/receive-pack.c
index 8b59b3227e8c3c920d04b05cd5b5bb4e72e7753f..7d263262d3b593b645c73b37b63356bfdea42d7f 100644 (file)
--- a/receive-pack.c
+++ b/receive-pack.c
die("attempt to push into a shallow repository");
setup_ident();
- /* don't die if gecos is empty */
- ignore_missing_committer_name();
git_config(receive_pack_config);
if (0 <= transfer_unpack_limit)
index 81173282fce15c1bd93feea86d3f5ec99d5914d4..4323e9a41a6c2f4fe7f0dba4b53e083bd8576d50 100644 (file)
--- a/refs.c
+++ b/refs.c
lock->log_file, strerror(errno));
}
- committer = git_committer_info(1);
+ committer = git_committer_info(-1);
if (msg) {
maxlen = strlen(committer) + strlen(msg) + 2*40 + 5;
logrec = xmalloc(maxlen);