diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-09-03 14:14:01 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-09-03 14:14:01 -0700 |
commit | 7662973ea38e39f2766a4403209189f263c914a3 (patch) | |
tree | 38d64a67067ae465a32e50e3b998c7d84c29c2fc /builtin | |
parent | Git 2.6-rc0 (diff) | |
parent | rerere: release lockfile in non-writing functions (diff) | |
download | tgif-7662973ea38e39f2766a4403209189f263c914a3.tar.xz |
Merge branch 'jk/am-rerere-lock-fix'
Recent "git am" introduced a double-locking failure when used with
the "--3way" option that invokes rerere machinery.
* jk/am-rerere-lock-fix:
rerere: release lockfile in non-writing functions
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/am.c | 5 | ||||
-rw-r--r-- | builtin/rerere.c | 18 |
2 files changed, 9 insertions, 14 deletions
diff --git a/builtin/am.c b/builtin/am.c index 27165a6730..83b3d86e67 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -2057,11 +2057,6 @@ static int clean_index(const unsigned char *head, const unsigned char *remote) static void am_rerere_clear(void) { struct string_list merge_rr = STRING_LIST_INIT_DUP; - int fd = setup_rerere(&merge_rr, 0); - - if (fd < 0) - return; - rerere_clear(&merge_rr); string_list_clear(&merge_rr, 1); } diff --git a/builtin/rerere.c b/builtin/rerere.c index 7afadd2ead..12535c9b4f 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -50,7 +50,7 @@ static int diff_two(const char *file1, const char *label1, int cmd_rerere(int argc, const char **argv, const char *prefix) { struct string_list merge_rr = STRING_LIST_INIT_DUP; - int i, fd, autoupdate = -1, flags = 0; + int i, autoupdate = -1, flags = 0; struct option options[] = { OPT_SET_INT(0, "rerere-autoupdate", &autoupdate, @@ -79,18 +79,16 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) return rerere_forget(&pathspec); } - fd = setup_rerere(&merge_rr, flags); - if (fd < 0) - return 0; - if (!strcmp(argv[0], "clear")) { rerere_clear(&merge_rr); } else if (!strcmp(argv[0], "gc")) rerere_gc(&merge_rr); - else if (!strcmp(argv[0], "status")) + else if (!strcmp(argv[0], "status")) { + if (setup_rerere(&merge_rr, flags | RERERE_READONLY) < 0) + return 0; for (i = 0; i < merge_rr.nr; i++) printf("%s\n", merge_rr.items[i].string); - else if (!strcmp(argv[0], "remaining")) { + } else if (!strcmp(argv[0], "remaining")) { rerere_remaining(&merge_rr); for (i = 0; i < merge_rr.nr; i++) { if (merge_rr.items[i].util != RERERE_RESOLVED) @@ -100,13 +98,15 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) * string_list_clear() */ merge_rr.items[i].util = NULL; } - } else if (!strcmp(argv[0], "diff")) + } else if (!strcmp(argv[0], "diff")) { + if (setup_rerere(&merge_rr, flags | RERERE_READONLY) < 0) + return 0; for (i = 0; i < merge_rr.nr; i++) { const char *path = merge_rr.items[i].string; const char *name = (const char *)merge_rr.items[i].util; diff_two(rerere_path(name, "preimage"), path, path, path); } - else + } else usage_with_options(rerere_usage, options); string_list_clear(&merge_rr, 1); |