这篇教程C++ xstrfmt函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xstrfmt函数的典型用法代码示例。如果您正苦于以下问题:C++ xstrfmt函数的具体用法?C++ xstrfmt怎么用?C++ xstrfmt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xstrfmt函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: xcallocstatic struct complete_reflogs *read_complete_reflog(const char *ref){ struct complete_reflogs *reflogs = xcalloc(1, sizeof(struct complete_reflogs)); reflogs->ref = xstrdup(ref); for_each_reflog_ent(ref, read_one_reflog, reflogs); if (reflogs->nr == 0) { struct object_id oid; const char *name; void *name_to_free; name = name_to_free = resolve_refdup(ref, RESOLVE_REF_READING, oid.hash, NULL); if (name) { for_each_reflog_ent(name, read_one_reflog, reflogs); free(name_to_free); } } if (reflogs->nr == 0) { char *refname = xstrfmt("refs/%s", ref); for_each_reflog_ent(refname, read_one_reflog, reflogs); if (reflogs->nr == 0) { free(refname); refname = xstrfmt("refs/heads/%s", ref); for_each_reflog_ent(refname, read_one_reflog, reflogs); } free(refname); } return reflogs;}
开发者ID:basilgor,项目名称:git,代码行数:29,
示例2: name_revstatic void name_rev(struct commit *commit, const char *tip_name, int generation, int distance, int deref){ struct rev_name *name = (struct rev_name *)commit->util; struct commit_list *parents; int parent_number = 1; parse_commit(commit); if (commit->date < cutoff) return; if (deref) { tip_name = xstrfmt("%s^0", tip_name); if (generation) die("generation: %d, but deref?", generation); } if (name == NULL) { name = xmalloc(sizeof(rev_name)); commit->util = name; goto copy_data; } else if (name->distance > distance) {copy_data: name->tip_name = tip_name; name->generation = generation; name->distance = distance; } else return; for (parents = commit->parents; parents; parents = parents->next, parent_number++) { if (parent_number > 1) { size_t len; char *new_name; strip_suffix(tip_name, "^0", &len); if (generation > 0) new_name = xstrfmt("%.*s~%d^%d", (int)len, tip_name, generation, parent_number); else new_name = xstrfmt("%.*s^%d", (int)len, tip_name, parent_number); name_rev(parents->item, new_name, 0, distance + MERGE_TRAVERSAL_WEIGHT, 0); } else { name_rev(parents->item, tip_name, generation + 1, distance + 1, 0); } }}
开发者ID:0369,项目名称:git,代码行数:55,
示例3: bisect_next_checkstatic int bisect_next_check(const struct bisect_terms *terms, const char *current_term){ int missing_good = 1, missing_bad = 1, retval = 0; const char *bad_ref = xstrfmt("refs/bisect/%s", terms->term_bad); const char *good_glob = xstrfmt("%s-*", terms->term_good); if (ref_exists(bad_ref)) missing_bad = 0; for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/", (void *) &missing_good); if (!missing_good && !missing_bad) goto finish; if (!current_term) { retval = -1; goto finish; } if (missing_good && !missing_bad && !strcmp(current_term, terms->term_good)) { char *yesno; /* * have bad (or new) but not good (or old). We could bisect * although this is less optimum. */ warning(_("bisecting only with a %s commit"), terms->term_bad); if (!isatty(0)) goto finish; /* * TRANSLATORS: Make sure to include [Y] and [n] in your * translation. The program will only accept English input * at this point. */ yesno = git_prompt(_("Are you sure [Y/n]? "), PROMPT_ECHO); if (starts_with(yesno, "N") || starts_with(yesno, "n")) retval = -1; goto finish; } if (!is_empty_or_missing_file(git_path_bisect_start())) { retval = error(_(need_bad_and_good_revision_warning), vocab_bad, vocab_good, vocab_bad, vocab_good); } else { retval = error(_(need_bisect_start_warning), vocab_good, vocab_bad, vocab_good, vocab_bad); }finish: free((void *) good_glob); free((void *) bad_ref); return retval;}
开发者ID:bk2204,项目名称:git,代码行数:54,
示例4: check_term_formatstatic int check_term_format(const char *term, const char *orig_term){ int res; char *new_term = xstrfmt("refs/bisect/%s", term); res = check_refname_format(new_term, 0); free(new_term); if (res) return error(_("'%s' is not a valid term"), term); if (one_of(term, "help", "start", "skip", "next", "reset", "visualize", "view", "replay", "log", "run", "terms", NULL)) return error(_("can't use the builtin command '%s' as a term"), term); /* * In theory, nothing prevents swapping completely good and bad, * but this situation could be confusing and hasn't been tested * enough. Forbid it for now. */ if ((strcmp(orig_term, "bad") && one_of(term, "bad", "new", NULL)) || (strcmp(orig_term, "good") && one_of(term, "good", "old", NULL))) return error(_("can't change the meaning of the term '%s'"), term); return 0;}
开发者ID:bk2204,项目名称:git,代码行数:27,
示例5: xmalloc/* * Normalize "path", prepending the "prefix" for relative paths. If * remaining_prefix is not NULL, return the actual prefix still * remains in the path. For example, prefix = sub1/sub2/ and path is * * foo -> sub1/sub2/foo (full prefix) * ../foo -> sub1/foo (remaining prefix is sub1/) * ../../bar -> bar (no remaining prefix) * ../../sub1/sub2/foo -> sub1/sub2/foo (but no remaining prefix) * `pwd`/../bar -> sub1/bar (no remaining prefix) */char *prefix_path_gently(const char *prefix, int len, int *remaining_prefix, const char *path){ const char *orig = path; char *sanitized; if (is_absolute_path(orig)) { sanitized = xmalloc(strlen(path) + 1); if (remaining_prefix) *remaining_prefix = 0; if (normalize_path_copy_len(sanitized, path, remaining_prefix)) { free(sanitized); return NULL; } if (abspath_part_inside_repo(sanitized)) { free(sanitized); return NULL; } } else { sanitized = xstrfmt("%.*s%s", len, prefix, path); if (remaining_prefix) *remaining_prefix = len; if (normalize_path_copy_len(sanitized, sanitized, remaining_prefix)) { free(sanitized); return NULL; } } return sanitized;}
开发者ID:jiangxilong,项目名称:git,代码行数:39,
示例6: list_tagsstatic int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, const char *format){ struct ref_array array; char *to_free = NULL; int i; memset(&array, 0, sizeof(array)); if (filter->lines == -1) filter->lines = 0; if (!format) { if (filter->lines) { to_free = xstrfmt("%s %%(contents:lines=%d)", "%(align:15)%(refname:strip=2)%(end)", filter->lines); format = to_free; } else format = "%(refname:strip=2)"; } verify_ref_format(format); filter->with_commit_tag_algo = 1; filter_refs(&array, filter, FILTER_REFS_TAGS); ref_array_sort(sorting, &array); for (i = 0; i < array.nr; i++) show_ref_array_item(array.items[i], format, 0); ref_array_clear(&array); free(to_free); return 0;}
开发者ID:136357477,项目名称:git,代码行数:33,
示例7: get_messagestatic int get_message(struct commit *commit, struct commit_message *out){ const char *abbrev, *subject; int subject_len; out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding()); abbrev = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV); subject_len = find_commit_subject(out->message, &subject); out->subject = xmemdupz(subject, subject_len); out->label = xstrfmt("%s... %s", abbrev, out->subject); out->parent_label = xstrfmt("parent of %s", out->label); return 0;}
开发者ID:64octets,项目名称:git,代码行数:16,
示例8: fetch_symrefstatic void fetch_symref(const char *path, char **symref, struct object_id *oid){ char *url = xstrfmt("%s%s", repo->url, path); struct strbuf buffer = STRBUF_INIT; const char *name; if (http_get_strbuf(url, &buffer, NULL) != HTTP_OK) die("Couldn't get %s for remote symref/n%s", url, curl_errorstr); free(url); FREE_AND_NULL(*symref); oidclr(oid); if (buffer.len == 0) return; /* Cut off trailing newline. */ strbuf_rtrim(&buffer); /* If it's a symref, set the refname; otherwise try for a sha1 */ if (skip_prefix(buffer.buf, "ref: ", &name)) { *symref = xmemdupz(name, buffer.len - (name - buffer.buf)); } else { get_oid_hex(buffer.buf, oid); } strbuf_release(&buffer);}
开发者ID:ro-ot,项目名称:git,代码行数:29,
示例9: name_revstatic void name_rev(struct commit *commit, const char *tip_name, int generation, int distance, int deref){ struct rev_name *name = (struct rev_name *)commit->util; struct commit_list *parents; int parent_number = 1; parse_commit(commit); if (commit->date < cutoff) return; if (deref) { tip_name = xstrfmt("%s^0", tip_name); if (generation) die("generation: %d, but deref?", generation); } if (name == NULL) { name = xmalloc(sizeof(rev_name)); commit->util = name; goto copy_data; } else if (name->distance > distance) {copy_data: name->tip_name = tip_name; name->generation = generation; name->distance = distance; } else return; for (parents = commit->parents; parents; parents = parents->next, parent_number++) { if (parent_number > 1) { int len = strlen(tip_name); char *new_name = xmalloc(len + 1 + decimal_length(generation) + /* ~<n> */ 1 + 2 + /* ^NN */ 1); if (len > 2 && !strcmp(tip_name + len - 2, "^0")) len -= 2; if (generation > 0) sprintf(new_name, "%.*s~%d^%d", len, tip_name, generation, parent_number); else sprintf(new_name, "%.*s^%d", len, tip_name, parent_number); name_rev(parents->item, new_name, 0, distance + MERGE_TRAVERSAL_WEIGHT, 0); } else { name_rev(parents->item, tip_name, generation + 1, distance + 1, 0); } }}
开发者ID:2quala,项目名称:git,代码行数:59,
示例10: setup_unpack_trees_porcelainvoid setup_unpack_trees_porcelain(struct unpack_trees_options *opts, const char *cmd){ int i; const char **msgs = opts->msgs; const char *msg; const char *cmd2 = strcmp(cmd, "checkout") ? cmd : "switch branches"; if (advice_commit_before_merge) msg = "Your local changes to the following files would be overwritten by %s:/n%%s" "Please, commit your changes or stash them before you can %s."; else msg = "Your local changes to the following files would be overwritten by %s:/n%%s"; msgs[ERROR_WOULD_OVERWRITE] = msgs[ERROR_NOT_UPTODATE_FILE] = xstrfmt(msg, cmd, cmd2); msgs[ERROR_NOT_UPTODATE_DIR] = "Updating the following directories would lose untracked files in it:/n%s"; if (advice_commit_before_merge) msg = "The following untracked working tree files would be %s by %s:/n%%s" "Please move or remove them before you can %s."; else msg = "The following untracked working tree files would be %s by %s:/n%%s"; msgs[ERROR_WOULD_LOSE_UNTRACKED_REMOVED] = xstrfmt(msg, "removed", cmd, cmd2); msgs[ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN] = xstrfmt(msg, "overwritten", cmd, cmd2); /* * Special case: ERROR_BIND_OVERLAP refers to a pair of paths, we * cannot easily display it as a list. */ msgs[ERROR_BIND_OVERLAP] = "Entry '%s' overlaps with '%s'. Cannot bind."; msgs[ERROR_SPARSE_NOT_UPTODATE_FILE] = "Cannot update sparse checkout: the following entries are not up-to-date:/n%s"; msgs[ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN] = "The following Working tree files would be overwritten by sparse checkout update:/n%s"; msgs[ERROR_WOULD_LOSE_ORPHANED_REMOVED] = "The following Working tree files would be removed by sparse checkout update:/n%s"; opts->show_all_errors = 1; /* rejected paths may not have a static buffer */ for (i = 0; i < ARRAY_SIZE(opts->unpack_rejects); i++) opts->unpack_rejects[i].strdup_strings = 1;}
开发者ID:2quala,项目名称:git,代码行数:46,
示例11: expand_base_dirstatic void expand_base_dir(char **out, const char *in, const char *base_dir, const char *def_in){ free(*out); if (in) *out = xstrdup(in); else *out = xstrfmt("%s/%s", base_dir, def_in);}
开发者ID:DoWonJin,项目名称:git,代码行数:9,
示例12: getenvstatic char *git_path_from_env(const char *envvar, const char *git_dir, const char *path, int fromenv){ if (fromenv) { const char *value = getenv(envvar); if (value) return xstrdup(value); } return xstrfmt("%s/%s", git_dir, path);}
开发者ID:alexcomplex,项目名称:git,代码行数:11,
示例13: show_datestringstatic void show_datestring(const char *flag, const char *datestr){ char *buffer; /* date handling requires both flags and revs */ if ((filter & (DO_FLAGS | DO_REVS)) != (DO_FLAGS | DO_REVS)) return; buffer = xstrfmt("%s%"PRItime, flag, approxidate(datestr)); show(buffer); free(buffer);}
开发者ID:guban,项目名称:git,代码行数:11,
示例14: xstrfmtconst char *unique_tracking_name(const char *name, struct object_id *oid){ struct tracking_name_data cb_data = { NULL, NULL, NULL, 1 }; cb_data.src_ref = xstrfmt("refs/heads/%s", name); cb_data.dst_oid = oid; for_each_remote(check_tracking_name, &cb_data); free(cb_data.src_ref); if (cb_data.unique) return cb_data.dst_ref; free(cb_data.dst_ref); return NULL;}
开发者ID:DoWonJin,项目名称:git,代码行数:12,
示例15: expand_user_pathstatic char *get_socket_path(void){ struct stat sb; char *old_dir, *socket; old_dir = expand_user_path("~/.git-credential-cache", 0); if (old_dir && !stat(old_dir, &sb) && S_ISDIR(sb.st_mode)) socket = xstrfmt("%s/socket", old_dir); else socket = xdg_cache_home("credential/socket"); free(old_dir); return socket;}
开发者ID:Litttle-butterfly,项目名称:git,代码行数:12,
示例16: match_trees/* * Match one itself and its subtrees with two and pick the best match. */static void match_trees(const unsigned char *hash1, const unsigned char *hash2, int *best_score, char **best_match, const char *base, int recurse_limit){ struct tree_desc one; void *one_buf = fill_tree_desc_strict(&one, hash1); while (one.size) { const char *path; const unsigned char *elem; unsigned mode; int score; elem = tree_entry_extract(&one, &path, &mode); if (!S_ISDIR(mode)) goto next; score = score_trees(elem, hash2); if (*best_score < score) { free(*best_match); *best_match = xstrfmt("%s%s", base, path); *best_score = score; } if (recurse_limit) { char *newbase = xstrfmt("%s%s/", base, path); match_trees(elem, hash2, best_score, best_match, newbase, recurse_limit - 1); free(newbase); } next: update_tree_entry(&one); } free(one_buf);}
开发者ID:0369,项目名称:git,代码行数:40,
示例17: log_commitstatic void log_commit(FILE *fp, char *fmt, const char *state, struct commit *commit){ struct pretty_print_context pp = {0}; struct strbuf commit_msg = STRBUF_INIT; char *label = xstrfmt(fmt, state); format_commit_message(commit, "%s", &commit_msg, &pp); fprintf(fp, "# %s: [%s] %s/n", label, oid_to_hex(&commit->object.oid), commit_msg.buf); strbuf_release(&commit_msg); free(label);}
开发者ID:bk2204,项目名称:git,代码行数:15,
示例18: repo_submodule_init/* * Initialize 'submodule' as the submodule given by 'path' in parent repository * 'superproject'. * Return 0 upon success and a non-zero value upon failure. */int repo_submodule_init(struct repository *submodule, struct repository *superproject, const char *path){ const struct submodule *sub; struct strbuf gitdir = STRBUF_INIT; struct strbuf worktree = STRBUF_INIT; int ret = 0; sub = submodule_from_path(superproject, &null_oid, path); if (!sub) { ret = -1; goto out; } strbuf_repo_worktree_path(&gitdir, superproject, "%s/.git", path); strbuf_repo_worktree_path(&worktree, superproject, "%s", path); if (repo_init(submodule, gitdir.buf, worktree.buf)) { /* * If initilization fails then it may be due to the submodule * not being populated in the superproject's worktree. Instead * we can try to initilize the submodule by finding it's gitdir * in the superproject's 'modules' directory. In this case the * submodule would not have a worktree. */ strbuf_reset(&gitdir); strbuf_repo_git_path(&gitdir, superproject, "modules/%s", sub->name); if (repo_init(submodule, gitdir.buf, NULL)) { ret = -1; goto out; } } submodule->submodule_prefix = xstrfmt("%s%s/", superproject->submodule_prefix ? superproject->submodule_prefix : "", path);out: strbuf_release(&gitdir); strbuf_release(&worktree); return ret;}
开发者ID:DoWonJin,项目名称:git,代码行数:51,
示例19: tail_match/* * Is there one among the list of patterns that match the tail part * of the path? */static int tail_match(const char **pattern, const char *path){ const char *p; char *pathbuf; if (!pattern) return 1; /* no restriction */ pathbuf = xstrfmt("/%s", path); while ((p = *(pattern++)) != NULL) { if (!wildmatch(p, pathbuf, 0, NULL)) { free(pathbuf); return 1; } } free(pathbuf); return 0;}
开发者ID:avar,项目名称:git,代码行数:22,
示例20: fsck_handle_reflog_oidstatic void fsck_handle_reflog_oid(const char *refname, struct object_id *oid, timestamp_t timestamp){ struct object *obj; if (!is_null_oid(oid)) { obj = lookup_object(oid->hash); if (obj && (obj->flags & HAS_OBJ)) { if (timestamp && name_objects) add_decoration(fsck_walk_options.object_names, obj, xstrfmt("%[email C++ xstrlen函数代码示例 C++ xstrerror函数代码示例
|