@matheusbsbs / matheus-bagliano / commits / a9f979093d
Fork 0

hash-object: support --stdin-paths with --no-filters

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Acked-by: Junio C Hamano <gitster@pobox.com>

Erik Faye-Lund committed Mar 3, 2010 at 21:10 UTC a9f979093dabe8b1c7bf8d67863adc378a8bec45
3 files changed +19 -9
Documentation/git-hash-object.txt
+1 -1
@@ -10,7 +10,7 @@ SYNOPSIS
10 --------
11 [verse]
12 'git hash-object' [-t <type>] [-w] [--path=<file>|--no-filters] [--stdin] [--] <file>...
13 -'git hash-object' [-t <type>] [-w] --stdin-paths < <list-of-paths>
13 +'git hash-object' [-t <type>] [-w] --stdin-paths [--no-filters] < <list-of-paths>
14
15 DESCRIPTION
16 -----------
builtin-hash-object.c
+4 -4
@@ -33,6 +33,8 @@ static void hash_object(const char *path, const char *type, int write_object,
33 hash_fd(fd, type, write_object, vpath);
34 }
35
36 +static int no_filters;
37 +
38 static void hash_stdin_paths(const char *type, int write_objects)
39 {
40 struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT;
@@ -44,7 +46,8 @@ static void hash_stdin_paths(const char *type, int write_objects)
46 die("line is badly quoted");
47 strbuf_swap(&buf, &nbuf);
48 }
47 - hash_object(buf.buf, type, write_objects, buf.buf);
49 + hash_object(buf.buf, type, write_objects,
50 + no_filters ? NULL : buf.buf);
51 }
52 strbuf_release(&buf);
53 strbuf_release(&nbuf);
@@ -60,7 +63,6 @@ static const char *type;
63 static int write_object;
64 static int hashstdin;
65 static int stdin_paths;
63 -static int no_filters;
66 static const char *vpath;
67
68 static const struct option hash_object_options[] = {
@@ -100,8 +102,6 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
102 errstr = "Can't specify files with --stdin-paths";
103 else if (vpath)
104 errstr = "Can't use --stdin-paths with --path";
103 - else if (no_filters)
104 - errstr = "Can't use --stdin-paths with --no-filters";
105 }
106 else {
107 if (hashstdin > 1)
t/t1007-hash-object.sh
+14 -4
@@ -65,10 +65,6 @@ test_expect_success "Can't use --path with --stdin-paths" '
65 echo example | test_must_fail git hash-object --stdin-paths --path=foo
66 '
67
68 -test_expect_success "Can't use --stdin-paths with --no-filters" '
69 - echo example | test_must_fail git hash-object --stdin-paths --no-filters
70 -'
71 -
68 test_expect_success "Can't use --path with --no-filters" '
69 test_must_fail git hash-object --no-filters --path=foo
70 '
@@ -141,6 +137,20 @@ test_expect_success 'check that --no-filters option works' '
137 git config --unset core.autocrlf
138 '
139
140 +test_expect_success 'check that --no-filters option works with --stdin-paths' '
141 + echo fooQ | tr Q "\\015" >file0 &&
142 + cp file0 file1 &&
143 + echo "file0 -crlf" >.gitattributes &&
144 + echo "file1 crlf" >>.gitattributes &&
145 + git config core.autocrlf true &&
146 + file0_sha=$(git hash-object file0) &&
147 + file1_sha=$(git hash-object file1) &&
148 + test "$file0_sha" != "$file1_sha" &&
149 + nofilters_file1=$(echo "file1" | git hash-object --stdin-paths --no-filters) &&
150 + test "$file0_sha" = "$nofilters_file1" &&
151 + git config --unset core.autocrlf
152 +'
153 +
154 pop_repo
155
156 for args in "-w --stdin" "--stdin -w"; do