<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/refs, branch v2.26.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.26.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.26.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2020-01-31T21:03:45Z</updated>
<entry>
<title>C: use skip_prefix() to avoid hardcoded string length</title>
<updated>2020-01-31T21:03:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-01-30T19:35:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=145136a95a8755528aa012a4ce0ed50d1ec39e24'/>
<id>urn:sha1:145136a95a8755528aa012a4ce0ed50d1ec39e24</id>
<content type='text'>
We often skip an optional prefix in a string with a hardcoded
constant, e.g.

	if (starts_with(string, "prefix"))
		string += 6;

which is less error prone when written

	skip_prefix(string, "prefix", &amp;string);

Note that this changes a few error messages from "git reflog expire
--expire=nonsense.timestamp", which used to complain by saying

    '--expire=nonsense.timestamp' is not a valid timestamp

but with this change, we say

    'nonsense.timestamp' is not a valid timestamp

which is more technically correct (the string with --expire= as
a prefix obviously cannot be a valid timestamp, but the error is
about the part of the input without that prefix).

Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: pass NULL to refs_read_ref_full() because object ID is not needed</title>
<updated>2019-12-11T21:48:42Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2019-12-11T18:46:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e0ae2447d66aa3983837ddc3d6fc0c3371a8e350'/>
<id>urn:sha1:e0ae2447d66aa3983837ddc3d6fc0c3371a8e350</id>
<content type='text'>
refs_read_ref_full() wraps refs_resolve_ref_unsafe(), which handles a
NULL oid pointer of callers not interested in the resolved object ID.
Pass NULL from files_copy_or_rename_ref() to clarify that it is one
such caller.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Fix spelling errors in code comments</title>
<updated>2019-11-10T07:00:54Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2019-11-05T17:07:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=15beaaa3d1f6b555900446deb5e376b4f806d734'/>
<id>urn:sha1:15beaaa3d1f6b555900446deb5e376b4f806d734</id>
<content type='text'>
Reported-by: Jens Schleusener &lt;Jens.Schleusener@fossies.org&gt;
Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'sc/pack-refs-deletion-racefix'</title>
<updated>2019-08-22T19:34:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-08-22T19:34:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=207ad3cb203b7adeeb52b5372ace497e20739d49'/>
<id>urn:sha1:207ad3cb203b7adeeb52b5372ace497e20739d49</id>
<content type='text'>
"git pack-refs" can lose refs that are created while running, which
is getting corrected.

* sc/pack-refs-deletion-racefix:
  pack-refs: always refresh after taking the lock file
</content>
</entry>
<entry>
<title>dir-iterator: release strbuf after use</title>
<updated>2019-08-07T19:25:35Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2019-08-07T11:15:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9b7b0295f9521262b50143e580f4eb27b7bb83a7'/>
<id>urn:sha1:9b7b0295f9521262b50143e580f4eb27b7bb83a7</id>
<content type='text'>
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pack-refs: always refresh after taking the lock file</title>
<updated>2019-08-02T16:59:05Z</updated>
<author>
<name>Sun Chao</name>
<email>16657101987@163.com</email>
</author>
<published>2019-07-31T18:35:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a613d4f8176593e560628b174c3e10cfac3f6d58'/>
<id>urn:sha1:a613d4f8176593e560628b174c3e10cfac3f6d58</id>
<content type='text'>
When a packed ref is deleted, the whole packed-refs file is
rewritten to omit the ref that no longer exists. However if another
gc command is running and calls `pack-refs --all` simultaneously,
there is a chance that a ref that was just updated lose the newly
created commits.

Through these steps, losing commits on newly updated refs can be
demonstrated:

  # step 1: compile git without `USE_NSEC` option
  Some kernel releases do enable it by default while some do
  not. And if we compile git without `USE_NSEC`, it will be easier
  demonstrated by the following steps.

  # step 2: setup a repository and add the first commit
  git init repo &amp;&amp;
  (cd repo &amp;&amp;
   git config core.logallrefupdates true &amp;&amp;
   git commit --allow-empty -m foo)

  # step 3: in one terminal, repack the refs repeatedly
  cd repo &amp;&amp;
  while true
  do
    git pack-refs --all
  done

  # step 4: in another terminal, simultaneously update the
  # master with update-ref, and create and delete an
  # unrelated ref also with update-ref
  cd repo &amp;&amp;
  while true
  do
    us=$(git commit-tree -m foo -p HEAD HEAD^{tree}) &amp;&amp;
    git update-ref refs/heads/newbranch $us &amp;&amp;
    git update-ref refs/heads/master $us &amp;&amp;
    git update-ref -d refs/heads/newbranch &amp;&amp;
    them=$(git rev-parse master) &amp;&amp;
    if test "$them" != "$us"
    then
      echo &gt;&amp;2 "lost commit: $us"
      exit 1
    fi
    # eye candy
    printf .
  done

