From: Junio C Hamano <gitster@pobox.com>
To: "Dmitry Potapov" <dpotapov@gmail.com>
Cc: "Alexander Litvinov" <litvinov2004@gmail.com>,
git@vger.kernel.org, "Eric Wong" <normalperson@yhbt.net>
Subject: Re: [PATCH] git-svn now work with crlf convertion enabled.
Date: Fri, 01 Aug 2008 12:42:44 -0700 [thread overview]
Message-ID: <7vmyjwserv.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 37fcd2780808010224l68c2c717y5334a34d9de1de8d@mail.gmail.com
"Dmitry Potapov" <dpotapov@gmail.com> writes:
> On Fri, Aug 1, 2008 at 12:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> "Dmitry Potapov" <dpotapov@gmail.com> writes:
>>>
>>> To being able to synchronize efficiently in both ways, you need to store
>>> files exactly as they were received from SVN then there will be no
>>> problem with applying binary delta patch. All CRLF conversion should be
>>> done on checkout and checkin from/to Git repository.
>>
>> Ahh,... if that is the philosophy, perhaps we can teach --stdin-paths to
>> optionally open the file itself and use index_pipe() like --stdin codepath
>> does?
>
> It is possible to do in this way, but it less efficient, because it uses
> index_pipe, which does not know the actual size, so it reallocates the buffer
> as it reads data from the descriptor, while index_fd uses xmap() instead.
> So I sent another solution yesterday:
> http://article.gmane.org/gmane.comp.version-control.git/90968
>
> It is a bit hackish because...
Ok, earlier I was confused who was proposing what for what purpose, but
that one was not just "a bit hackish" but an unacceptable hack ;-)
Perhaps you would want to do the s/write_object/flags/ conversion, like
this?
--
cache.h | 9 ++++++---
sha1_file.c | 15 +++++++++------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/cache.h b/cache.h
index 2475de9..39975fb 100644
--- a/cache.h
+++ b/cache.h
@@ -390,9 +390,12 @@ extern int ie_match_stat(const struct index_state *, struct cache_entry *, struc
extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
-extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
-extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object);
-extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
+
+#define HASH_OBJECT_DO_CREATE 01
+#define HASH_OBJECT_LITERALLY 02
+extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int flags, enum object_type type, const char *path);
+extern int index_pipe(unsigned char *sha1, int fd, const char *type, int flags);
+extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int flags);
extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
#define REFRESH_REALLY 0x0001 /* ignore_valid */
diff --git a/sha1_file.c b/sha1_file.c
index e281c14..5def648 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2353,10 +2353,11 @@ int has_sha1_file(const unsigned char *sha1)
return has_loose_object(sha1);
}
-int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)
+int index_pipe(unsigned char *sha1, int fd, const char *type, int flags)
{
struct strbuf buf;
int ret;
+ int write_object = flags & HASH_OBJECT_DO_CREATE;
strbuf_init(&buf, 0);
if (strbuf_read(&buf, fd, 4096) < 0) {
@@ -2375,9 +2376,11 @@ int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)
return ret;
}
-int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
+int index_fd(unsigned char *sha1, int fd, struct stat *st, int flags,
enum object_type type, const char *path)
{
+ int write_object = flags & HASH_OBJECT_DO_CREATE;
+ int hash_literally = flags & HASH_OBJECT_LITERALLY;
size_t size = xsize_t(st->st_size);
void *buf = NULL;
int ret, re_allocated = 0;
@@ -2392,7 +2395,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
/*
* Convert blobs to git internal format
*/
- if ((type == OBJ_BLOB) && S_ISREG(st->st_mode)) {
+ if (!hash_literally && (type == OBJ_BLOB) && S_ISREG(st->st_mode)) {
struct strbuf nbuf;
strbuf_init(&nbuf, 0);
if (convert_to_git(path, buf, size, &nbuf,
@@ -2416,7 +2419,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
return ret;
}
-int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object)
+int index_path(unsigned char *sha1, const char *path, struct stat *st, int flags)
{
int fd;
char *target;
@@ -2428,7 +2431,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
if (fd < 0)
return error("open(\"%s\"): %s", path,
strerror(errno));
- if (index_fd(sha1, fd, st, write_object, OBJ_BLOB, path) < 0)
+ if (index_fd(sha1, fd, st, flags, OBJ_BLOB, path) < 0)
return error("%s: failed to insert into database",
path);
break;
@@ -2441,7 +2444,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
return error("readlink(\"%s\"): %s", path,
errstr);
}
- if (!write_object)
+ if (!(flags & HASH_OBJECT_DO_CREATE))
hash_sha1_file(target, len, blob_type, sha1);
else if (write_sha1_file(target, len, blob_type, sha1))
return error("%s: failed to insert into database",
next prev parent reply other threads:[~2008-08-01 19:44 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-23 8:44 git-svn does not seems to work with crlf convertion enabled Alexander Litvinov
2008-07-23 9:18 ` Johannes Schindelin
2008-07-23 11:52 ` Alexander Litvinov
2008-07-23 12:57 ` Johannes Schindelin
2008-07-23 15:49 ` Avery Pennarun
2008-07-23 16:07 ` Johannes Schindelin
2008-07-24 3:13 ` Alexander Litvinov
2008-08-06 11:15 ` Petr Baudis
2008-08-06 12:35 ` Peter Harris
2008-08-06 12:43 ` Johannes Schindelin
2008-08-06 13:51 ` git-svn on MSysGit and why is it (going to be?) unsupported Petr Baudis
2008-08-06 15:23 ` Avery Pennarun
2008-08-06 16:11 ` git-svn does not seems to work with crlf convertion enabled Dmitry Potapov
2008-07-24 14:24 ` Dmitry Potapov
2008-07-24 14:40 ` Johannes Schindelin
2008-07-24 16:28 ` Avery Pennarun
2008-07-30 4:37 ` Alexander Litvinov
2008-07-31 5:43 ` [PATCH] git-svn now " Alexander Litvinov
2008-07-31 5:57 ` Alexander Litvinov
2008-07-31 10:45 ` Dmitry Potapov
2008-07-31 19:09 ` [RFC] hash-object --no-filters Dmitry Potapov
2008-08-01 3:23 ` [PATCH] git-svn now work with crlf convertion enabled Alexander Litvinov
2008-08-01 5:09 ` Junio C Hamano
2008-08-01 7:44 ` Dmitry Potapov
2008-08-01 11:27 ` Alexander Litvinov
2008-08-01 7:47 ` Dmitry Potapov
2008-08-01 8:08 ` Junio C Hamano
2008-08-01 9:24 ` Dmitry Potapov
2008-08-01 19:42 ` Junio C Hamano [this message]
2008-08-01 22:09 ` Dmitry Potapov
2008-08-01 22:14 ` Junio C Hamano
2008-08-01 23:10 ` Dmitry Potapov
2008-08-02 17:28 ` [PATCH] hash-object --no-filters Junio C Hamano
2008-08-03 5:42 ` Dmitry Potapov
2008-08-03 5:56 ` Dmitry Potapov
2008-08-03 14:36 ` [PATCH 1/5] correct argument checking test for git hash-object Dmitry Potapov
2008-08-03 14:36 ` [PATCH 2/5] correct usage help string for git-hash-object Dmitry Potapov
2008-08-03 14:36 ` [PATCH 3/5] use parse_options() in git hash-object Dmitry Potapov
2008-08-03 14:36 ` [PATCH 4/5] add --path option to " Dmitry Potapov
2008-08-03 14:36 ` [PATCH 5/5] add --no-filters " Dmitry Potapov
2008-08-03 20:44 ` [PATCH] hash-object --no-filters Junio C Hamano
2008-08-01 11:11 ` [PATCH] git-svn now work with crlf convertion enabled Alexander Litvinov
2008-08-01 12:36 ` Dmitry Potapov
2008-08-04 3:10 ` Alexander Litvinov
2008-08-04 0:48 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vmyjwserv.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=dpotapov@gmail.com \
--cc=git@vger.kernel.org \
--cc=litvinov2004@gmail.com \
--cc=normalperson@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.