Skip to content

Commit 7158e3b

Browse files
committed
add files to index with path relative to current dir
1 parent e4a01bc commit 7158e3b

File tree

3 files changed

+49
-11
lines changed

3 files changed

+49
-11
lines changed

commands/pull.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ type singleCheckout struct {
3838
}
3939

4040
func (c *singleCheckout) Run(p *lfs.WrappedPointer) {
41+
cwdfilepath := c.pathConverter.Convert(p.Name)
42+
4143
// Check the content - either missing or still this pointer (not exist is ok)
42-
filepointer, err := lfs.DecodePointerFromFile(p.Name)
44+
filepointer, err := lfs.DecodePointerFromFile(cwdfilepath)
4345
if err != nil && !os.IsNotExist(err) {
4446
if errors.IsNotAPointerError(err) {
4547
// File has non-pointer content, leave it alone
@@ -56,8 +58,6 @@ func (c *singleCheckout) Run(p *lfs.WrappedPointer) {
5658
return
5759
}
5860

59-
cwdfilepath := c.pathConverter.Convert(p.Name)
60-
6161
err = lfs.PointerSmudgeToFile(cwdfilepath, p.Pointer, false, c.manifest, nil)
6262
if err != nil {
6363
if errors.IsDownloadDeclinedError(err) {

test/test-pull.sh

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,42 @@ begin_test "pull"
1919
contents_oid=$(calc_oid "$contents")
2020
contents2="A"
2121
contents2_oid=$(calc_oid "$contents2")
22+
contents3="dir"
23+
contents3_oid=$(calc_oid "$contents3")
2224

25+
mkdir dir
26+
echo "*.log" > .gitignore
2327
printf "$contents" > a.dat
2428
printf "$contents2" > á.dat
25-
git add a.dat á.dat .gitattributes
29+
printf "$contents3" > dir/dir.dat
30+
git add .
2631
git commit -m "add files" 2>&1 | tee commit.log
2732
grep "master (root-commit)" commit.log
28-
grep "3 files changed" commit.log
33+
grep "5 files changed" commit.log
2934
grep "create mode 100644 a.dat" commit.log
3035
grep "create mode 100644 .gitattributes" commit.log
3136

3237
ls -al
3338
[ "a" = "$(cat a.dat)" ]
3439
[ "A" = "$(cat "á.dat")" ]
40+
[ "dir" = "$(cat "dir/dir.dat")" ]
3541

3642
assert_pointer "master" "a.dat" "$contents_oid" 1
3743
assert_pointer "master" "á.dat" "$contents2_oid" 1
44+
assert_pointer "master" "dir/dir.dat" "$contents3_oid" 3
3845

3946
refute_server_object "$reponame" "$contents_oid"
4047
refute_server_object "$reponame" "$contents2_oid"
48+
refute_server_object "$reponame" "$contents33oid"
4149

4250
echo "initial push"
4351
git push origin master 2>&1 | tee push.log
44-
grep "(2 of 2 files)" push.log
52+
grep "(3 of 3 files)" push.log
4553
grep "master -> master" push.log
4654

4755
assert_server_object "$reponame" "$contents_oid"
4856
assert_server_object "$reponame" "$contents2_oid"
57+
assert_server_object "$reponame" "$contents3_oid"
4958

5059
# change to the clone's working directory
5160
cd ../clone
@@ -58,21 +67,22 @@ begin_test "pull"
5867

5968
assert_local_object "$contents_oid" 1
6069
assert_local_object "$contents2_oid" 1
70+
assert_clean_status
6171

6272
echo "lfs pull"
63-
rm a.dat á.dat
73+
rm -r a.dat á.dat dir # removing files makes the status dirty
6474
rm -rf .git/lfs/objects
65-
git lfs pull 2>&1 | grep "(2 of 2 files)"
75+
git lfs pull 2>&1 | grep "(3 of 3 files)"
6676
ls -al
6777
[ "a" = "$(cat a.dat)" ]
6878
[ "A" = "$(cat "á.dat")" ]
6979
assert_local_object "$contents_oid" 1
7080
assert_local_object "$contents2_oid" 1
7181

7282
echo "lfs pull with remote"
73-
rm a.dat á.dat
83+
rm -r a.dat á.dat dir
7484
rm -rf .git/lfs/objects
75-
git lfs pull origin 2>&1 | grep "(2 of 2 files)"
85+
git lfs pull origin 2>&1 | grep "(3 of 3 files)"
7686
[ "a" = "$(cat a.dat)" ]
7787
[ "A" = "$(cat "á.dat")" ]
7888
assert_local_object "$contents_oid" 1
@@ -105,6 +115,27 @@ begin_test "pull"
105115
rm -rf .git/lfs/objects
106116
git lfs pull --exclude="a*"
107117
refute_local_object "$contents_oid"
118+
119+
echo "resetting to test status"
120+
git reset --hard
121+
assert_clean_status
122+
123+
echo "lfs pull clean status"
124+
git lfs pull
125+
assert_clean_status
126+
127+
echo "lfs pull with -I"
128+
git lfs pull -I "*.dat"
129+
assert_clean_status
130+
131+
echo "lfs pull in subdir"
132+
cd dir
133+
git lfs pull
134+
assert_clean_status
135+
136+
echo "lfs pull in subdir with -I"
137+
git lfs pull -I "*.dat"
138+
assert_clean_status
108139
)
109140
end_test
110141

test/testhelpers.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,14 @@ assert_hooks() {
238238
[ -x "$git_root/hooks/pre-push" ]
239239
}
240240

241+
assert_clean_status() {
242+
status="$(git status)"
243+
echo "$status" | grep "working tree clean" || {
244+
echo $status
245+
git lfs status
246+
}
247+
}
248+
241249
# pointer returns a string Git LFS pointer file.
242250
#
243251
# $ pointer abc-some-oid 123 <version>
@@ -340,7 +348,6 @@ clone_repo_url() {
340348
echo "$out"
341349
}
342350

343-
344351
# clone_repo_ssl clones a repository from the test Git server to the subdirectory
345352
# $dir under $TRASHDIR, using the SSL endpoint.
346353
# setup_remote_repo() needs to be run first. Output is written to clone_ssl.log.

0 commit comments

Comments
 (0)