From: Junio C Hamano Subject: Re: [PATCH 2/2] apply: notice creation/removal patches produced by GNU diff Date: Fri, 10 Jul 2009 20:57:32 -0700 Message-ID: <7vws6foor7.fsf@alter.siamese.dyndns.org> References: <4A5680B5.2090405@necel.com> <4A56B060.7090106@mips.com> <20090710104743.GB1288@linux-mips.org> <7vhbxkv7ax.fsf@alter.siamese.dyndns.org> <7vk52frjv9.fsf@alter.siamese.dyndns.org> <7vbpnrrjld.fsf_-_@alter.siamese.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Junio C Hamano , git@vger.kernel.org To: Linus Torvalds X-From: git-owner@vger.kernel.org Sat Jul 11 05:59:09 2009 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1MPTjw-00046m-7i for gcvg-git-2@gmane.org; Sat, 11 Jul 2009 05:59:08 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753287AbZGKD5o (ORCPT ); Fri, 10 Jul 2009 23:57:44 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753132AbZGKD5n (ORCPT ); Fri, 10 Jul 2009 23:57:43 -0400 Received: from a-sasl-quonix.sasl.smtp.pobox.com ([208.72.237.25]:58040 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428AbZGKD5m (ORCPT ); Fri, 10 Jul 2009 23:57:42 -0400 Received: from localhost.localdomain (unknown [127.0.0.1]) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id B671B27C9E; Fri, 10 Jul 2009 23:57:41 -0400 (EDT) Received: from pobox.com (unknown [68.225.240.211]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id DBACA27C9D; Fri, 10 Jul 2009 23:57:35 -0400 (EDT) In-Reply-To: (Linus Torvalds's message of "Fri\, 10 Jul 2009 20\:32\:01 -0700 \(PDT\)") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) X-Pobox-Relay-ID: FB785164-6DCE-11DE-A1C5-424D1A496417-77302942!a-sasl-quonix.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Linus Torvalds writes: > On Fri, 10 Jul 2009, Junio C Hamano wrote: >> >> Unified context patch generated by GNU diff has UNIX epoch timestamp >> on the side that does not exist when the patch is about a creation or >> a deletion event. Notice this convention when reading a non-git diff. > > Hmm. Do you really want to do a regex here? That seems overkill. Why not > just try to parse the date? If parse_date() says "It is a date and it is UNIX epoch", we mark the patch as either creation or deletion, and that is used by various consistency checks. Deletion patch must remove the entire line, the file must not exist if it is the target of a creation patch, etc. I found parse_date() to be a bit too forgiving for my taste for this particular application; I wanted to be anal and only accept the format specified by http://www.opengroup.org/onlinepubs/9699919799/utilities/diff.html#tag_20_34_10_07 By the way, the above does not mention anything about marking creation/deletion event with UNIX epoch; I am guessing it is a GNU extension. >> + const char stamp_regexp[] = >> + "^[0-9][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]" >> + " " >> + "[0-2][0-9]:[0-5][0-9]:[0-6][0-9](\\.0+)?" >> + " " >> + "[-+][0-2][0-9][0-5][0-9]\n"; > > Also, why are you apparently expecting micro-seconds to always be all > zeroes? Maybe that's the common case, but I'd expect that somebody has > non-zero microseconds on filesystems that support them.. As the comment before the quoted part of the patch says, the point of this function is not about detecting the presense of a timestamp (and parsing the time), but telling if the timestamp that represents UNIX epoch is there. The first iteration of my patch did not even use parse_date() but accepted only 1969-12-31 (west of GMT) or 1970-01-01 (east of GMT) and then checked timestamp with timezone manually. Perhaps that might be a better way to do this function? I dunno.