<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/Documentation/technical/api-lockfile.txt, branch v2.3.4</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.3.4</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.3.4'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2014-10-01T21:08:10Z</updated>
<entry>
<title>fdopen_lock_file(): access a lockfile using stdio</title>
<updated>2014-10-01T21:08:10Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T11:14:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=013870cd2cb1b0d6719a7a9123e126a62426520b'/>
<id>urn:sha1:013870cd2cb1b0d6719a7a9123e126a62426520b</id>
<content type='text'>
Add a new function, fdopen_lock_file(), which returns a FILE pointer
open to the lockfile. If a stream is open on a lock_file object, it is
closed using fclose() on commit, rollback, or close_lock_file().

This change will allow callers to use stdio to write to a lockfile
without having to muck around in the internal representation of the
lock_file object (callers will be rewritten in upcoming 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>
<entry>
<title>get_locked_file_path(): new function</title>
<updated>2014-10-01T20:53:54Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ec38b4e482e96e62762452cab5714e55abdb48c3'/>
<id>urn:sha1:ec38b4e482e96e62762452cab5714e55abdb48c3</id>
<content type='text'>
Add a function to return the path of the file that is locked by a
lock_file object. This reduces the knowledge that callers have to have
about the lock_file layout.

Suggested-by: Ronnie Sahlberg &lt;sahlberg@google.com&gt;
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>lockfile: rename LOCK_NODEREF to LOCK_NO_DEREF</title>
<updated>2014-10-01T20:53:28Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=47ba4662bfd755829edd24428cf2e4bc492d70a6'/>
<id>urn:sha1:47ba4662bfd755829edd24428cf2e4bc492d70a6</id>
<content type='text'>
This makes it harder to misread the name as LOCK_NODE_REF.

Suggested-by: Torsten Bögershausen &lt;tboegi@web.de&gt;
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>commit_lock_file_to(): refactor a helper out of commit_lock_file()</title>
<updated>2014-10-01T20:52:06Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=751bacedaa507b7b6d10b2c1f48e019a01a8fa6e'/>
<id>urn:sha1:751bacedaa507b7b6d10b2c1f48e019a01a8fa6e</id>
<content type='text'>
commit_locked_index(), when writing to an alternate index file,
duplicates (poorly) the code in commit_lock_file(). And anyway, it
shouldn't have to know so much about the internal workings of lockfile
objects. So extract a new function commit_lock_file_to() that does the
work common to the two functions, and call it from both
commit_lock_file() and commit_locked_index().

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>api-lockfile: document edge cases</title>
<updated>2014-10-01T20:45:14Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d75145acf6d17eb9b0f9d7d8856e523038081311'/>
<id>urn:sha1:d75145acf6d17eb9b0f9d7d8856e523038081311</id>
<content type='text'>
* Document the behavior of commit_lock_file() when it fails, namely
  that it rolls back the lock_file object and sets errno
  appropriately.

* Document the behavior of rollback_lock_file() when called for a
  lock_file object that has already been committed or rolled back,
  namely that it is a NOOP.

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>close_lock_file(): if close fails, roll back</title>
<updated>2014-10-01T20:45:13Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8e86c155d2962f5dff83c9d0d88b836bf040c1fa'/>
<id>urn:sha1:8e86c155d2962f5dff83c9d0d88b836bf040c1fa</id>
<content type='text'>
If closing an open lockfile fails, then we cannot be sure of the
contents of the lockfile, so there is nothing sensible to do but
delete it. This change also insures that the lock_file object is left
in a defined state in this error path (namely, unlocked).

The only caller that is ultimately affected by this change is
try_merge_strategy() -&gt; write_locked_index(), which can call
close_lock_file() via various execution paths. This caller uses a
static lock_file object which previously could have been reused after
a failed close_lock_file() even though it was still in locked state.
This change causes the lock_file object to be unlocked on failure,
thus fixing this error-handling path.

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>commit_lock_file(): die() if called for unlocked lockfile object</title>
<updated>2014-10-01T20:45:13Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8a1c7533e2ee468a505656abab364780b15004fc'/>
<id>urn:sha1:8a1c7533e2ee468a505656abab364780b15004fc</id>
<content type='text'>
It was previously a bug to call commit_lock_file() with a lock_file
object that was not active (an illegal access would happen within the
function).  It was presumably never done, but this would be an easy
programming error to overlook.  So before continuing, do a consistency
check that the lock_file object really is locked.

Helped-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
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>api-lockfile: revise and expand the documentation</title>
<updated>2014-10-01T20:38:38Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a5e48669a2bb45e3a2a6daf30635270b90056085'/>
<id>urn:sha1:a5e48669a2bb45e3a2a6daf30635270b90056085</id>
<content type='text'>
Document a couple more functions and the flags argument as used by
hold_lock_file_for_update() and hold_lock_file_for_append().
Reorganize the document to make it more accessible.

Helped-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Helped-by: Junio Hamano &lt;gitster@pobox.com&gt;
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>close_lock_file(): new function in the lockfile API</title>
<updated>2008-01-16T23:35:03Z</updated>
<author>
<name>Brandon Casey</name>
<email>casey@nrlssc.navy.mil</email>
</author>
<published>2008-01-16T19:05:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d6cf61bfd4bccffcc8b095f8469dbe749d70abdf'/>
<id>urn:sha1:d6cf61bfd4bccffcc8b095f8469dbe749d70abdf</id>
<content type='text'>
The lockfile API is a handy way to obtain a file that is cleaned
up if you die().  But sometimes you would need this sequence to
work:

 1. hold_lock_file_for_update() to get a file descriptor for
    writing;

 2. write the contents out, without being able to decide if the
    results should be committed or rolled back;

 3. do something else that makes the decision --- and this
    "something else" needs the lockfile not to have an open file
    descriptor for writing (e.g. Windows do not want a open file
    to be renamed);

 4. call commit_lock_file() or rollback_lock_file() as
    appropriately.

This adds close_lock_file() you can call between step 2 and 3 in
the above sequence.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Document lockfile API</title>
<updated>2008-01-16T20:42:37Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2008-01-16T19:00:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0c0478cac87991bd555e81715e9332d11eecd881'/>
<id>urn:sha1:0c0478cac87991bd555e81715e9332d11eecd881</id>
<content type='text'>
We have nice set of placeholders, but nobody stepped in to fill
the gap in the API documentation, so I am doing it myself.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
