<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/refs.c, branch v2.2.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v2.2.2</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v2.2.2'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2015-01-12T22:02:54Z</updated>
<entry>
<title>Merge branch 'jk/read-packed-refs-without-path-max' into maint</title>
<updated>2015-01-12T22:02:54Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-01-12T22:02:54Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=9f16184af5a1ccfbc05d7ec763d4b4e0469a326e'/>
<id>urn:sha1:9f16184af5a1ccfbc05d7ec763d4b4e0469a326e</id>
<content type='text'>
* jk/read-packed-refs-without-path-max:
  read_packed_refs: use skip_prefix instead of static array
  read_packed_refs: pass strbuf to parse_ref_line
  read_packed_refs: use a strbuf for reading lines
</content>
</entry>
<entry>
<title>Merge branch 'jk/for-each-reflog-ent-reverse' into maint</title>
<updated>2015-01-12T20:19:17Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-01-12T20:19:17Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=417a5b226ca70086a7a54bbb0914db53c32384c5'/>
<id>urn:sha1:417a5b226ca70086a7a54bbb0914db53c32384c5</id>
<content type='text'>
* jk/for-each-reflog-ent-reverse:
  for_each_reflog_ent_reverse: turn leftover check into assertion
  for_each_reflog_ent_reverse: fix newlines on block boundaries
</content>
</entry>
<entry>
<title>read_packed_refs: use skip_prefix instead of static array</title>
<updated>2014-12-10T17:40:33Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-12-10T10:40:36Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=ea417833ea9a07d7b8d568358ff20f57851cb26e'/>
<id>urn:sha1:ea417833ea9a07d7b8d568358ff20f57851cb26e</id>
<content type='text'>
We want to recognize the packed-refs header and skip to the
"traits" part of the line. We currently do it by feeding
sizeof() a static const array to strncmp. However, it's a
bit simpler to just skip_prefix, which expresses the
intention more directly, and without remembering to account
for the NUL-terminator in each sizeof() call.

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>read_packed_refs: pass strbuf to parse_ref_line</title>
<updated>2014-12-10T17:28:54Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-12-10T10:40:19Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=6a49870a7245934eac671e3dcd7186a90dac255d'/>
<id>urn:sha1:6a49870a7245934eac671e3dcd7186a90dac255d</id>
<content type='text'>
Now that we have a strbuf in read_packed_refs, we can pass
it straight to the line parser, which saves us an extra
strlen.

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>read_packed_refs: use a strbuf for reading lines</title>
<updated>2014-12-10T17:27:24Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-12-10T10:40:07Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=10c497aa0cc7ccb5bd213f53fc0cd803bd73a508'/>
<id>urn:sha1:10c497aa0cc7ccb5bd213f53fc0cd803bd73a508</id>
<content type='text'>
Current code uses a fixed PATH_MAX-sized buffer for reading
packed-refs lines. This is a reasonable guess, in the sense
that git generally cannot work with refs larger than
PATH_MAX.  However, there are a few cases where it is not
great:

  1. Some systems may have a low value of PATH_MAX, but can
     actually handle larger paths in practice. Fixing this
     code path probably isn't enough to make them work
     completely with long refs, but it is a step in the
     right direction.

  2. We use fgets, which will happily give us half a line on
     the first read, and then the rest of the line on the
     second. This is probably OK in practice, because our
     refline parser is careful enough to look for the
     trailing newline on the first line. The second line may
     look like a peeled line to us, but since "^" is illegal
     in refnames, it is not likely to come up.

     Still, it does not hurt to be more careful.

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>for_each_reflog_ent_reverse: turn leftover check into assertion</title>
<updated>2014-12-05T19:11:52Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-12-05T01:32:44Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=69216bf72be2be4f8aa932324b3145d3f395cdc6'/>
<id>urn:sha1:69216bf72be2be4f8aa932324b3145d3f395cdc6</id>
<content type='text'>
Our loop should always process all lines, even if we hit the
beginning of the file. We have a conditional after the loop
ends to double-check that there is nothing left and to
process it. But this should never happen, and is a sign of a
logic bug in the loop. Let's turn it into a BUG assertion.

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>for_each_reflog_ent_reverse: fix newlines on block boundaries</title>
<updated>2014-12-05T19:11:35Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-12-05T01:28:54Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=e5e73ff20b5a750b9622438fd877f4e4a4c3519b'/>
<id>urn:sha1:e5e73ff20b5a750b9622438fd877f4e4a4c3519b</id>
<content type='text'>
When we read a reflog file in reverse, we read whole chunks
of BUFSIZ bytes, then loop over the buffer, parsing any
lines we find. We find the beginning of each line by looking
for the newline from the previous line. If we don't find
one, we know that we are either at the beginning of
the file, or that we have to read another block.

