From: David Barr <davidbarr@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Andrew Sayers <andrew-git@pileofstuff.org>,
Jonathan Nieder <jrnieder@gmail.com>,
Dmitry Ivankov <divanorama@gmail.com>,
David Barr <davidbarr@google.com>
Subject: [PATCH] fast-import: fix ls command with empty path
Date: Thu, 8 Mar 2012 16:30:56 +1100 [thread overview]
Message-ID: <1331184656-98629-1-git-send-email-davidbarr@google.com> (raw)
In-Reply-To: <CAFfmPPMxcs0ySgnD7UfUS1yq=qaqfn1qCxdh1HYgFu6WPfpWQg@mail.gmail.com>
There is a pathological Subversion operation that svn-fe handles
incorrectly due to an unexpected response from fast-import:
svn cp $SVN_ROOT $SVN_ROOT/subdirectory
When the following command is sent to fast-import:
'ls' SP ':1' SP LF
The expected output is:
'040000' SP 'tree' SP <dataref> HT LF
The actual output is:
'missing' SP LF
This is because tree_content_get() is called but expects a non-empty
path. Instead, copy the root entry and force the mode to S_IFDIR.
Reported-by: Andrew Sayers <andrew-git@pileofstuff.org>
Signed-off-by: David Barr <davidbarr@google.com>
---
fast-import.c | 7 ++++++-
t/t9300-fast-import.sh | 31 +++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/fast-import.c b/fast-import.c
index c1486ca..8dbfd4c 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -3019,7 +3019,12 @@ static void parse_ls(struct branch *b)
die("Garbage after path in: %s", command_buf.buf);
p = uq.buf;
}
- tree_content_get(root, p, &leaf);
+ if (*p) {
+ tree_content_get(root, p, &leaf);
+ } else {
+ leaf = *root;
+ leaf.versions[1].mode = S_IFDIR;
+ }
/*
* A directory in preparation would have a sha1 of zero
* until it is saved. Save, for simplicity.
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 438aaf6..2558a2e 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1400,6 +1400,37 @@ test_expect_success \
test_cmp expect.qux actual.qux &&
test_cmp expect.qux actual.quux'
+test_expect_success PIPE 'N: read and copy root' '
+ cat >expect <<-\EOF
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/file2/newf
+ :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/file2/oldf
+ :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 file3/file4
+ :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh file3/newdir/exec.sh
+ :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/newdir/interesting
+ EOF
+ git update-ref -d refs/heads/N12 &&
+ rm -f backflow &&
+ mkfifo backflow &&
+ (
+ exec <backflow &&
+ cat <<-EOF &&
+ commit refs/heads/N12
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ copy root directory by tree hash read via ls
+ COMMIT
+
+ from refs/heads/branch^0
+ ls ""
+ EOF
+ read mode type tree filename &&
+ echo "M 040000 $tree file3"
+ ) |
+ git fast-import --cat-blob-fd=3 3>backflow &&
+ git diff-tree -C --find-copies-harder -r N12^ N12 >actual &&
+ compare_diff_raw expect actual
+'
+
###
### series O
###
--
1.7.9.3
next prev parent reply other threads:[~2012-03-08 5:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-08 3:13 [BUG] fast-import: ls command on commit root returns missing (was: Bug in svn-fe: copying the root directory acts as if it's an empty directory) David Barr
2012-03-08 5:30 ` David Barr [this message]
2012-03-08 7:09 ` [PATCH] fast-import: fix ls command with empty path Jonathan Nieder
2012-03-08 15:29 ` Sverre Rabbelier
2012-03-08 16:39 ` Junio C Hamano
2012-03-08 17:33 ` Dmitry Ivankov
2012-03-08 19:32 ` Jonathan Nieder
2012-03-10 9:48 ` Jonathan Nieder
2012-03-08 18:15 ` Jonathan Nieder
2012-03-10 3:12 ` Jonathan Nieder
2012-03-10 3:20 ` [PATCH maint-1.7.6] fast-import: leakfix for 'ls' of dirty trees Jonathan Nieder
2012-03-10 4:00 ` [PATCH maint-1.7.6] fast-import: don't allow 'ls' of path with empty components Jonathan Nieder
2012-03-10 4:30 ` [PULL maint] two fast-import "ls" fixes Jonathan Nieder
2012-03-10 7:00 ` [NON-PATCH] vcs-svn: avoid 'ls' and filedelete with empty path Jonathan Nieder
2013-06-21 16:33 ` [PATCH] fast-import: fix ls command " Dave Abrahams
2012-03-08 20:27 ` [PATCH v2 0/2] " Jonathan Nieder
2012-03-08 20:31 ` [PATCH 1/2] fast-import: plug leak of dirty trees in 'ls' command Jonathan Nieder
2012-03-08 20:33 ` [PATCH 2/2] fast-import: teach ls command to accept empty path Jonathan Nieder
2012-03-09 4:28 ` David Barr
2012-03-09 9:29 ` Jonathan Nieder
2012-03-10 8:53 ` [PATCH v3] fast-import: allow 'ls' and filecopy to read the root Jonathan Nieder
2012-03-10 9:01 ` Jonathan Nieder
2012-03-10 9:18 ` [PATCH 2/1] fixup! " Jonathan Nieder
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331184656-98629-1-git-send-email-davidbarr@google.com \
--to=davidbarr@google.com \
--cc=andrew-git@pileofstuff.org \
--cc=divanorama@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).