git-credential-store: support XDG_CONFIG_HOME
[git/git.git] / credential-store.c
index c519f80..d62dc29 100644 (file)
@@ -165,11 +165,16 @@ int main(int argc, char **argv)
                usage_with_options(usage, options);
        op = argv[0];
 
-       if (!file)
-               file = expand_user_path("~/.git-credentials");
-       if (file)
+       if (file) {
                string_list_append(&fns, file);
-       else
+       } else {
+               if ((file = expand_user_path("~/.git-credentials")))
+                       string_list_append_nodup(&fns, file);
+               home_config_paths(NULL, &file, "credentials");
+               if (file)
+                       string_list_append_nodup(&fns, file);
+       }
+       if (!fns.nr)
                die("unable to set up default path; use --file");
 
        if (credential_read(&c, stdin) < 0)