summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-12-01 17:04:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-12-01 17:04:29 (GMT)
commita2b0451434db903975cb1dfda0eafef939ebc6db (patch)
tree95c12b249b5ec1d47d7eda8ecdd1b3606ac2c3ca /path.c
parent0be5caf97ce1ad5f3c10ac00875f9aaf4939339d (diff)
parent76a53d640f72fc77e7e9358dfeb5df5ece56515f (diff)
downloadgit-a2b0451434db903975cb1dfda0eafef939ebc6db.zip
git-a2b0451434db903975cb1dfda0eafef939ebc6db.tar.gz
git-a2b0451434db903975cb1dfda0eafef939ebc6db.tar.bz2
Merge branch 'js/git-path-head-dot-lock-fix'
"git rev-parse --git-path HEAD.lock" did not give the right path when run in a secondary worktree. * js/git-path-head-dot-lock-fix: git_path(): handle `.lock` files correctly t1400: wrap setup code in test case
Diffstat (limited to 'path.c')
-rw-r--r--path.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/path.c b/path.c
index e21b00c..0607156 100644
--- a/path.c
+++ b/path.c
@@ -11,6 +11,7 @@
#include "path.h"
#include "packfile.h"
#include "object-store.h"
+#include "lockfile.h"
static int get_st_mode_bits(const char *path, int *mode)
{
@@ -362,9 +363,14 @@ static void update_common_dir(struct strbuf *buf, int git_dir_len,
const char *common_dir)
{
char *base = buf->buf + git_dir_len;
+ int has_lock_suffix = strbuf_strip_suffix(buf, LOCK_SUFFIX);
+
init_common_trie();
if (trie_find(&common_trie, base, check_common, NULL) > 0)
replace_dir(buf, git_dir_len, common_dir);
+
+ if (has_lock_suffix)
+ strbuf_addstr(buf, LOCK_SUFFIX);
}
void report_linked_checkout_garbage(void)