Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
convert: convert crlf_to_git to take an index
author
Brandon Williams
<bmwill@google.com>
Mon, 12 Jun 2017 22:13:53 +0000
(15:13 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 13 Jun 2017 18:40:51 +0000
(11:40 -0700)
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
convert.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
a7609c5
)
diff --git
a/convert.c
b/convert.c
index 03160b376a47489b1ccf614cb636702fac993051..0cafb06f56baa893a969e4075655e3750e2bf5ee 100644
(file)
--- a/
convert.c
+++ b/
convert.c
@@
-218,13
+218,13
@@
static void check_safe_crlf(const char *path, enum crlf_action crlf_action,
}
}
}
}
-static int has_cr_in_index(const char *path)
+static int has_cr_in_index(const
struct index_state *istate, const
char *path)
{
unsigned long sz;
void *data;
int has_cr;
{
unsigned long sz;
void *data;
int has_cr;
- data = read_blob_data_from_
cache(
path, &sz);
+ data = read_blob_data_from_
index(istate,
path, &sz);
if (!data)
return 0;
has_cr = memchr(data, '\r', sz) != NULL;
if (!data)
return 0;
has_cr = memchr(data, '\r', sz) != NULL;
@@
-254,7
+254,8
@@
static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats,
}
}
-static int crlf_to_git(const char *path, const char *src, size_t len,
+static int crlf_to_git(const struct index_state *istate,
+ const char *path, const char *src, size_t len,
struct strbuf *buf,
enum crlf_action crlf_action, enum safe_crlf checksafe)
{
struct strbuf *buf,
enum crlf_action crlf_action, enum safe_crlf checksafe)
{
@@
-286,7
+287,8
@@
static int crlf_to_git(const char *path, const char *src, size_t len,
* unless we want to renormalize in a merge or
* cherry-pick.
*/
* unless we want to renormalize in a merge or
* cherry-pick.
*/
- if ((checksafe != SAFE_CRLF_RENORMALIZE) && has_cr_in_index(path))
+ if ((checksafe != SAFE_CRLF_RENORMALIZE) &&
+ has_cr_in_index(istate, path))
convert_crlf_into_lf = 0;
}
if ((checksafe == SAFE_CRLF_WARN ||
convert_crlf_into_lf = 0;
}
if ((checksafe == SAFE_CRLF_WARN ||
@@
-1098,7
+1100,7
@@
int convert_to_git(const char *path, const char *src, size_t len,
src = dst->buf;
len = dst->len;
}
src = dst->buf;
len = dst->len;
}
- ret |= crlf_to_git(path, src, len, dst, ca.crlf_action, checksafe);
+ ret |= crlf_to_git(
&the_index,
path, src, len, dst, ca.crlf_action, checksafe);
if (ret && dst) {
src = dst->buf;
len = dst->len;
if (ret && dst) {
src = dst->buf;
len = dst->len;
@@
-1118,7
+1120,7
@@
void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,
if (!apply_filter(path, NULL, 0, fd, dst, ca.drv, CAP_CLEAN))
die("%s: clean filter '%s' failed", path, ca.drv->name);
if (!apply_filter(path, NULL, 0, fd, dst, ca.drv, CAP_CLEAN))
die("%s: clean filter '%s' failed", path, ca.drv->name);
- crlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);
+ crlf_to_git(
&the_index,
path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);
ident_to_git(path, dst->buf, dst->len, dst, ca.ident);
}
ident_to_git(path, dst->buf, dst->len, dst, ca.ident);
}