Though we have the packed-refs lock file and loose refs lock
files to avoid updating conflicts, a ref will lost its newly
commits if racy stat-validity of `packed-refs` file happens
(which is quite same as the racy-git described in
`Documentation/technical/racy-git.txt`), the following
specific set of operations demonstrates the problem:

  1. Call `pack-refs --all` to pack all the loose refs to
     packed-refs, and let say the modify time of the
     packed-refs is DATE_M.

  2. Call `update-ref` to update a new commit to master while
     it is already packed.  the old value (let us call it
     OID_A) remains in the packed-refs file and write the new
     value (let us call it OID_B) to $GIT_DIR/refs/heads/master.

  3. Call `update-ref -d` within the same DATE_M from the 1th
     step to delete a different ref newbranch which is packed
     in the packed-refs file. It check newbranch's oid from
     packed-refs file without locking it.

     Meanwhile it keeps a snapshot of the packed-refs file in
     memory and record the file's attributes with the snapshot.
     The oid of master in the packed-refs's snapshot is OID_A.

  4. Call a new `pack-refs --all` to pack the loose refs, the
     oid of master in packe-refs file is OID_B, and the loose
     refs $GIT_DIR/refs/heads/master is removed. Let's say
     the `pack-refs --all` is very quickly done and the new
     packed-refs file's modify time is still DATE_M, and it
     has the same file size, even the same inode.

  5. 3th step now goes on after checking the newbranch, it
     begin to rewrite the packed-refs file. After get the
     lock file of packed-ref file, it checks it's on-disk
     file attributes with the snapshot, suck as the timestamp,
     the file size and the inode value. If they are both the
     same values, and the snapshot is not refreshed.

     Because the loose ref of master is removed by 4th step,
     `update-ref -d` will updates the new packed-ref to disk
     which contains master with the oid OID_A. So now the
     newly commit OID_B of master is lost.

The best path forward is just always refreshing after take
the lock file of `packed-refs` file. Traditionally we avoided
that because refreshing it implied parsing the whole file.
But these days we mmap it, so it really is just an extra
open()/mmap() and a quick read of the header. That doesn't seem
like an outrageous cost to pay when we're already taking the lock.

Signed-off-by: Sun Chao &lt;sunchao9@huawei.com&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Sun Chao &lt;sunchao9@huawei.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>dir-iterator: add flags parameter to dir_iterator_begin</title>
<updated>2019-07-11T20:52:15Z</updated>
<author>
<name>Matheus Tavares</name>
<email>matheus.bernardino@usp.br</email>
</author>
<published>2019-07-10T23:59:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fa1da7d2eef0fedf0e5942028513912bf2bb64ed'/>
<id>urn:sha1:fa1da7d2eef0fedf0e5942028513912bf2bb64ed</id>
<content type='text'>
Add the possibility of giving flags to dir_iterator_begin to initialize
a dir-iterator with special options.

Currently possible flags are:
- DIR_ITERATOR_PEDANTIC, which makes dir_iterator_advance abort
immediately in the case of an error, instead of keep looking for the
next valid entry;
- DIR_ITERATOR_FOLLOW_SYMLINKS, which makes the iterator follow
symlinks and include linked directories' contents in the iteration.

These new flags will be used in a subsequent patch.

Also add tests for the flags' usage and adjust refs/files-backend.c to
the new dir_iterator_begin signature.

Signed-off-by: Matheus Tavares &lt;matheus.bernardino@usp.br&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>dir-iterator: refactor state machine model</title>
<updated>2019-07-11T20:52:15Z</updated>
<author>
<name>Matheus Tavares</name>
<email>matheus.bernardino@usp.br</email>
</author>
<published>2019-07-10T23:58:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3012397e0327f5e4dfd1d1183a792268429744ae'/>
<id>urn:sha1:3012397e0327f5e4dfd1d1183a792268429744ae</id>
<content type='text'>
dir_iterator_advance() is a large function with two nested loops. Let's
improve its readability factoring out three functions and simplifying
its mechanics. The refactored model will no longer depend on
level.initialized and level.dir_state to keep track of the iteration
state and will perform on a single loop.

Also, dir_iterator_begin() currently does not check if the given string
represents a valid directory path. Since the refactored model will have
to stat() the given path at initialization, let's also check for this
kind of error and make dir_iterator_begin() return NULL, on failures,
with errno appropriately set. And add tests for this new behavior.

Improve documentation at dir-iteration.h and code comments at
dir-iterator.c to reflect the changes and eliminate possible
ambiguities.

Finally, adjust refs/files-backend.c to check for now possible
dir_iterator_begin() failures.

Original-patch-by: Daniel Ferreira &lt;bnmvco@gmail.com&gt;
Signed-off-by: Matheus Tavares &lt;matheus.bernardino@usp.br&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/refs-double-abort'</title>
<updated>2019-04-16T10:28:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-16T10:28:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2e08c892a7037ce2c7dfe30134eb54a2825bf0be'/>
<id>urn:sha1:2e08c892a7037ce2c7dfe30134eb54a2825bf0be</id>
<content type='text'>
A corner case bug in the refs API has been corrected.

* jk/refs-double-abort:
  refs/files-backend: don't look at an aborted transaction
  refs/files-backend: handle packed transaction prepare failure
</content>
</entry>
<entry>
<title>Merge branch 'nd/rewritten-ref-is-per-worktree'</title>
<updated>2019-04-09T17:14:23Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-09T17:14:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=917f2cd1c2396c694ae956a1a26d9c92bf50b847'/>
<id>urn:sha1:917f2cd1c2396c694ae956a1a26d9c92bf50b847</id>
<content type='text'>
"git rebase" uses the refs/rewritten/ hierarchy to store its
intermediate states, which inherently makes the hierarchy per
worktree, but it didn't quite work well.

* nd/rewritten-ref-is-per-worktree:
  Make sure refs/rewritten/ is per-worktree
  files-backend.c: reduce duplication in add_per_worktree_entries_to_dir()
  files-backend.c: factor out per-worktree code in loose_fill_ref_dir()
</content>
</entry>
</feed>
