diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-07-07 11:18:26 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-07-07 11:18:26 -0700 |
commit | fcd91f8de20bf7969599a7a60cba73117d99f2d1 (patch) | |
tree | 41fe45b3c1cd2ef3f1b84cc1fdeff14468cd6997 /refs.c | |
parent | 0cc4da303641611e8d9cc431e7b4d3f1a6a0dc86 (diff) | |
parent | c30e742c4981585061ed52c14abd9ebd32a0e18b (diff) | |
download | git-fcd91f8de20bf7969599a7a60cba73117d99f2d1.tar.gz |
Merge branch 'maint'
* maint:
backmerge a few more fixes to 1.7.1.X series
rev-parse: fix --parse-opt --keep-dashdash --stop-at-non-option
fix git branch -m in presence of cross devices
Conflicts:
RelNotes
builtin/rev-parse.c
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -1090,6 +1090,15 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt) return ret; } +/* + * People using contrib's git-new-workdir have .git/logs/refs -> + * /some/other/path/.git/logs/refs, and that may live on another device. + * + * IOW, to avoid cross device rename errors, the temporary renamed log must + * live into logs/refs. + */ +#define TMP_RENAMED_LOG "logs/refs/.tmp-renamed-log" + int rename_ref(const char *oldref, const char *newref, const char *logmsg) { static const char renamed_ref[] = "RENAMED-REF"; @@ -1123,8 +1132,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) if (write_ref_sha1(lock, orig_sha1, logmsg)) return error("unable to save current sha1 in %s", renamed_ref); - if (log && rename(git_path("logs/%s", oldref), git_path("tmp-renamed-log"))) - return error("unable to move logfile logs/%s to tmp-renamed-log: %s", + if (log && rename(git_path("logs/%s", oldref), git_path(TMP_RENAMED_LOG))) + return error("unable to move logfile logs/%s to "TMP_RENAMED_LOG": %s", oldref, strerror(errno)); if (delete_ref(oldref, orig_sha1, REF_NODEREF)) { @@ -1150,7 +1159,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) } retry: - if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) { + if (log && rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", newref))) { if (errno==EISDIR || errno==ENOTDIR) { /* * rename(a, b) when b is an existing @@ -1163,7 +1172,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) } goto retry; } else { - error("unable to move logfile tmp-renamed-log to logs/%s: %s", + error("unable to move logfile "TMP_RENAMED_LOG" to logs/%s: %s", newref, strerror(errno)); goto rollback; } @@ -1203,8 +1212,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) error("unable to restore logfile %s from %s: %s", oldref, newref, strerror(errno)); if (!logmoved && log && - rename(git_path("tmp-renamed-log"), git_path("logs/%s", oldref))) - error("unable to restore logfile %s from tmp-renamed-log: %s", + rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", oldref))) + error("unable to restore logfile %s from "TMP_RENAMED_LOG": %s", oldref, strerror(errno)); return 1; |