@@ -111,11 +111,12 @@ static std::vector<int> make_version (int a, int b, int c)
111
111
return version;
112
112
}
113
113
114
- static void git_config (const std::string& name, const std::string& value)
114
+ static void git_config (const std::string& name, const std::string& value, bool from_worktree= true )
115
115
{
116
116
std::vector<std::string> command;
117
117
command.push_back (" git" );
118
118
command.push_back (" config" );
119
+ if (from_worktree) command.push_back (" --worktree" );
119
120
command.push_back (name);
120
121
command.push_back (value);
121
122
@@ -124,11 +125,12 @@ static void git_config (const std::string& name, const std::string& value)
124
125
}
125
126
}
126
127
127
- static bool git_has_config (const std::string& name)
128
+ static bool git_has_config (const std::string& name, bool from_worktree= true )
128
129
{
129
130
std::vector<std::string> command;
130
131
command.push_back (" git" );
131
132
command.push_back (" config" );
133
+ if (from_worktree) command.push_back (" --worktree" );
132
134
command.push_back (" --get-all" );
133
135
command.push_back (name);
134
136
@@ -140,11 +142,12 @@ static bool git_has_config (const std::string& name)
140
142
}
141
143
}
142
144
143
- static void git_deconfig (const std::string& name)
145
+ static void git_deconfig (const std::string& name, bool from_worktree= true )
144
146
{
145
147
std::vector<std::string> command;
146
148
command.push_back (" git" );
147
149
command.push_back (" config" );
150
+ if (from_worktree) command.push_back (" --worktree" );
148
151
command.push_back (" --remove-section" );
149
152
command.push_back (name);
150
153
@@ -277,12 +280,13 @@ static std::string get_internal_key_path (const char* key_name)
277
280
return path;
278
281
}
279
282
280
- std::string get_git_config (const std::string& name)
283
+ std::string get_git_config (const std::string& name, bool from_worktree= true )
281
284
{
282
285
// git config --get
283
286
std::vector<std::string> command;
284
287
command.push_back (" git" );
285
288
command.push_back (" config" );
289
+ if (from_worktree) command.push_back (" --worktree" );
286
290
command.push_back (" --get" );
287
291
command.push_back (name);
288
292
@@ -321,7 +325,7 @@ static std::string get_repo_state_path ()
321
325
}
322
326
323
327
// Check if the repo state dir has been explicitly configured. If so, use that in path construction.
324
- if (git_has_config (" git-crypt.repoStateDir" )) {
328
+ if (git_has_config (" git-crypt.repoStateDir" , false )) {
325
329
std::string repoStateDir = get_git_config (" git-crypt.repoStateDir" );
326
330
327
331
// The repoStateDir value must always be relative to git work tree to ensure the repoStateDir can be committed
0 commit comments