From: Dmitry Potapov <dpotapov@gmail.com>
To: git@vger.kernel.org
Cc: Alexander Litvinov <litvinov2004@gmail.com>
Subject: [RFC] hash-object --no-filters
Date: Thu, 31 Jul 2008 23:09:49 +0400 [thread overview]
Message-ID: <20080731190949.GI7008@dpotapov.dyndns.org> (raw)
In-Reply-To: <20080731104529.GE7008@dpotapov.dyndns.org>
Hi All,
I am tryint to add the --no-filters option. It is useful for git-svn
and other importers that want to add file as-is without being affected
by any filter (in particular, autocrlf). Though, the patch below works,
I am not happy with the hackish way of passing no-filter requirement
to the index_fd() function. So, I wonder what would be preferable:
- to change 'write_object' to be flags (bit 0: write_object,
bit 1: no-filters )
- to add some global the no_filters flag to environment.c, which can
be checked inside of convert_to_git(), so it may be used in the
future in some other cases (though I don't see where else it can
be useful).
Another question: currently git hash-object --input imply no filters.
I don't know if it was done intentionally (it can be argued in both
ways). I don't think it is reasonable now to change this behavior,
so I want to add just one line to documentation, so there will be
no surprise among users.
Dmitry
-- 8< --
From: Dmitry Potapov <dpotapov@gmail.com>
Date: Thu, 31 Jul 2008 21:10:26 +0400
Subject: [PATCH] hash-object --no-filters
The --no-filters option makes git hash-object to work as there were no
input filters. This option is useful for importers such as git-svn to
put new version of files as is even if autocrlf is set.
---
Documentation/git-hash-object.txt | 6 ++++++
hash-object.c | 7 ++++++-
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt
index ac928e1..69a17c7 100644
--- a/Documentation/git-hash-object.txt
+++ b/Documentation/git-hash-object.txt
@@ -35,6 +35,12 @@ OPTIONS
--stdin-paths::
Read file names from stdin instead of from the command-line.
+--no-filters::
+ If this option is given then the file is hashed as is ignoring
+ all filters specified in the configuration, including crlf
+ conversion. If the file is read from standard input then no
+ filters is always implied.
+
Author
------
Written by Junio C Hamano <gitster@pobox.com>
diff --git a/hash-object.c b/hash-object.c
index 46c06a9..1e7fe8a 100644
--- a/hash-object.c
+++ b/hash-object.c
@@ -8,6 +8,8 @@
#include "blob.h"
#include "quote.h"
+static unsigned no_filters;
+
static void hash_object(const char *path, enum object_type type, int write_object)
{
int fd;
@@ -16,7 +18,8 @@ static void hash_object(const char *path, enum object_type type, int write_objec
fd = open(path, O_RDONLY);
if (fd < 0 ||
fstat(fd, &st) < 0 ||
- index_fd(sha1, fd, &st, write_object, type, path))
+ ((no_filters ? st.st_mode &= ~S_IFREG : 0),
+ index_fd(sha1, fd, &st, write_object, type, path)))
die(write_object
? "Unable to add %s to database"
: "Unable to hash %s", path);
@@ -104,6 +107,8 @@ int main(int argc, char **argv)
die("Multiple --stdin arguments are not supported");
hashstdin = 1;
}
+ else if (!strcmp(argv[i], "--no-filters"))
+ no_filters = 1;
else
usage(hash_object_usage);
}
--
1.6.0.rc1.32.gc84cb
next prev parent reply other threads:[~2008-07-31 19:10 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 ` Dmitry Potapov [this message]
2008-08-01 3:23 ` 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
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=20080731190949.GI7008@dpotapov.dyndns.org \
--to=dpotapov@gmail.com \
--cc=git@vger.kernel.org \
--cc=litvinov2004@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).