]> granicus.if.org Git - git/commitdiff
Merge branch 'mh/lockfile'
authorJunio C Hamano <gitster@pobox.com>
Tue, 14 Oct 2014 17:49:45 +0000 (10:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 14 Oct 2014 17:49:45 +0000 (10:49 -0700)
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
  ...

1  2 
builtin/receive-pack.c
cache.h
config.c
lockfile.c
merge-recursive.c
sha1_file.c

Simple merge
diff --cc cache.h
Simple merge
diff --cc config.c
Simple merge
diff --cc lockfile.c
index d34a96df4f859feeaa7597abba374128ff9dc598,d27e61cafcfd2a8277e67edddaf41c29065babee..7bfec4b773bc710b474677b808c4bdacf53af91b
@@@ -216,19 -193,23 +193,26 @@@ int hold_lock_file_for_append(struct lo
        orig_fd = open(path, O_RDONLY);
        if (orig_fd < 0) {
                if (errno != ENOENT) {
+                       int save_errno = errno;
                        if (flags & LOCK_DIE_ON_ERROR)
                                die("cannot open '%s' for copying", path);
-                       close(fd);
-                       return error("cannot open '%s' for copying", path);
+                       rollback_lock_file(lk);
+                       error("cannot open '%s' for copying", path);
+                       errno = save_errno;
+                       return -1;
                }
        } else if (copy_fd(orig_fd, fd)) {
+               int save_errno = errno;
                if (flags & LOCK_DIE_ON_ERROR)
                        exit(128);
-               close(fd);
 +              close(orig_fd);
+               rollback_lock_file(lk);
+               errno = save_errno;
                return -1;
 +      } else {
 +              close(orig_fd);
        }
        return fd;
  }
index 9fc71a2391bff6c718cab39865371d2b43bf15a0,4b0884b7bbdf177d6cfa2d07d3888cd212ec8a62..fdb7d0f10ba471bcdff26dc87851d7df34fdc971
@@@ -3,8 -3,9 +3,9 @@@
   * Fredrik Kuivinen.
   * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
   */
 -#include "advice.h"
  #include "cache.h"
 +#include "advice.h"
+ #include "lockfile.h"
  #include "cache-tree.h"
  #include "commit.h"
  #include "blob.h"
diff --cc sha1_file.c
Simple merge