<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/builtin/check-ref-format.c, branch v2.26.1</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.26.1</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.26.1'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-11-06T05:24:28Z</updated>
<entry>
<title>Merge branch 'jc/check-ref-format-oor'</title>
<updated>2017-11-06T05:24:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-11-06T05:24:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5a74ce22e61ce0c8d7325b891ef1a926cf4f6154'/>
<id>urn:sha1:5a74ce22e61ce0c8d7325b891ef1a926cf4f6154</id>
<content type='text'>
"git check-ref-format --branch @{-1}" bit a "BUG()" when run
outside a repository for obvious reasons; clarify the documentation
and make sure we do not even try to expand the at-mark magic in
such a case, but still call the validation logic for branch names.

* jc/check-ref-format-oor:
  check-ref-format doc: --branch validates and expands &lt;branch&gt;
  check-ref-format --branch: strip refs/heads/ using skip_prefix
  check-ref-format --branch: do not expand @{...} outside repository
</content>
</entry>
<entry>
<title>check-ref-format --branch: strip refs/heads/ using skip_prefix</title>
<updated>2017-10-17T21:12:01Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-10-17T07:10:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7ccc94ff4590cd035b7f78dfd9debbd7e692f3e6'/>
<id>urn:sha1:7ccc94ff4590cd035b7f78dfd9debbd7e692f3e6</id>
<content type='text'>
The expansion returned from strbuf_check_branch_ref always starts with
"refs/heads/" by construction, but there is nothing about its name or
advertised API making that obvious.  This command is used to process
human-supplied input from the command line and is usually not the
inner loop, so we can spare some cycles to be more defensive.  Instead
of hard-coding the offset strlen("refs/heads/") to skip, verify that
the expansion actually starts with refs/heads/.

[jn: split out from a larger patch, added explanation]

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>check-ref-format: release strbuf after use in check_ref_format_branch()</title>
<updated>2017-09-06T23:49:26Z</updated>
<author>
<name>Rene Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-08-30T17:49:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=861e65557f14a0d93af780c71d82f194404dd563'/>
<id>urn:sha1:861e65557f14a0d93af780c71d82f194404dd563</id>
<content type='text'>
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>use xmallocz to avoid size arithmetic</title>
<updated>2016-02-22T22:51:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-02-22T22:44:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3733e6946465d4a3a1d89026a5ec911d3af339ab'/>
<id>urn:sha1:3733e6946465d4a3a1d89026a5ec911d3af339ab</id>
<content type='text'>
We frequently allocate strings as xmalloc(len + 1), where
the extra 1 is for the NUL terminator. This can be done more
simply with xmallocz, which also checks for integer
overflow.

There's no case where switching xmalloc(n+1) to xmallocz(n)
is wrong; the result is the same length, and malloc made no
guarantees about what was in the buffer anyway. But in some
cases, we can stop manually placing NUL at the end of the
allocated buffer. But that's only safe if it's clear that
the contents will always fill the buffer.

In each case where this patch does so, I manually examined
the control flow, and I tried to err on the side of caution.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>standardize usage info string format</title>
<updated>2015-01-14T17:32:04Z</updated>
<author>
<name>Alex Henrie</name>
<email>alexhenrie24@gmail.com</email>
</author>
<published>2015-01-13T07:44:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9c9b4f2f8b7f27f3984e80d053106d5d41cbb03b'/>
<id>urn:sha1:9c9b4f2f8b7f27f3984e80d053106d5d41cbb03b</id>
<content type='text'>
This patch puts the usage info strings that were not already in docopt-
like format into docopt-like format, which will be a litle easier for
end users and a lot easier for translators. Changes include:

- Placing angle brackets around fill-in-the-blank parameters
- Putting dashes in multiword parameter names
- Adding spaces to [-f|--foobar] to make [-f | --foobar]
- Replacing &lt;foobar&gt;* with [&lt;foobar&gt;...]

Signed-off-by: Alex Henrie &lt;alexhenrie24@gmail.com&gt;
Reviewed-by: Matthieu Moy &lt;Matthieu.Moy@imag.fr&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Change check_refname_format() to reject unnormalized refnames</title>
<updated>2011-10-05T20:45:30Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2011-09-15T21:10:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a40e6fb67a4aed2d5ffde5792bf7f1996d9666e1'/>
<id>urn:sha1:a40e6fb67a4aed2d5ffde5792bf7f1996d9666e1</id>
<content type='text'>
Since much of the infrastructure does not work correctly with
unnormalized refnames, change check_refname_format() to reject them.

Similarly, change "git check-ref-format" to reject unnormalized
refnames by default.  But add an option --normalize, which causes "git
check-ref-format" to normalize the refname before checking its format,
and print the normalized refname.  This is exactly the behavior of the
old --print option, which is retained but deprecated.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Inline function refname_format_print()</title>
<updated>2011-10-05T20:45:30Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2011-09-15T21:10:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a5e4ec063afea050d09773f0aa5dcb95a82a31ec'/>
<id>urn:sha1:a5e4ec063afea050d09773f0aa5dcb95a82a31ec</id>
<content type='text'>
Soon we will make printing independent of collapsing.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Make collapse_slashes() allocate memory for its result</title>
<updated>2011-10-05T20:45:30Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2011-09-15T21:10:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7f748c7cb2317800dcdb311c3e75a086ae0d1600'/>
<id>urn:sha1:7f748c7cb2317800dcdb311c3e75a086ae0d1600</id>
<content type='text'>
This will make upcoming changes a tiny bit easier.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Change check_ref_format() to take a flags argument</title>
<updated>2011-10-05T20:45:29Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2011-09-15T21:10:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8d9c50105f908b2adde4b7c77537cf95f19cd893'/>
<id>urn:sha1:8d9c50105f908b2adde4b7c77537cf95f19cd893</id>
<content type='text'>
Change check_ref_format() to take a flags argument that indicates what
is acceptable in the reference name (analogous to "git
check-ref-format"'s "--allow-onelevel" and "--refspec-pattern").  This
is more convenient for callers and also fixes a failure in the test
suite (and likely elsewhere in the code) by enabling "onelevel" and
"refspec-pattern" to be allowed independently of each other.

Also rename check_ref_format() to check_refname_format() to make it
obvious that it deals with refnames rather than references themselves.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git check-ref-format: add options --allow-onelevel and --refspec-pattern</title>
<updated>2011-10-05T20:45:29Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2011-09-15T21:10:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e4ed6105ec4a8507d4bd9f6355647fa911e4731f'/>
<id>urn:sha1:e4ed6105ec4a8507d4bd9f6355647fa911e4731f</id>
<content type='text'>
Also add tests of the new options.  (Actually, one big reason to add
the new options is to make it easy to test check_ref_format(), though
the options should also be useful to other scripts.)

Interpret the result of check_ref_format() based on which types of
refnames are allowed.  However, because check_ref_format() can only
return a single value, one test case is still broken.  Specifically,
the case "git check-ref-format --onelevel '*'" incorrectly succeeds
because check_ref_format() returns CHECK_REF_FORMAT_ONELEVEL for this
refname even though the refname is also CHECK_REF_FORMAT_WILDCARD.
The type of check that leads to this failure is used elsewhere in
"real" code and could lead to bugs; it will be fixed over the next few
commits.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
