Skip to content
Snippets Groups Projects
Select Git revision
  • aa145bf6f1cb45ad66250c40da3cd708956cf71e
  • passt default
  • master
  • pu
  • todo
  • next
  • maint
  • v2.8.0-rc1
  • v2.8.0-rc0
  • v2.7.2
  • v2.7.1
  • v2.7.0
  • v2.6.5
  • v2.7.0-rc3
  • v2.7.0-rc2
  • v2.7.0-rc1
  • v2.7.0-rc0
  • v2.6.4
  • v2.6.3
  • v2.6.2
  • v2.6.1
  • v2.3.10
  • v2.5.4
  • v2.4.10
  • v2.6.0
  • v2.6.0-rc3
  • v2.5.3
27 results

commit.c

Blame
    • Junio C Hamano's avatar
      5a304dd3
      Merge branch 'nd/index-pack-no-recurse' · 5a304dd3
      Junio C Hamano authored
      * nd/index-pack-no-recurse:
        index-pack: eliminate unlimited recursion in get_base_data()
        index-pack: eliminate recursion in find_unresolved_deltas
        Eliminate recursion in setting/clearing marks in commit list
      5a304dd3
      History
      Merge branch 'nd/index-pack-no-recurse'
      Junio C Hamano authored
      * nd/index-pack-no-recurse:
        index-pack: eliminate unlimited recursion in get_base_data()
        index-pack: eliminate recursion in find_unresolved_deltas
        Eliminate recursion in setting/clearing marks in commit list
    credential.c 7.79 KiB
    #include "cache.h"
    #include "credential.h"
    #include "string-list.h"
    #include "run-command.h"
    #include "url.h"
    #include "prompt.h"
    
    void credential_init(struct credential *c)
    {
    	memset(c, 0, sizeof(*c));
    	c->helpers.strdup_strings = 1;
    }
    
    void credential_clear(struct credential *c)
    {
    	free(c->protocol);
    	free(c->host);
    	free(c->path);
    	free(c->username);
    	free(c->password);
    	string_list_clear(&c->helpers, 0);
    
    	credential_init(c);
    }
    
    int credential_match(const struct credential *want,
    		     const struct credential *have)
    {
    #define CHECK(x) (!want->x || (have->x && !strcmp(want->x, have->x)))
    	return CHECK(protocol) &&
    	       CHECK(host) &&
    	       CHECK(path) &&
    	       CHECK(username);
    #undef CHECK
    }
    
    static int credential_config_callback(const char *var, const char *value,
    				      void *data)
    {
    	struct credential *c = data;
    	const char *key, *dot;
    
    	if (!skip_prefix(var, "credential.", &key))
    		return 0;
    
    	if (!value)
    		return config_error_nonbool(var);
    
    	dot = strrchr(key, '.');
    	if (dot) {
    		struct credential want = CREDENTIAL_INIT;
    		char *url = xmemdupz(key, dot - key);
    		int matched;
    
    		credential_from_url(&want, url);
    		matched = credential_match(&want, c);
    
    		credential_clear(&want);
    		free(url);
    
    		if (!matched)
    			return 0;
    		key = dot + 1;
    	}
    
    	if (!strcmp(key, "helper")) {
    		if (*value)
    			string_list_append(&c->helpers, value);
    		else
    			string_list_clear(&c->helpers, 0);