提交 1928c944 编写于 作者: B brian m. carlson 提交者: Junio C Hamano

builtin/update-index: convert to using the_hash_algo

Switch from using GIT_SHA1_HEXSZ to the_hash_algo to make the parsing of
the index information hash independent.
Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 2ae2e2a1
......@@ -492,6 +492,7 @@ static void update_one(const char *path)
static void read_index_info(int nul_term_line)
{
const int hexsz = the_hash_algo->hexsz;
struct strbuf buf = STRBUF_INIT;
struct strbuf uq = STRBUF_INIT;
strbuf_getline_fn getline_fn;
......@@ -529,7 +530,7 @@ static void read_index_info(int nul_term_line)
mode = ul;
tab = strchr(ptr, '\t');
if (!tab || tab - ptr < GIT_SHA1_HEXSZ + 1)
if (!tab || tab - ptr < hexsz + 1)
goto bad_line;
if (tab[-2] == ' ' && '0' <= tab[-1] && tab[-1] <= '3') {
......@@ -542,8 +543,8 @@ static void read_index_info(int nul_term_line)
ptr = tab + 1; /* point at the head of path */
}
if (get_oid_hex(tab - GIT_SHA1_HEXSZ, &oid) ||
tab[-(GIT_SHA1_HEXSZ + 1)] != ' ')
if (get_oid_hex(tab - hexsz, &oid) ||
tab[-(hexsz + 1)] != ' ')
goto bad_line;
path_name = ptr;
......@@ -571,7 +572,7 @@ static void read_index_info(int nul_term_line)
* ptr[-1] points at tab,
* ptr[-41] is at the beginning of sha1
*/
ptr[-(GIT_SHA1_HEXSZ + 2)] = ptr[-1] = 0;
ptr[-(hexsz + 2)] = ptr[-1] = 0;
if (add_cacheinfo(mode, &oid, path_name, stage))
die("git update-index: unable to update %s",
path_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册