Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/compat/fsmonitor/fsm-ipc-unix.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / compat / fsmonitor / fsm-ipc-unix.c` 59 lines ยท 1555 bytes Raw Blame History 1 #define USE_THE_REPOSITORY_VARIABLE 2 3 #include "git-compat-util.h" 4 #include "config.h" 5 #include "gettext.h" 6 #include "hex.h" 7 #include "path.h" 8 #include "repository.h" 9 #include "strbuf.h" 10 #include "fsmonitor-ll.h" 11 #include "fsmonitor-ipc.h" 12 #include "fsmonitor-path-utils.h" 13 14 static GIT_PATH_FUNC(fsmonitor_ipc__get_default_path, "fsmonitor--daemon.ipc") 15 16 const char *fsmonitor_ipc__get_path(struct repository *r) 17 { 18 static const char *ipc_path = NULL; 19 git_SHA_CTX sha1ctx; 20 char *sock_dir = NULL; 21 struct strbuf ipc_file = STRBUF_INIT; 22 unsigned char hash[GIT_SHA1_RAWSZ]; 23 24 if (!r) 25 BUG("No repository passed into fsmonitor_ipc__get_path"); 26 27 if (ipc_path) 28 return ipc_path; 29 30 31 /* By default the socket file is created in the .git directory */ 32 if (fsmonitor__is_fs_remote(r->gitdir) < 1) { 33 ipc_path = fsmonitor_ipc__get_default_path(); 34 return ipc_path; 35 } 36 37 git_SHA1_Init(&sha1ctx); 38 git_SHA1_Update(&sha1ctx, r->worktree, strlen(r->worktree)); 39 git_SHA1_Final(hash, &sha1ctx); 40 41 repo_config_get_string(r, "fsmonitor.socketdir", &sock_dir); 42 43 /* Create the socket file in either socketDir or $HOME */ 44 if (sock_dir && *sock_dir) { 45 strbuf_addf(&ipc_file, "%s/.git-fsmonitor-%s", 46 sock_dir, hash_to_hex_algop(hash, &hash_algos[GIT_HASH_SHA1])); 47 } else { 48 strbuf_addf(&ipc_file, "~/.git-fsmonitor-%s", 49 hash_to_hex_algop(hash, &hash_algos[GIT_HASH_SHA1])); 50 } 51 free(sock_dir); 52 53 ipc_path = interpolate_path(ipc_file.buf, 1); 54 if (!ipc_path) 55 die(_("Invalid path: %s"), ipc_file.buf); 56 57 strbuf_release(&ipc_file); 58 return ipc_path; 59 }