Skip to content

Commit

Permalink
Merge branch 'master' into fix-unlock-by-id
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Oct 3, 2017
2 parents c463dca + 12a5c5b commit 1ba0d3c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
6 changes: 3 additions & 3 deletions commands/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ type singleCheckout struct {
}

func (c *singleCheckout) Run(p *lfs.WrappedPointer) {
cwdfilepath := c.pathConverter.Convert(p.Name)

// Check the content - either missing or still this pointer (not exist is ok)
filepointer, err := lfs.DecodePointerFromFile(p.Name)
filepointer, err := lfs.DecodePointerFromFile(cwdfilepath)
if err != nil && !os.IsNotExist(err) {
if errors.IsNotAPointerError(err) {
// File has non-pointer content, leave it alone
Expand All @@ -56,8 +58,6 @@ func (c *singleCheckout) Run(p *lfs.WrappedPointer) {
return
}

cwdfilepath := c.pathConverter.Convert(p.Name)

err = lfs.PointerSmudgeToFile(cwdfilepath, p.Pointer, false, c.manifest, nil)
if err != nil {
if errors.IsDownloadDeclinedError(err) {
Expand Down
7 changes: 6 additions & 1 deletion lfsapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,17 @@ func (c *Client) Close() error {
}

func (c *Client) extraHeadersFor(req *http.Request) http.Header {
extraHeaders := c.extraHeaders(req.URL)
if len(extraHeaders) == 0 {
return req.Header
}

copy := make(http.Header, len(req.Header))
for k, vs := range req.Header {
copy[k] = vs
}

for k, vs := range c.extraHeaders(req.URL) {
for k, vs := range extraHeaders {
for _, v := range vs {
copy[k] = append(copy[k], v)
}
Expand Down
45 changes: 38 additions & 7 deletions test/test-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,42 @@ begin_test "pull"
contents_oid=$(calc_oid "$contents")
contents2="A"
contents2_oid=$(calc_oid "$contents2")
contents3="dir"
contents3_oid=$(calc_oid "$contents3")

mkdir dir
echo "*.log" > .gitignore
printf "$contents" > a.dat
printf "$contents2" > á.dat
git add a.dat á.dat .gitattributes
printf "$contents3" > dir/dir.dat
git add .
git commit -m "add files" 2>&1 | tee commit.log
grep "master (root-commit)" commit.log
grep "3 files changed" commit.log
grep "5 files changed" commit.log
grep "create mode 100644 a.dat" commit.log
grep "create mode 100644 .gitattributes" commit.log

ls -al
[ "a" = "$(cat a.dat)" ]
[ "A" = "$(cat "á.dat")" ]
[ "dir" = "$(cat "dir/dir.dat")" ]

assert_pointer "master" "a.dat" "$contents_oid" 1
assert_pointer "master" "á.dat" "$contents2_oid" 1
assert_pointer "master" "dir/dir.dat" "$contents3_oid" 3

refute_server_object "$reponame" "$contents_oid"
refute_server_object "$reponame" "$contents2_oid"
refute_server_object "$reponame" "$contents33oid"

echo "initial push"
git push origin master 2>&1 | tee push.log
grep "(2 of 2 files)" push.log
grep "(3 of 3 files)" push.log
grep "master -> master" push.log

assert_server_object "$reponame" "$contents_oid"
assert_server_object "$reponame" "$contents2_oid"
assert_server_object "$reponame" "$contents3_oid"

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

assert_local_object "$contents_oid" 1
assert_local_object "$contents2_oid" 1
assert_clean_status

echo "lfs pull"
rm a.dat á.dat
rm -r a.dat á.dat dir # removing files makes the status dirty
rm -rf .git/lfs/objects
git lfs pull 2>&1 | grep "(2 of 2 files)"
git lfs pull 2>&1 | grep "(3 of 3 files)"
ls -al
[ "a" = "$(cat a.dat)" ]
[ "A" = "$(cat "á.dat")" ]
assert_local_object "$contents_oid" 1
assert_local_object "$contents2_oid" 1

echo "lfs pull with remote"
rm a.dat á.dat
rm -r a.dat á.dat dir
rm -rf .git/lfs/objects
git lfs pull origin 2>&1 | grep "(2 of 2 files)"
git lfs pull origin 2>&1 | grep "(3 of 3 files)"
[ "a" = "$(cat a.dat)" ]
[ "A" = "$(cat "á.dat")" ]
assert_local_object "$contents_oid" 1
Expand Down Expand Up @@ -105,6 +115,27 @@ begin_test "pull"
rm -rf .git/lfs/objects
git lfs pull --exclude="a*"
refute_local_object "$contents_oid"

echo "resetting to test status"
git reset --hard
assert_clean_status

echo "lfs pull clean status"
git lfs pull
assert_clean_status

echo "lfs pull with -I"
git lfs pull -I "*.dat"
assert_clean_status

echo "lfs pull in subdir"
cd dir
git lfs pull
assert_clean_status

echo "lfs pull in subdir with -I"
git lfs pull -I "*.dat"
assert_clean_status
)
end_test

Expand Down
9 changes: 8 additions & 1 deletion test/testhelpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ assert_hooks() {
[ -x "$git_root/hooks/pre-push" ]
}

assert_clean_status() {
status="$(git status)"
echo "$status" | grep "working tree clean" || {
echo $status
git lfs status
}
}

# pointer returns a string Git LFS pointer file.
#
# $ pointer abc-some-oid 123 <version>
Expand Down Expand Up @@ -340,7 +348,6 @@ clone_repo_url() {
echo "$out"
}


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

0 comments on commit 1ba0d3c

Please sign in to comment.