mirror of
https://github.com/git/git.git
synced 2024-05-05 22:16:12 +02:00
object-name: move related functions to object-name
Move object-name-related functions from strbuf.[ch] to object-name.[ch] so that strbuf is focused on string manipulation routines with minimal dependencies. Signed-off-by: Calvin Wan <calvinwan@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
eaec86fb92
commit
d1272d1469
|
@ -766,6 +766,21 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad)
|
||||||
find_abbrev_len_for_pack(p, mad);
|
find_abbrev_len_for_pack(p, mad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
|
||||||
|
const struct object_id *oid, int abbrev_len)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
strbuf_grow(sb, GIT_MAX_HEXSZ + 1);
|
||||||
|
r = repo_find_unique_abbrev_r(repo, sb->buf + sb->len, oid, abbrev_len);
|
||||||
|
strbuf_setlen(sb, sb->len + r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
|
||||||
|
int abbrev_len)
|
||||||
|
{
|
||||||
|
strbuf_repo_add_unique_abbrev(sb, the_repository, oid, abbrev_len);
|
||||||
|
}
|
||||||
|
|
||||||
int repo_find_unique_abbrev_r(struct repository *r, char *hex,
|
int repo_find_unique_abbrev_r(struct repository *r, char *hex,
|
||||||
const struct object_id *oid, int len)
|
const struct object_id *oid, int len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,15 @@ struct object_context {
|
||||||
const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
|
const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
|
||||||
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
|
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
|
||||||
|
* the strbuf `sb`.
|
||||||
|
*/
|
||||||
|
void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
|
||||||
|
const struct object_id *oid, int abbrev_len);
|
||||||
|
void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
|
||||||
|
int abbrev_len);
|
||||||
|
|
||||||
int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
|
int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
|
||||||
__attribute__((format (printf, 2, 3)))
|
__attribute__((format (printf, 2, 3)))
|
||||||
int get_oidf(struct object_id *oid, const char *fmt, ...);
|
int get_oidf(struct object_id *oid, const char *fmt, ...);
|
||||||
|
|
1
pretty.c
1
pretty.c
|
@ -18,6 +18,7 @@
|
||||||
#include "gpg-interface.h"
|
#include "gpg-interface.h"
|
||||||
#include "trailer.h"
|
#include "trailer.h"
|
||||||
#include "run-command.h"
|
#include "run-command.h"
|
||||||
|
#include "object-name.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The limit for formatting directives, which enable the caller to append
|
* The limit for formatting directives, which enable the caller to append
|
||||||
|
|
16
strbuf.c
16
strbuf.c
|
@ -3,7 +3,6 @@
|
||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "hex.h"
|
#include "hex.h"
|
||||||
#include "object-name.h"
|
|
||||||
#include "refs.h"
|
#include "refs.h"
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
@ -1023,21 +1022,6 @@ void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm *tm,
|
||||||
strbuf_setlen(sb, sb->len + len);
|
strbuf_setlen(sb, sb->len + len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
|
|
||||||
const struct object_id *oid, int abbrev_len)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
strbuf_grow(sb, GIT_MAX_HEXSZ + 1);
|
|
||||||
r = repo_find_unique_abbrev_r(repo, sb->buf + sb->len, oid, abbrev_len);
|
|
||||||
strbuf_setlen(sb, sb->len + r);
|
|
||||||
}
|
|
||||||
|
|
||||||
void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
|
|
||||||
int abbrev_len)
|
|
||||||
{
|
|
||||||
strbuf_repo_add_unique_abbrev(sb, the_repository, oid, abbrev_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the length of a line, without trailing spaces.
|
* Returns the length of a line, without trailing spaces.
|
||||||
*
|
*
|
||||||
|
|
10
strbuf.h
10
strbuf.h
|
@ -616,16 +616,6 @@ void strbuf_add_separated_string_list(struct strbuf *str,
|
||||||
*/
|
*/
|
||||||
void strbuf_list_free(struct strbuf **list);
|
void strbuf_list_free(struct strbuf **list);
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
|
|
||||||
* the strbuf `sb`.
|
|
||||||
*/
|
|
||||||
struct repository;
|
|
||||||
void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
|
|
||||||
const struct object_id *oid, int abbrev_len);
|
|
||||||
void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
|
|
||||||
int abbrev_len);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove the filename from the provided path string. If the path
|
* Remove the filename from the provided path string. If the path
|
||||||
* contains a trailing separator, then the path is considered a directory
|
* contains a trailing separator, then the path is considered a directory
|
||||||
|
|
Loading…
Reference in New Issue