git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why is ident_is_sufficient different on Windows?
@ 2013-02-06 13:06 Max Horn
  2013-02-06 20:41 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Max Horn @ 2013-02-06 13:06 UTC (permalink / raw)
  To: git

Hi there,

while trying to understand which parts of the author & committer identity are mandatory (name, email, or both), I ended up in ident.c, looking at ident_is_sufficient(), and to my surprise discovered that this seems to differ between Windows (were both are mandatory) and everyone else:

static int ident_is_sufficient(int user_ident_explicitly_given)
{
#ifndef WINDOWS
	return (user_ident_explicitly_given & IDENT_MAIL_GIVEN);
#else
	return (user_ident_explicitly_given == IDENT_ALL_GIVEN);
#endif
}


According to git blame, this was introduced here:

commit 5aeb3a3a838b2cb03d250f3376cf9c41f4d4608e
Author: Junio C Hamano <gitster@pobox.com>
Date:   Sun Jan 17 13:54:28 2010 -0800

    user_ident_sufficiently_given(): refactor the logic to be usable from elsewhere


The commit message sounds as if this was only a refactoring, but the patch to me look as if it changes behaviour, too. Of course this could very well be false, say due to code elsewhere that already caused Windows to behave differently; I wouldn't know.


Still, I wonder: Why does this difference exist?


Cheers,
Max

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why is ident_is_sufficient different on Windows?
  2013-02-06 13:06 Why is ident_is_sufficient different on Windows? Max Horn
@ 2013-02-06 20:41 ` Junio C Hamano
  2013-02-06 20:47   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2013-02-06 20:41 UTC (permalink / raw)
  To: Max Horn; +Cc: git

Max Horn <max@quendi.de> writes:

> static int ident_is_sufficient(int user_ident_explicitly_given)
> {
> #ifndef WINDOWS
> 	return (user_ident_explicitly_given & IDENT_MAIL_GIVEN);
> #else
> 	return (user_ident_explicitly_given == IDENT_ALL_GIVEN);
> #endif
> }
>
>
> According to git blame, this was introduced here:
>
> commit 5aeb3a3a838b2cb03d250f3376cf9c41f4d4608e
> Author: Junio C Hamano <gitster@pobox.com>
> Date:   Sun Jan 17 13:54:28 2010 -0800
>
>     user_ident_sufficiently_given(): refactor the logic to be usable from elsewhere
>
>
> The commit message sounds as if this was only a refactoring, but
> the patch to me look as if it changes behaviour, too. Of course
> this could very well be false, say due to code elsewhere that
> already caused Windows to behave differently; I wouldn't know.
>
> Still, I wonder: Why does this difference exist?

Sorry but I do not recall why these ifdefs are there.  The commit
did this to builtin-commit.c:

-               if (user_ident_explicitly_given != IDENT_ALL_GIVEN)
+               if (!user_ident_sufficiently_given())

I would have written the function to always check with ALL_GIVEN
myself, and it is very likely that I was *not* the person who
noticed that the function needs to behave differently on Windows, as
I do not do Windows.

I suspect somebody from the Windows camp saw a patch I posted
without the ifdef, noticed that there is a problem to expect
IDENT_NAME_GIVEN to be set on Windows for some reason, and resulted
in a reroll of the function in that shape.

I didn't find anything in the list archive, though.  So I am
stumped.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why is ident_is_sufficient different on Windows?
  2013-02-06 20:41 ` Junio C Hamano
@ 2013-02-06 20:47   ` Junio C Hamano
  2013-02-06 20:52     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2013-02-06 20:47 UTC (permalink / raw)
  To: Max Horn; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

> I suspect somebody from the Windows camp saw a patch I posted
> without the ifdef, noticed that there is a problem to expect
> IDENT_NAME_GIVEN to be set on Windows for some reason, and resulted
> in a reroll of the function in that shape.
>
> I didn't find anything in the list archive, though.  So I am
> stumped.

The only thing I can think of is that on Unix we can guess name from
GECOS, which could be considered sufficiently your name, while on
Windows we probably do not get anything useful there.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why is ident_is_sufficient different on Windows?
  2013-02-06 20:47   ` Junio C Hamano
@ 2013-02-06 20:52     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2013-02-06 20:52 UTC (permalink / raw)
  To: Max Horn; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> I suspect somebody from the Windows camp saw a patch I posted
>> without the ifdef, noticed that there is a problem to expect
>> IDENT_NAME_GIVEN to be set on Windows for some reason, and resulted
>> in a reroll of the function in that shape.
>>
>> I didn't find anything in the list archive, though.  So I am
>> stumped.
>
> The only thing I can think of is that on Unix we can guess name from
> GECOS, which could be considered sufficiently your name, while on
> Windows we probably do not get anything useful there.

http://thread.gmane.org/gmane.comp.version-control.git/137312/focus=137345

These days, we encourage setting user.name explicitly even on a
system on which it is likely that we will see a good GECOS value, so
removing the ifdef and always check with ALL may not hurt anybody.
I dunno.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-06 20:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-06 13:06 Why is ident_is_sufficient different on Windows? Max Horn
2013-02-06 20:41 ` Junio C Hamano
2013-02-06 20:47   ` Junio C Hamano
2013-02-06 20:52     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).