Skip to content

Commit a9f9790

Browse files
kusmaEric Wong
authored andcommitted
hash-object: support --stdin-paths with --no-filters
Signed-off-by: Erik Faye-Lund <[email protected]> Acked-by: Junio C Hamano <[email protected]>
1 parent be2fb16 commit a9f9790

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Documentation/git-hash-object.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SYNOPSIS
1010
--------
1111
[verse]
1212
'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>
1414

1515
DESCRIPTION
1616
-----------

builtin-hash-object.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ static void hash_object(const char *path, const char *type, int write_object,
3333
hash_fd(fd, type, write_object, vpath);
3434
}
3535

36+
static int no_filters;
37+
3638
static void hash_stdin_paths(const char *type, int write_objects)
3739
{
3840
struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT;
@@ -44,7 +46,8 @@ static void hash_stdin_paths(const char *type, int write_objects)
4446
die("line is badly quoted");
4547
strbuf_swap(&buf, &nbuf);
4648
}
47-
hash_object(buf.buf, type, write_objects, buf.buf);
49+
hash_object(buf.buf, type, write_objects,
50+
no_filters ? NULL : buf.buf);
4851
}
4952
strbuf_release(&buf);
5053
strbuf_release(&nbuf);
@@ -60,7 +63,6 @@ static const char *type;
6063
static int write_object;
6164
static int hashstdin;
6265
static int stdin_paths;
63-
static int no_filters;
6466
static const char *vpath;
6567

6668
static const struct option hash_object_options[] = {
@@ -100,8 +102,6 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
100102
errstr = "Can't specify files with --stdin-paths";
101103
else if (vpath)
102104
errstr = "Can't use --stdin-paths with --path";
103-
else if (no_filters)
104-
errstr = "Can't use --stdin-paths with --no-filters";
105105
}
106106
else {
107107
if (hashstdin > 1)

t/t1007-hash-object.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ test_expect_success "Can't use --path with --stdin-paths" '
6565
echo example | test_must_fail git hash-object --stdin-paths --path=foo
6666
'
6767

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-
7268
test_expect_success "Can't use --path with --no-filters" '
7369
test_must_fail git hash-object --no-filters --path=foo
7470
'
@@ -141,6 +137,20 @@ test_expect_success 'check that --no-filters option works' '
141137
git config --unset core.autocrlf
142138
'
143139

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+
144154
pop_repo
145155

146156
for args in "-w --stdin" "--stdin -w"; do

0 commit comments

Comments
 (0)