In the latter case, we stuff away what we have into a
strbuf, read another block, and continue our parse. But we
missed one case here. If we did find a newline, and it is at
the beginning of the block, we must also stuff that newline
into the strbuf, as it belongs to the block we are about to
read.

The minimal fix here would be to add this special case to
the conditional that checks whether we found a newline.
But we can make the flow a little clearer by rearranging a
bit: we first handle lines that we are going to show, and
then at the end of each loop, stuff away any leftovers if
necessary. That lets us fold this special-case in with the
more common "we ended in the middle of a line" case.

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>Merge branch 'jk/fetch-reflog-df-conflict'</title>
<updated>2014-11-06T18:52:32Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-11-06T18:52:31Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=a1671dd82b5e1c6e837a3f47509a3a33189b0884'/>
<id>urn:sha1:a1671dd82b5e1c6e837a3f47509a3a33189b0884</id>
<content type='text'>
Corner-case bugfixes for "git fetch" around reflog handling.

* jk/fetch-reflog-df-conflict:
  ignore stale directories when checking reflog existence
  fetch: load all default config at startup
</content>
</entry>
<entry>
<title>ignore stale directories when checking reflog existence</title>
<updated>2014-11-04T20:18:44Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-11-04T13:24:53Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=9233887cce8eaebd8469315622b84bd26910351f'/>
<id>urn:sha1:9233887cce8eaebd8469315622b84bd26910351f</id>
<content type='text'>
When we update a ref, we have two rules for whether or not
we actually update the reflog:

  1. If the reflog already exists, we will always append to
     it.

  2. If log_all_ref_updates is set, we will create a new
     reflog file if necessary.

We do the existence check by trying to open the reflog file,
either with or without O_CREAT (depending on log_all_ref_updates).
If it fails, then we check errno to see what happened.

If we were not using O_CREAT and we got ENOENT, the file
doesn't exist, and we return success (there isn't a reflog
already, and we were not told to make a new one).

If we get EISDIR, then there is likely a stale directory
that needs to be removed (e.g., there used to be "foo/bar",
it was deleted, and the directory "foo" was left. Now we
want to create the ref "foo"). If O_CREAT is set, then we
catch this case, try to remove the directory, and retry our
open. So far so good.

But if we get EISDIR and O_CREAT is not set, then we treat
this as any other error, which is not right. Like ENOENT,
EISDIR is an indication that we do not have a reflog, and we
should silently return success (we were not told to create
it). Instead, the current code reports this as an error, and
we fail to update the ref at all.

Note that this is relatively unlikely to happen, as you
would have to have had reflogs turned on, and then later
turned them off (it could also happen due to a bug in fetch,
but that was fixed in the previous commit). However, it's
quite easy to fix: we just need to treat EISDIR like ENOENT
for the non-O_CREAT case, and silently return (note that
this early return means we can also simplify the O_CREAT
case).

Our new tests cover both cases (O_CREAT and non-O_CREAT).
The first one already worked, of course.

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>ref_transaction_commit: bail out on failure to remove a ref</title>
<updated>2014-10-15T17:47:27Z</updated>
<author>
<name>Jonathan Nieder</name>
<email>jrnieder@gmail.com</email>
</author>
<published>2014-08-29T00:01:35Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=65732845e89eee69422b725bb495f4282065284f'/>
<id>urn:sha1:65732845e89eee69422b725bb495f4282065284f</id>
<content type='text'>
When removal of a loose or packed ref fails, bail out instead of
trying to finish the transaction.  This way, a single error message
can be printed (instead of multiple messages being concatenated by
mistake) and the operator can try to solve the underlying problem
before there is a chance to muck things up even more.

In particular, when git fails to remove a ref, git goes on to try to
delete the reflog.  Exiting early lets us keep the reflog.

When git succeeds in deleting a ref A and fails to remove a ref B, it
goes on to try to delete both reflogs.  It would be better to just
remove the reflog for A, but that would be a more invasive change.
Failing early means we keep both reflogs, which puts the operator in a
good position to understand the problem and recover.

A long term goal is to avoid these problems altogether and roll back
the transaction on failure.  That kind of transactionality will have
to wait for a later series (the plan for which is to make all
destructive work happen in a single update of the packed-refs file).

Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Reviewed-by: Ronnie Sahlberg &lt;sahlberg@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
