<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/lockfile.c, branch v2.4.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.4.9</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2014-11-03T19:00:28Z</updated>
<entry>
<title>lockfile.c: store absolute path</title>
<updated>2014-11-03T19:00:28Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2014-11-02T06:24:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fa137f67a40bbcb3f583920586fdd34ce98ddeaf'/>
<id>urn:sha1:fa137f67a40bbcb3f583920586fdd34ce98ddeaf</id>
<content type='text'>
Locked paths can be saved in a linked list so that if something wrong
happens, *.lock are removed. For relative paths, this works fine if we
keep cwd the same, which is true 99% of time except:

- update-index and read-tree hold the lock on $GIT_DIR/index really
  early, then later on may call setup_work_tree() to move cwd.

- Suppose a lock is being held (e.g. by "git add") then somewhere
  down the line, somebody calls real_path (e.g. "link_alt_odb_entry"),
  which temporarily moves cwd away and back.

During that time when cwd is moved (either permanently or temporarily)
and we decide to die(), attempts to remove relative *.lock will fail,
and the next operation will complain that some files are still locked.

Avoid this case by turning relative paths to absolute before storing
the path in "filename" field.

Reported-by: Yue Lin Ho &lt;yuelinho777@gmail.com&gt;
Helped-by: Ramsay Jones &lt;ramsay@ramsay1.demon.co.uk&gt;
Helped-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Adapted-by: Michael Haggerty &lt;mhagger@alum.mit.edu&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: remove unable_to_lock_error</title>
<updated>2014-10-15T17:47:27Z</updated>
<author>
<name>Jonathan Nieder</name>
<email>jrnieder@gmail.com</email>
</author>
<published>2014-08-28T23:41:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fb43bd1cd187bcd29312df3b0394a457d524906d'/>
<id>urn:sha1:fb43bd1cd187bcd29312df3b0394a457d524906d</id>
<content type='text'>
The former caller uses unable_to_lock_message now.

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>
<entry>
<title>Merge branch 'mh/lockfile-stdio'</title>
<updated>2014-10-14T17:49:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-10-14T17:49:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=11cb3130d551590ae2dbd582e809763bfc353a47'/>
<id>urn:sha1:11cb3130d551590ae2dbd582e809763bfc353a47</id>
<content type='text'>
* mh/lockfile-stdio:
  commit_packed_refs(): reimplement using fdopen_lock_file()
  dump_marks(): reimplement using fdopen_lock_file()
  fdopen_lock_file(): access a lockfile using stdio
</content>
</entry>
<entry>
<title>Merge branch 'mh/lockfile'</title>
<updated>2014-10-14T17:49:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-10-14T17:49:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bd107e1052a11cf7dd6baf9077eab52fbb9d9c90'/>
<id>urn:sha1:bd107e1052a11cf7dd6baf9077eab52fbb9d9c90</id>
<content type='text'>
The lockfile API and its users have been cleaned up.

* mh/lockfile: (38 commits)
  lockfile.h: extract new header file for the functions in lockfile.c
  hold_locked_index(): move from lockfile.c to read-cache.c
  hold_lock_file_for_append(): restore errno before returning
  get_locked_file_path(): new function
  lockfile.c: rename static functions
  lockfile: rename LOCK_NODEREF to LOCK_NO_DEREF
  commit_lock_file_to(): refactor a helper out of commit_lock_file()
  trim_last_path_component(): replace last_path_elm()
  resolve_symlink(): take a strbuf parameter
  resolve_symlink(): use a strbuf for internal scratch space
  lockfile: change lock_file::filename into a strbuf
  commit_lock_file(): use a strbuf to manage temporary space
  try_merge_strategy(): use a statically-allocated lock_file object
  try_merge_strategy(): remove redundant lock_file allocation
  struct lock_file: declare some fields volatile
  lockfile: avoid transitory invalid states
  git_config_set_multivar_in_file(): avoid call to rollback_lock_file()
  dump_marks(): remove a redundant call to rollback_lock_file()
  api-lockfile: document edge cases
  commit_lock_file(): rollback lock file on failure to rename
  ...
</content>
</entry>
<entry>
<title>Merge branch 'sp/stream-clean-filter'</title>
<updated>2014-10-08T20:05:32Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-10-08T20:05:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f0d89001750a27c1c447b2eb3149b998521fa52c'/>
<id>urn:sha1:f0d89001750a27c1c447b2eb3149b998521fa52c</id>
<content type='text'>
When running a required clean filter, we do not have to mmap the
original before feeding the filter.  Instead, stream the file
contents directly to the filter and process its output.

* sp/stream-clean-filter:
  sha1_file: don't convert off_t to size_t too early to avoid potential die()
  convert: stream from fd to required clean filter to reduce used address space
  copy_fd(): do not close the input file descriptor
  mmap_limit: introduce GIT_MMAP_LIMIT to allow testing expected mmap size
  memory_limit: use git_env_ulong() to parse GIT_ALLOC_LIMIT
  config.c: add git_env_ulong() to parse environment variable
  convert: drop arguments other than 'path' from would_convert_to_git()
</content>
</entry>
<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>lockfile.h: extract new header file for the functions in lockfile.c</title>
<updated>2014-10-01T20:56:14Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=697cc8efd944a32ca472337cd6640004c474b788'/>
<id>urn:sha1:697cc8efd944a32ca472337cd6640004c474b788</id>
<content type='text'>
Move the interface declaration for the functions in lockfile.c from
cache.h to a new file, lockfile.h. Add #includes where necessary (and
remove some redundant includes of cache.h by files that already
include builtin.h).

Move the documentation of the lock_file state diagram from lockfile.c
to the new header file.

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>hold_locked_index(): move from lockfile.c to read-cache.c</title>
<updated>2014-10-01T20:54:31Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2014-10-01T10:28:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=216aab1e3d8eef088dc9785febce24a110e9f835'/>
<id>urn:sha1:216aab1e3d8eef088dc9785febce24a110e9f835</id>
<content type='text'>
lockfile.c contains the general API for locking any file. Code
specifically about the index file doesn't belong here.

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>hold_lock_file_for_append(): restore errno before returning</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:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4d423a3e62c7ab0b04c4bd84995c32daff3b24c3'/>
<id>urn:sha1:4d423a3e62c7ab0b04c4bd84995c32daff3b24c3</id>
<content type='text'>
Callers who don't pass LOCK_DIE_ON_ERROR might want to examine errno
to see what went wrong, so restore errno before returning.

In fact this function only has one caller, add_to_alternates_file(),
and it *does* use LOCK_DIE_ON_ERROR, but, you know, think of future
generations.

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>
</feed>
